Skip to content

Commit

Permalink
Build improvements for Docker and extension (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lver committed Apr 4, 2023
1 parent f985cfa commit 1069811
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -28,6 +28,7 @@
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/phpunit.xml.dist export-ignore
/Makefile export-ignore
/tests export-ignore
/docs export-ignore

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Expand Up @@ -26,6 +26,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.2']
['8.0', '8.1', '8.2']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
5 changes: 2 additions & 3 deletions .gitignore
Expand Up @@ -17,7 +17,6 @@ composer.lock
# PHP CS Fixer
.php_cs.cache

# Env variables
.env

# PHPUnit
.phpunit.result.cache
coverage.html
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,2 +1,6 @@
Yii2 Queue Extension Change Log
Yii Queue Extension Change Log
===============================

## 1.0.0 under development

- Initial release.
65 changes: 22 additions & 43 deletions Makefile
@@ -1,53 +1,32 @@
COMPOSE_PROJECT_NAME=yii-queue
COMPOSE_FILE=tests/docker-compose.yml
export COMPOSE_PROJECT_NAME=yii-queue

test: test72 test71 test70 test56
test72:
docker-compose build php72
docker-compose run php72 vendor/bin/phpunit
docker-compose down
test71:
docker-compose build php71
docker-compose run php71 vendor/bin/phpunit
docker-compose down
test70:
docker-compose build php70
docker-compose run php70 vendor/bin/phpunit
docker-compose down
test56:
docker-compose build php56
docker-compose run php56 vendor/bin/phpunit
docker-compose down
build:
docker-compose -f tests/docker-compose.yml up -d --build

benchmark: benchmark72 benchmark71 benchmark70 benchmark56
benchmark72:
docker-compose build php72
docker-compose run php72 tests/yii benchmark/waiting
docker-compose down
benchmark71:
docker-compose build php71
docker-compose run php71 tests/yii benchmark/waiting
docker-compose down
benchmark70:
docker-compose build php70
docker-compose run php70 tests/yii benchmark/waiting
docker-compose down
benchmark56:
docker-compose build php56
docker-compose run php56 tests/yii benchmark/waiting
docker-compose down
down:
docker-compose -f tests/docker-compose.yml down

check-cs:
docker-compose build php72
docker-compose run php72 php-cs-fixer fix --diff --dry-run
docker-compose down
test:
docker-compose -f tests/docker-compose.yml build --pull php$(v)
docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/phpunit --colors=always -v --debug
make down

mutation-test:
docker-compose -f tests/docker-compose.yml build --pull php$(v)
docker-compose -f tests/docker-compose.yml run php$(v) php -dpcov.enabled=1 -dpcov.directory=. vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered
make down

coverage:
docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/phpunit --coverage-clover coverage.xml
make down

static-analyze:
docker-compose -f tests/docker-compose.yml run php$(v) vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=$(v)
make down

clean:
docker-compose down
sudo rm -rf tests/runtime/*
sudo rm -f .php_cs.cache
sudo rm -rf composer.lock
sudo rm -rf vendor/

clean-all: clean
sudo rm -rf tests/runtime/.composer*
34 changes: 34 additions & 0 deletions tests/docker-compose.yml
@@ -0,0 +1,34 @@
version: '3.8'

x-php: &php
volumes:
- ./runtime:/app/tests/runtime
- ..:/app

services:
php8.0:
<<: *php
container_name: yii-queue-php80
build:
context: ..
dockerfile: tests/docker/php/Dockerfile
args:
PHP_VERSION: '8.0'

php8.1:
<<: *php
container_name: yii-queue-php81
build:
context: ..
dockerfile: tests/docker/php/Dockerfile
args:
PHP_VERSION: '8.1'

php8.2:
<<: *php
container_name: yii-queue-php82
build:
context: ..
dockerfile: tests/docker/php/Dockerfile
args:
PHP_VERSION: '8.2'
15 changes: 15 additions & 0 deletions tests/docker/php/Dockerfile
@@ -0,0 +1,15 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-fpm-alpine

RUN apk add git autoconf g++ make linux-headers

RUN docker-php-ext-install pcntl
RUN pecl install xdebug pcov
RUN docker-php-ext-enable xdebug pcov

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER 1

WORKDIR /app
ENTRYPOINT ["sh", "tests/docker/php/entrypoint.sh"]
CMD ["sleep", "infinity"]
9 changes: 9 additions & 0 deletions tests/docker/php/entrypoint.sh
@@ -0,0 +1,9 @@
#!/bin/sh

set -eu

flock tests/runtime/composer-install.lock composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

php --version
set -x
exec "$@"

0 comments on commit 1069811

Please sign in to comment.