Merge #16914 - Add multi arch tests support (amd64,arm64v8,arm32v7,arm32v6,i386,ppc64le,s390x)

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2021-05-28 15:37:40 +02:00
commit 8c8689d7ad
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
6 changed files with 71 additions and 21 deletions

View File

@ -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]')"

1
install.sh Executable file
View File

@ -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

View File

@ -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)
);
}

View File

@ -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;

View File

@ -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());
}

View File

@ -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 . ')',