Merge pull request #17310 from mauriciofauth/ci-workflow-4.9

Add CI workflow for PHPUnit tests
This commit is contained in:
Maurício Meneghini Fauth 2022-01-22 16:01:09 -03:00 committed by GitHub
commit 6578ae9433
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 119 additions and 2 deletions

View File

@ -0,0 +1,95 @@
name: "Continuous Integration"
on:
pull_request:
push:
jobs:
phpunit:
name: "PHPUnit tests"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
php-version:
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install gettext"
run: "sudo apt-get install -y gettext"
- name: "Generate .mo files"
run: "./scripts/generate-mo --quiet"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "mbstring, iconv, mysqli, zip, gd, bz2"
php-version: "${{ matrix.php-version }}"
ini-values: "memory_limit=-1, error_reporting=E_ALL, display_errors=On"
- name: "Require PHPUnit 8 for PHP 7.4"
if: "matrix.php-version == '7.4'"
run: |
composer require --no-interaction php>=7.1
composer remove --dev --no-interaction phpunit/phpunit-selenium
composer remove --dev --no-interaction phpunit/phpunit
composer require --dev --no-interaction "phpunit/phpunit:~8.5"
rm -rf test/selenium
find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUpBeforeClass()/function setUpBeforeClass(): void/g'
find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function setUp()/function setUp(): void/g'
find test/ -type f -iname '*.php' -print0 | xargs -0 sed -i 's/function tearDown()/function tearDown(): void/g'
- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
- name: "Run tests for PHP 5.5"
if: "matrix.php-version == '5.5'"
run: "vendor/bin/phpunit --no-coverage --disallow-test-output --exclude-group selenium,git-revision,network"
- name: "Run tests"
if: "matrix.php-version != '5.5'"
run: "vendor/bin/phpunit --no-coverage --disallow-test-output --exclude-group selenium"
coding-standards:
name: "Check coding standards"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "7.1"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
ini-values: "memory_limit=-1"
- name: "Install dependencies"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"
- name: "Check coding standards"
run: |
vendor/bin/phpcs --config-set installed_paths ../../phpmyadmin/coding-standard
vendor/bin/phpcs

View File

@ -2,6 +2,7 @@
namespace PhpMyAdmin\Crypto;
use Exception;
use phpseclib\Crypt\AES;
use phpseclib\Crypt\Random;
@ -145,7 +146,12 @@ final class Crypto
$key = $this->getEncryptionKey();
$nonce = mb_substr($encrypted, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
$ciphertext = mb_substr($encrypted, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
$decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
try {
$decrypted = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
} catch (Exception $e) {
return null;
}
if ($decrypted === false) {
return null;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="phpMyAdmin Coding Standard">
<rule ref="./vendor/phpmyadmin/coding-standard/PMAStandard/ruleset.xml">
<rule ref="PMAStandard">
<exclude name="Generic.Metrics.NestingLevel.TooHigh"/>
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

View File

@ -232,6 +232,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'host' => '',
'controluser' => 'u2',
'controlpass' => 'p2',
'hide_connection_errors' => false,
);
$cfg_ssl = array(
'user' => 'u',
@ -240,6 +241,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'ssl' => true,
'controluser' => 'u2',
'controlpass' => 'p2',
'hide_connection_errors' => false,
);
$cfg_control_ssl = array(
'user' => 'u',
@ -248,6 +250,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'control_ssl' => true,
'controluser' => 'u2',
'controlpass' => 'p2',
'hide_connection_errors' => false,
);
return array(
array(
@ -267,6 +270,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'compress' => false,
'controluser' => 'u2',
'controlpass' => 'p2',
'hide_connection_errors' => false,
)
),
),
@ -283,6 +287,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => false,
'compress' => false,
'hide_connection_errors' => false,
)
),
),
@ -303,6 +308,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'compress' => false,
'controluser' => 'u2',
'controlpass' => 'p2',
'hide_connection_errors' => false,
)
),
),
@ -319,6 +325,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => true,
'compress' => false,
'hide_connection_errors' => false,
)
),
),
@ -340,6 +347,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'controluser' => 'u2',
'controlpass' => 'p2',
'control_ssl' => true,
'hide_connection_errors' => false,
)
),
),
@ -356,6 +364,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => true,
'compress' => false,
'hide_connection_errors' => false,
)
),
),

View File

@ -79,6 +79,13 @@ class EncodingTest extends TestCase
$this->markTestSkipped('iconv extension missing');
}
// Set PHP native locale
if (function_exists('setlocale') && setlocale(0, 'POSIX') === false) {
$this->markTestSkipped('native setlocale failed');
}
_setlocale(LC_ALL, 'POSIX');
if (PHP_INT_SIZE === 8) {
$GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT';
Encoding::setEngine(Encoding::ENGINE_ICONV);