diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3400c8c82c..66a797e648 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,53 @@ on: - QA_** jobs: + multi-arch-tests-php: + name: Test on php ${{ matrix.php-version }} (${{ matrix.arch }}) + if: "!contains(github.event.head_commit.message, '[ci skip]')" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { php-version: '7', arch: 'amd64', exclude-phpunit-groups: 'selenium,extension-iconv' } + - { php-version: '7', arch: 'arm64v8', exclude-phpunit-groups: 'selenium,extension-iconv' } + - { php-version: '7', arch: 'arm32v7', exclude-phpunit-groups: 'selenium,extension-iconv,32bit-incompatible' } + - { php-version: '7', arch: 'arm32v6', exclude-phpunit-groups: 'selenium,extension-iconv,32bit-incompatible' } + - { php-version: '7', arch: 'i386', exclude-phpunit-groups: 'selenium,extension-iconv,32bit-incompatible' } + - { php-version: '7', arch: 'ppc64le', exclude-phpunit-groups: 'selenium,extension-iconv' } + - { php-version: '7', arch: 's390x', exclude-phpunit-groups: 'selenium,extension-iconv,32bit-incompatible' } + steps: + - uses: actions/checkout@v2 + - name: Write script + # tcpdf allowed memory exhausted needs the memory_limit workaround + # musl-locales and musl-locales-lang are needed to run some locale specific tests + # gettext is needed to run generate-mo + # pcov for code coverage + run: | + printf "set -exu && \ + export V='%s' && \ + apk add --update --no-cache \ + php\$V-cli php\$V-mysqli php\$V-session php\$V-mbstring \ + php\$V-iconv php\$V-xml php\$V-tokenizer php\$V-xmlwriter php\$V-simplexml \ + php\$V-dom php\$V-json php\$V-bz2 php\$V-curl php\$V-gd php\$V-zip \ + musl-locales musl-locales-lang \ + gettext composer && \ + apk add --update --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing php\$V-pecl-pcov && \ + composer update && \ + ./scripts/generate-mo && \ + php -d memory_limit=512M ./vendor/bin/phpunit --exclude-group=%s" \ + "${{ matrix.php-version }}" "${{ matrix.exclude-phpunit-groups }}" > ./do-tests.sh + - name: Setup multi arch support + run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - name: Print arch + run: docker run --rm ${{ matrix.arch }}/alpine:3.13 uname -a + - name: Run tests on php ${{ matrix.php-version }} + run: docker run -v $PWD:/app --workdir /app --rm ${{ matrix.arch }}/alpine:3.13 sh /app/do-tests.sh + - name: Send coverage + uses: codecov/codecov-action@v1 + with: + flags: arch-${{ matrix.php-version }}-${{ matrix.arch }} + name: phpunit-${{ matrix.php-version }}-${{ matrix.arch }} test-php: name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }} if: "!contains(github.event.head_commit.message, '[ci skip]')" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000000..3d2b7f495b --- /dev/null +++ b/install.sh @@ -0,0 +1 @@ +set -exu && export V='7' && apk add --update --no-cache php$V-cli php$V-mysqli php$V-session php$V-mbstring php$V-iconv php$V-xml php$V-tokenizer php$V-xmlwriter php$V-simplexml php$V-dom php$V-json php$V-bz2 php$V-curl php$V-gd php$V-zip gettext composer yarn && php -d memory_limit=512M ./vendor/bin/phpunit --no-coverage --exclude-group=selenium \ No newline at end of file diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index e442a8cf0e..979d639e08 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -68,6 +68,7 @@ use function sys_get_temp_dir; use function time; use function trigger_error; use function trim; +use function crc32; /** * Configuration class @@ -866,11 +867,11 @@ class Config { global $PMA_Theme; - return (int) ( - $this->sourceMtime + - $this->defaultSourceMtime + - $this->get('user_preferences_mtime') + - ($PMA_Theme->mtimeInfo ?? 0) + + return crc32( + $this->sourceMtime . + $this->defaultSourceMtime . + $this->get('user_preferences_mtime') . + ($PMA_Theme->mtimeInfo ?? 0) . ($PMA_Theme->filesizeInfo ?? 0) ); } diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 3f6c40825e..f382efba2f 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -123,7 +123,7 @@ class Util /** * Returns the formatted maximum size for an upload * - * @param int|string $max_upload_size the size + * @param int|float|string $max_upload_size the size * * @return string the message * @@ -696,9 +696,9 @@ class Util * * @param string|int $formatted_size the size expression (for example 8MB) * - * @return int The numerical part of the expression (for example 8) + * @return int|float The numerical part of the expression (for example 8) */ - public static function extractValueFromFormattedSize($formatted_size): int + public static function extractValueFromFormattedSize($formatted_size) { $return_value = -1; diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index 15f9a34b70..655b5c2425 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -29,6 +29,7 @@ use function realpath; use function strip_tags; use function stristr; use function sys_get_temp_dir; +use function crc32; class ConfigTest extends AbstractTestCase { @@ -945,16 +946,16 @@ class ConfigTest extends AbstractTestCase /** * Should test getting unique value for theme - * - * @group 32bit-incompatible */ public function testGetThemeUniqueValue(): void { - $partial_sum = $this->object->sourceMtime + - $this->object->defaultSourceMtime + - $this->object->get('user_preferences_mtime') + - $GLOBALS['PMA_Theme']->mtimeInfo + - $GLOBALS['PMA_Theme']->filesizeInfo; + $partial_sum = crc32( + $this->object->sourceMtime . + $this->object->defaultSourceMtime . + $this->object->get('user_preferences_mtime') . + $GLOBALS['PMA_Theme']->mtimeInfo . + $GLOBALS['PMA_Theme']->filesizeInfo + ); $this->assertEquals($partial_sum, $this->object->getThemeUniqueValue()); } diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 2e579b7017..862c2e64de 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -948,12 +948,12 @@ class UtilTest extends AbstractTestCase * Test for Util::extractValueFromFormattedSize * * @param int|string $size Size - * @param int $expected Expected value + * @param int|float $expected Expected value (float on some cpu architectures) * * @covers \PhpMyAdmin\Util::extractValueFromFormattedSize * @dataProvider providerExtractValueFromFormattedSize */ - public function testExtractValueFromFormattedSize($size, int $expected): void + public function testExtractValueFromFormattedSize($size, $expected): void { $this->assertEquals( $expected, @@ -1378,14 +1378,14 @@ class UtilTest extends AbstractTestCase /** * Test for Util::getFormattedMaximumUploadSize * - * @param int $size Size - * @param string $unit Unit - * @param string $res Result + * @param int|float $size Size (float on some cpu architectures) + * @param string $unit Unit + * @param string $res Result * * @covers \PhpMyAdmin\Util::getFormattedMaximumUploadSize * @dataProvider providerGetFormattedMaximumUploadSize */ - public function testGetFormattedMaximumUploadSize(int $size, string $unit, string $res): void + public function testGetFormattedMaximumUploadSize($size, string $unit, string $res): void { $this->assertEquals( '(' . __('Max: ') . $res . $unit . ')',