From 777f10be7904b796a59e17501403cea4a08780d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 13:02:13 -0300 Subject: [PATCH 1/7] Add CI workflow for PHPUnit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/continuous-integration.yml | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/continuous-integration.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000000..a74d7370ab --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,48 @@ +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: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Run tests" + run: "vendor/bin/phpunit --no-coverage --disallow-test-output --exclude-group selenium" From 19ef2d84d462471b40e16b2d510c11d91b6cc51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 14:06:12 -0300 Subject: [PATCH 2/7] Fix `DatabaseInterfaceTest::testGetConnectionParams` tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- test/classes/DatabaseInterfaceTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php index 730cb78255..b514dd8b97 100644 --- a/test/classes/DatabaseInterfaceTest.php +++ b/test/classes/DatabaseInterfaceTest.php @@ -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, ) ), ), From 8577e70888ef08a2d4dd2d013da7dc3327c9976f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 14:23:06 -0300 Subject: [PATCH 3/7] Add coding standard check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/continuous-integration.yml | 30 ++++++++++++++++++++ phpcs.xml.dist | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a74d7370ab..d229a9514a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -46,3 +46,33 @@ jobs: - name: "Run tests" 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 diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 72448ac474..8b6c5f136f 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,6 @@ - + From 16c833fe068217c36256545a5da80330ac4e5ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 14:42:11 -0300 Subject: [PATCH 4/7] Fix CoreTest failing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Crypto/Crypto.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Crypto/Crypto.php b/libraries/classes/Crypto/Crypto.php index 6449f7dca5..f0ef18ec5d 100644 --- a/libraries/classes/Crypto/Crypto.php +++ b/libraries/classes/Crypto/Crypto.php @@ -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; } From aef5ee7ae43460a9716cfc83c6c34c99c2339b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 14:58:55 -0300 Subject: [PATCH 5/7] Fix iconv failing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 9b6cb9ce7dc3178267eca1e08b99b8ac2e431f85) Signed-off-by: Maurício Meneghini Fauth --- test/classes/EncodingTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/classes/EncodingTest.php b/test/classes/EncodingTest.php index 14fc8adcac..458e005ef2 100644 --- a/test/classes/EncodingTest.php +++ b/test/classes/EncodingTest.php @@ -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); From ea6fc6fe1ee08e3c36e7af91d1f3a9284af79b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 15:40:04 -0300 Subject: [PATCH 6/7] Skip git-revision and network groups for PHP 5.5 tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/continuous-integration.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d229a9514a..1743e57a00 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -44,7 +44,12 @@ jobs: 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: From c1ee33594e5ffe39a3af82eeb4ce33916cf18e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 22 Jan 2022 15:52:17 -0300 Subject: [PATCH 7/7] Fix tests for PHP 7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .github/workflows/continuous-integration.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 1743e57a00..3da44dae5c 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,6 +39,18 @@ jobs: 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: