Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the ability to run tests on PHP 8.0 #470

Merged
merged 21 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 56, 70, 71, 72, 73, 74 ]
php: [ 56, 70, 71, 72, 73, 74, 80 ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ build:
docker-compose pull
docker-compose build --pull

test: test74 test73 test72 test71 test70 test56
test: test80 test74 test73 test72 test71 test70 test56
test80:
docker-compose build --pull php80
docker-compose run php80 vendor/bin/phpunit --colors=always -v --debug
docker-compose down
test74:
docker-compose build --pull php74
docker-compose run php74 vendor/bin/phpunit --colors=always -v --debug
Expand Down
37 changes: 24 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
"symfony/process": "^3.3||^4.0||^5.0||^6.0"
},
"require-dev": {
"yiisoft/yii2-redis": "*",
"yiisoft/yii2-redis": "~2.0.0",
"php-amqplib/php-amqplib": "*",
"enqueue/amqp-lib": "^0.8||^0.9.10",
"pda/pheanstalk": "v3.*",
"pda/pheanstalk": "~3.2.1",
"opis/closure": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"phpunit/phpunit": "~4.4",
"yiisoft/yii2-debug": "~2.1.0",
"yiisoft/yii2-gii": "~2.2.0",
"phpunit/phpunit": "~5.0",
s1lver marked this conversation as resolved.
Show resolved Hide resolved
"aws/aws-sdk-php": ">=2.4",
"enqueue/stomp": "^0.8.39"
"enqueue/stomp": "^0.8.39",
"cweagans/composer-patches": "^1.7"
s1lver marked this conversation as resolved.
Show resolved Hide resolved
},
"suggest": {
"ext-pcntl": "Need for process signals.",
Expand Down Expand Up @@ -64,23 +65,33 @@
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"cweagans/composer-patches": true
}
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
},
"phpunit/php-file-iterator": {
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_path_file_iterator.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch",
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php81.patch"
}
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
}
]
}
11 changes: 11 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ services:
depends_on: *php_depends_on
networks:
net: { }
php80:
build:
context: ..
dockerfile: tests/docker/php/8.0/Dockerfile
volumes:
- ./runtime/.composer80:/root/.composer
dns: *php_dns
environment: *php_environment
depends_on: *php_depends_on
networks:
net: { }

# https://docs.docker.com/samples/library/mysql/
mysql:
Expand Down
20 changes: 20 additions & 0 deletions tests/docker/php/8.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM --platform=linux/amd64 php:8.0.28-cli-alpine

RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& echo https://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories \
&& apk update
RUN apk add bash unzip zlib-dev libzip-dev icu-dev libpq-dev gearman-dev autoconf g++ make musl

RUN docker-php-ext-install zip intl pcntl bcmath pdo_mysql pdo_pgsql
RUN pecl install igbinary gearman
RUN docker-php-ext-enable igbinary gearman

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
COPY --from=cytopia/php-cs-fixer:latest /usr/bin/php-cs-fixer /usr/local/bin/php-cs-fixer

COPY . /code
WORKDIR /code

ENTRYPOINT ["tests/docker/php/entrypoint-php80.sh"]
CMD ["sleep", "infinity"]
16 changes: 16 additions & 0 deletions tests/docker/php/entrypoint-php80.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -eu

flock tests/runtime/composer-install.lock composer install --prefer-dist --no-interaction --ignore-platform-req=php
composer require phpunit/phpunit:~7.5.20 --ignore-platform-req=php --dev --with-all-dependencies --no-interaction

tests/yii sqlite-migrate/up --interactive=0

tests/docker/php/mysql-lock.php tests/yii mysql-migrate/up --interactive=0

tests/docker/php/mysql-lock.php tests/yii pgsql-migrate/up --interactive=0

php --version
set -x
exec "$@"
1 change: 0 additions & 1 deletion tests/drivers/amqp_interop/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public function testSignals()
$process->signal($signal);
$process->wait();
$this->assertFalse($process->isRunning());
var_dump($exitCode, $process->getExitCode());
$this->assertEquals($exitCode, $process->getExitCode());
}
}
Expand Down