From 8b9721eb4255567596a7c1e6a2fdcb49b7e283f9 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 08:44:56 +0100 Subject: [PATCH 01/21] Run tests in PHP 8.2, 8.3, 8.4 --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3834e5..3dfad54 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,21 @@ jobs: RUN_PHPSTAN: true RUN_PSALM: true RUN_BENCHMARK: true + - PHP_VERSION: 8.2 + CODE_COVERAGE: false + RUN_PHPSTAN: true + RUN_PSALM: true + RUN_BENCHMARK: false + - PHP_VERSION: 8.3 + CODE_COVERAGE: false + RUN_PHPSTAN: true + RUN_PSALM: true + RUN_BENCHMARK: false + - PHP_VERSION: 8.4 + CODE_COVERAGE: false + RUN_PHPSTAN: true + RUN_PSALM: true + RUN_BENCHMARK: false steps: - uses: actions/checkout@v2 From 0d741612176d07e18679146a2966918e53023197 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 08:53:01 +0100 Subject: [PATCH 02/21] Install pcov only if needed --- .github/workflows/test.Dockerfile | 8 -------- .github/workflows/test.yml | 7 ++++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.Dockerfile b/.github/workflows/test.Dockerfile index a7acaf1..c3cba23 100644 --- a/.github/workflows/test.Dockerfile +++ b/.github/workflows/test.Dockerfile @@ -8,11 +8,3 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local ENV COMPOSER_ALLOW_SUPERUSER=1 ENV COMPOSER_HTACCESS_PROTECT=0 ENV COMPOSER_CACHE_DIR=/.composer - -# install PHP extension pcov -RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ - && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ - && docker-php-ext-install pcov \ - && docker-php-ext-enable pcov \ - && rm -Rf /usr/src/php/ext/pcov \ - && apk del --no-cache .build-deps diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3dfad54..2612774 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,7 +95,12 @@ jobs: - name: Run Unit Test run: | if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then - docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml + docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' \ + apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ + && docker-php-ext-install pcov \ + && docker-php-ext-enable pcov \ + && php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml else docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit fi From b703af142ea3fbe2069024625f804a117b431510 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 08:54:15 +0100 Subject: [PATCH 03/21] fixup --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2612774..2ead25d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,7 +95,7 @@ jobs: - name: Run Unit Test run: | if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then - docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' \ + docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' \ apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ && docker-php-ext-install pcov \ From 420423dbce0ae9c129d6f23ff363c3269de0bfe1 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:06:28 +0100 Subject: [PATCH 04/21] fixup --- .github/workflows/test.Dockerfile | 11 +++++++++++ .github/workflows/test.yml | 21 ++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.Dockerfile b/.github/workflows/test.Dockerfile index c3cba23..43cf94d 100644 --- a/.github/workflows/test.Dockerfile +++ b/.github/workflows/test.Dockerfile @@ -1,4 +1,5 @@ ARG PHP_VERSION=latest +ARG CODE_COVERAGE=false FROM php:${PHP_VERSION}-cli-alpine WORKDIR /workdir @@ -8,3 +9,13 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local ENV COMPOSER_ALLOW_SUPERUSER=1 ENV COMPOSER_HTACCESS_PROTECT=0 ENV COMPOSER_CACHE_DIR=/.composer + +# install PHP extension pcov +RUN if [[ "${CODE_COVERAGE}" == "true" ]] ; \ + then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ + && docker-php-ext-install pcov \ + && docker-php-ext-enable pcov \ + && rm -Rf /usr/src/php/ext/pcov \ + && apk del --no-cache .build-deps + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ead25d..71cdd24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,7 @@ jobs: uses: actions/cache@v2 with: path: /tmp/docker-image.tar - key: cache-docker-image-test:${{ matrix.PHP_VERSION }} + key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }} - name: Load Docker Image if: steps.cache-docker-image.outputs.cache-hit == 'true' @@ -75,13 +75,13 @@ jobs: - name: Build Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' . + run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . - name: Cache Composer Cache Files uses: actions/cache@v2 with: path: /tmp/composer-cache-files - key: cache-composer-cache-files-${{ matrix.PHP_VERSION }} + key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }} restore-keys: | cache-composer-cache-files- @@ -95,12 +95,7 @@ jobs: - name: Run Unit Test run: | if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then - docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' \ - apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ - && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ - && docker-php-ext-install pcov \ - && docker-php-ext-enable pcov \ - && php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml + docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-pcov' php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml else docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit fi @@ -114,16 +109,16 @@ jobs: - name: Run PHPStan if: ${{ matrix.RUN_PHPSTAN }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ - name: Run psalm if: ${{ matrix.RUN_PSALM }} - run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}' php ./vendor/bin/psalm + run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php ./vendor/bin/psalm - name: Run benchmark if: ${{ matrix.RUN_BENCHMARK }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none - name: Export Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}' + run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' From da42b7faae8a55a62dd15f380ba3353aa80b9b4a Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:19:20 +0100 Subject: [PATCH 05/21] use xdebug instead of pcov --- .github/workflows/test.Dockerfile | 6 ++---- .github/workflows/test.yml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.Dockerfile b/.github/workflows/test.Dockerfile index 43cf94d..ca52c84 100644 --- a/.github/workflows/test.Dockerfile +++ b/.github/workflows/test.Dockerfile @@ -13,9 +13,7 @@ ENV COMPOSER_CACHE_DIR=/.composer # install PHP extension pcov RUN if [[ "${CODE_COVERAGE}" == "true" ]] ; \ then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ - && mkdir -p /usr/src/php/ext/pcov && curl -fsSL https://pecl.php.net/get/pcov | tar xvz -C /usr/src/php/ext/pcov --strip 1 \ - && docker-php-ext-install pcov \ - && docker-php-ext-enable pcov \ - && rm -Rf /usr/src/php/ext/pcov \ + && pecl install xdebug \ + && docker-php-ext-enable xdebug \ && apk del --no-cache .build-deps diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71cdd24..36ef699 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,7 @@ jobs: uses: actions/cache@v2 with: path: /tmp/docker-image.tar - key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }} + key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }} - name: Load Docker Image if: steps.cache-docker-image.outputs.cache-hit == 'true' @@ -75,13 +75,13 @@ jobs: - name: Build Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . + run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . - name: Cache Composer Cache Files uses: actions/cache@v2 with: path: /tmp/composer-cache-files - key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }} + key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }} restore-keys: | cache-composer-cache-files- @@ -90,12 +90,12 @@ jobs: if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then composer remove --dev phpstan/phpstan --no-update --no-interaction; fi if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then composer remove --dev vimeo/psalm --no-update --no-interaction; fi if [ "${{ matrix.RUN_BENCHMARK }}" != "true" ]; then composer remove --dev phpbench/phpbench --no-update --no-interaction; fi - docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-files:/.composer' 'test:${{ matrix.PHP_VERSION }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} + docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-files:/.composer' 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} - name: Run Unit Test run: | if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then - docker run --rm -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-pcov' php -d 'zend.assertions=1' -d 'pcov.enabled=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml + docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-xdebug' php -d 'zend.assertions=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml else docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit fi @@ -109,16 +109,16 @@ jobs: - name: Run PHPStan if: ${{ matrix.RUN_PHPSTAN }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ - name: Run psalm if: ${{ matrix.RUN_PSALM }} - run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php ./vendor/bin/psalm + run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php ./vendor/bin/psalm - name: Run benchmark if: ${{ matrix.RUN_BENCHMARK }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none - name: Export Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-pcov' || '' }}' + run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' From 8f7766a1e064b48b6aa53a095dc5b14dec82582c Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:24:35 +0100 Subject: [PATCH 06/21] fixup --- .github/workflows/test.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.Dockerfile b/.github/workflows/test.Dockerfile index ca52c84..3e0aabe 100644 --- a/.github/workflows/test.Dockerfile +++ b/.github/workflows/test.Dockerfile @@ -15,5 +15,6 @@ RUN if [[ "${CODE_COVERAGE}" == "true" ]] ; \ then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ && pecl install xdebug \ && docker-php-ext-enable xdebug \ - && apk del --no-cache .build-deps + && apk del --no-cache .build-deps ; \ + fi From 661401184d5eb327f9f0eb3aa23710b9024442ea Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:29:14 +0100 Subject: [PATCH 07/21] fixup --- .github/workflows/test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36ef699..f8b0ab3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,7 @@ jobs: uses: actions/cache@v2 with: path: /tmp/docker-image.tar - key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }} + key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }} - name: Load Docker Image if: steps.cache-docker-image.outputs.cache-hit == 'true' @@ -75,13 +75,13 @@ jobs: - name: Build Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . + run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . - name: Cache Composer Cache Files uses: actions/cache@v2 with: path: /tmp/composer-cache-files - key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }} + key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }} restore-keys: | cache-composer-cache-files- @@ -90,7 +90,7 @@ jobs: if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then composer remove --dev phpstan/phpstan --no-update --no-interaction; fi if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then composer remove --dev vimeo/psalm --no-update --no-interaction; fi if [ "${{ matrix.RUN_BENCHMARK }}" != "true" ]; then composer remove --dev phpbench/phpbench --no-update --no-interaction; fi - docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-files:/.composer' 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} + docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-files:/.composer' 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} - name: Run Unit Test run: | @@ -109,16 +109,16 @@ jobs: - name: Run PHPStan if: ${{ matrix.RUN_PHPSTAN }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' php -d 'memory_limit=2G' ./vendor/bin/phpstan analyse --level max src/ tests/ - name: Run psalm if: ${{ matrix.RUN_PSALM }} - run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php ./vendor/bin/psalm + run: mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v "$HOME/.cache/psalm:/.cache/psalm" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' php ./vendor/bin/psalm - name: Run benchmark if: ${{ matrix.RUN_BENCHMARK }} - run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none + run: docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=none - name: Export Docker Image if: steps.cache-docker-image.outputs.cache-hit != 'true' - run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE == 'true' && '-xdebug' || '' }}' + run: docker save --output /tmp/docker-image.tar 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' From 8e434dbd02d12162a2c2fb222b36fed9fd9dd62d Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:33:54 +0100 Subject: [PATCH 08/21] fix implicitly nullable via default value null --- src/EnumMap.php | 2 +- src/EnumSet.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnumMap.php b/src/EnumMap.php index 9aa1b24..eae61ba 100644 --- a/src/EnumMap.php +++ b/src/EnumMap.php @@ -42,7 +42,7 @@ class EnumMap implements ArrayAccess, Countable, IteratorAggregate * @param null|iterable, mixed> $map Initialize map * @throws InvalidArgumentException */ - public function __construct(string $enumeration, iterable $map = null) + public function __construct(string $enumeration, ?iterable $map = null) { if (!\is_subclass_of($enumeration, Enum::class)) { throw new InvalidArgumentException(\sprintf( diff --git a/src/EnumSet.php b/src/EnumSet.php index be3cd07..42e34b3 100644 --- a/src/EnumSet.php +++ b/src/EnumSet.php @@ -86,7 +86,7 @@ class EnumSet implements IteratorAggregate, Countable * @param iterable>|null $enumerators iterable list of enumerators initializing the set * @throws InvalidArgumentException */ - public function __construct(string $enumeration, iterable $enumerators = null) + public function __construct(string $enumeration, ?iterable $enumerators = null) { if (!\is_subclass_of($enumeration, Enum::class)) { throw new InvalidArgumentException(\sprintf( From 45f59443f73e5dbd143ebc3936b49c56931f7f7b Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:44:58 +0100 Subject: [PATCH 09/21] PHPStan rm ignoreError "Access to an undefined static property $instances" --- phpstan.neon.dist | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index bd87684..65e3f03 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,8 +7,6 @@ parameters: # EnumSerializableTrait - message: '#Access to private property \$[a-z]+ of parent class MabeEnum\\Enum#' path: %currentWorkingDirectory%/src/EnumSerializableTrait.php - - message: '#Access to an undefined static property MabeEnumTest\\TestAsset\\SerializableEnum::\$instances#' - path: %currentWorkingDirectory%/src/EnumSerializableTrait.php # Tests - message: '#Parameter \#\d \$[a-z]* of static method MabeEnum\\Enum::[^ ]* expects [^ ]*, .+ given#' From 92bd1e1933c4eb40174fcb30b8d86821032dbc8b Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:51:05 +0100 Subject: [PATCH 10/21] PHPStan "Access to private static property $instances" --- phpstan.neon.dist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 65e3f03..291742f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,6 +7,8 @@ parameters: # EnumSerializableTrait - message: '#Access to private property \$[a-z]+ of parent class MabeEnum\\Enum#' path: %currentWorkingDirectory%/src/EnumSerializableTrait.php + - message: '#Access to private static property \$instances#' + path: %currentWorkingDirectory%/src/EnumSerializableTrait.php # Tests - message: '#Parameter \#\d \$[a-z]* of static method MabeEnum\\Enum::[^ ]* expects [^ ]*, .+ given#' From d1233256ccfdaa70be35dd2f79cf99e6826518fc Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 09:59:27 +0100 Subject: [PATCH 11/21] Disable psalm --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8b0ab3..e3f13d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,32 +31,32 @@ jobs: - PHP_VERSION: 7.4 CODE_COVERAGE: true RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: 8.0 CODE_COVERAGE: true RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: 8.1 CODE_COVERAGE: true RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: true - PHP_VERSION: 8.2 CODE_COVERAGE: false RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: 8.3 CODE_COVERAGE: false RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: 8.4 CODE_COVERAGE: false RUN_PHPSTAN: true - RUN_PSALM: true + RUN_PSALM: false RUN_BENCHMARK: false steps: From 8e94a02c7b648e624dc59bda9311ab6a136d6a2e Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 10:08:55 +0100 Subject: [PATCH 12/21] fixup --- .github/workflows/test.Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.Dockerfile b/.github/workflows/test.Dockerfile index 3e0aabe..f89f0cd 100644 --- a/.github/workflows/test.Dockerfile +++ b/.github/workflows/test.Dockerfile @@ -1,6 +1,7 @@ ARG PHP_VERSION=latest ARG CODE_COVERAGE=false FROM php:${PHP_VERSION}-cli-alpine +ARG CODE_COVERAGE WORKDIR /workdir @@ -12,7 +13,7 @@ ENV COMPOSER_CACHE_DIR=/.composer # install PHP extension pcov RUN if [[ "${CODE_COVERAGE}" == "true" ]] ; \ - then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + then apk add --no-cache --virtual .build-deps $PHPIZE_DEPS linux-headers \ && pecl install xdebug \ && docker-php-ext-enable xdebug \ && apk del --no-cache .build-deps ; \ From c255bf1b59f0e7d03f5df12ee6ce8aafb32f383f Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 12:30:29 +0100 Subject: [PATCH 13/21] PHP version is a string --- .github/workflows/test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3f13d5..a8668cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,47 +13,47 @@ jobs: strategy: matrix: include: - - PHP_VERSION: 7.1 + - PHP_VERSION: "7.1" CODE_COVERAGE: false RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 7.2 + - PHP_VERSION: "7.2" CODE_COVERAGE: true RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: true - - PHP_VERSION: 7.3 + - PHP_VERSION: "7.3" CODE_COVERAGE: true RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 7.4 + - PHP_VERSION: "7.4" CODE_COVERAGE: true RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 8.0 + - PHP_VERSION: "8.0" CODE_COVERAGE: true RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 8.1 + - PHP_VERSION: "8.1" CODE_COVERAGE: true RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: true - - PHP_VERSION: 8.2 + - PHP_VERSION: "8.2" CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 8.3 + - PHP_VERSION: "8.3" CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - - PHP_VERSION: 8.4 + - PHP_VERSION: "8.4" CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false From 1fde2992dfa0340fefeb353d2068c407dcf0dfb6 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 12:32:04 +0100 Subject: [PATCH 14/21] Disable code coverage --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8668cc..22ff579 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,27 +19,27 @@ jobs: RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "7.2" - CODE_COVERAGE: true + CODE_COVERAGE: false RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: true - PHP_VERSION: "7.3" - CODE_COVERAGE: true + CODE_COVERAGE: false RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "7.4" - CODE_COVERAGE: true + CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "8.0" - CODE_COVERAGE: true + CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "8.1" - CODE_COVERAGE: true + CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: true From 41bf03062761b9924acc4d71a8f73f09c182ddf9 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 13:05:03 +0100 Subject: [PATCH 15/21] Code coverage on 8.3 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22ff579..fd94bf2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,7 @@ jobs: RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "8.3" - CODE_COVERAGE: false + CODE_COVERAGE: true RUN_PHPSTAN: true RUN_PSALM: false RUN_BENCHMARK: false From 81e1587c909ae874e606ceb9d7142b81931d46ee Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 13:08:32 +0100 Subject: [PATCH 16/21] fixed "Calling ReflectionProperty::setValue() with a single argument is deprecated" --- tests/MabeEnumTest/EnumSerializableTraitTest.php | 2 +- tests/MabeEnumTest/EnumTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MabeEnumTest/EnumSerializableTraitTest.php b/tests/MabeEnumTest/EnumSerializableTraitTest.php index 17da462..5694a3c 100644 --- a/tests/MabeEnumTest/EnumSerializableTraitTest.php +++ b/tests/MabeEnumTest/EnumSerializableTraitTest.php @@ -108,7 +108,7 @@ private function clearEnumeration($enumeration): void } foreach ($reflClass->getProperties(ReflectionProperty::IS_STATIC) as $reflProp) { - $reflProp->setAccessible(true);; + $reflProp->setAccessible(true); $reflProp->setValue(null, []); } } diff --git a/tests/MabeEnumTest/EnumTest.php b/tests/MabeEnumTest/EnumTest.php index 1d04271..5156fde 100644 --- a/tests/MabeEnumTest/EnumTest.php +++ b/tests/MabeEnumTest/EnumTest.php @@ -40,7 +40,7 @@ private function resetStaticEnumProps(): void $enumPropsRefl = $enumRefl->getProperties(ReflectionProperty::IS_STATIC); foreach ($enumPropsRefl as $enumPropRefl) { $enumPropRefl->setAccessible(true); - $enumPropRefl->setValue([]); + $enumPropRefl->setValue(null, []); } } From 62ce31f0267d1dd1d2fd5ea3b31f4aa15c23689b Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 13:10:45 +0100 Subject: [PATCH 17/21] xdebug.mode=coverage --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd94bf2..b522b3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,7 +95,7 @@ jobs: - name: Run Unit Test run: | if [ "${{ matrix.CODE_COVERAGE }}" == "true" ]; then - docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-xdebug' php -d 'zend.assertions=1' ./vendor/bin/phpunit --coverage-clover=.clover.xml + docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}-xdebug' php -d 'zend.assertions=1' -d 'xdebug.mode=coverage' ./vendor/bin/phpunit --coverage-clover=.clover.xml else docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit fi From 52a11ce6f6e1e0fa2f0e71253b361cb557155b3c Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 13:20:04 +0100 Subject: [PATCH 18/21] benchmark PHP version --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b522b3f..19f24d7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,12 +42,12 @@ jobs: CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false - RUN_BENCHMARK: true + RUN_BENCHMARK: false - PHP_VERSION: "8.2" CODE_COVERAGE: false RUN_PHPSTAN: true RUN_PSALM: false - RUN_BENCHMARK: false + RUN_BENCHMARK: true - PHP_VERSION: "8.3" CODE_COVERAGE: true RUN_PHPSTAN: true @@ -81,7 +81,7 @@ jobs: uses: actions/cache@v2 with: path: /tmp/composer-cache-files - key: cache-composer-cache-files-${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }} + key: cache-composer-cache-files-${{ matrix.PHP_VERSION }} restore-keys: | cache-composer-cache-files- From 2e300bf013fed1202ffd98903c93b7d2a1f1f98e Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 14:50:44 +0100 Subject: [PATCH 19/21] Bump actions/cache from @2 to @4 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19f24d7..8adbb79 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,7 +64,7 @@ jobs: - name: Cache Docker Image id: cache-docker-image - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/docker-image.tar key: cache-docker-image-test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }} @@ -78,7 +78,7 @@ jobs: run: docker build -f .github/workflows/test.Dockerfile -t 'test:${{ matrix.PHP_VERSION }}${{ matrix.CODE_COVERAGE && '-xdebug' || '' }}' --build-arg 'PHP_VERSION=${{ matrix.PHP_VERSION }}' --build-arg 'CODE_COVERAGE=${{ matrix.CODE_COVERAGE }}' . - name: Cache Composer Cache Files - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/composer-cache-files key: cache-composer-cache-files-${{ matrix.PHP_VERSION }} From 5a1fb042cb2e430015fbf3c6d7a20aefccac06a0 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 14:52:03 +0100 Subject: [PATCH 20/21] Bump actions/checkout from @2 to @4 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8adbb79..fb3b43f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,7 +60,7 @@ jobs: RUN_BENCHMARK: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache Docker Image id: cache-docker-image From 03a4a882d4b818778c0bad91abdf0fc065e657bf Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Tue, 26 Nov 2024 14:55:27 +0100 Subject: [PATCH 21/21] Test Psaml --- .github/workflows/test.yml | 8 ++++---- composer.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb3b43f..c6b4a1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,18 +40,18 @@ jobs: RUN_BENCHMARK: false - PHP_VERSION: "8.1" CODE_COVERAGE: false - RUN_PHPSTAN: true + RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: false - PHP_VERSION: "8.2" CODE_COVERAGE: false - RUN_PHPSTAN: true + RUN_PHPSTAN: false RUN_PSALM: false RUN_BENCHMARK: true - PHP_VERSION: "8.3" CODE_COVERAGE: true - RUN_PHPSTAN: true - RUN_PSALM: false + RUN_PHPSTAN: false + RUN_PSALM: true RUN_BENCHMARK: false - PHP_VERSION: "8.4" CODE_COVERAGE: false diff --git a/composer.json b/composer.json index 5749337..2ae8e4b 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "phpbench/phpbench": "^0.16.10 || ^1.0.4", "phpstan/phpstan": "^1.3.1", "phpunit/phpunit": "^7.5.20 | ^8.5.22 | ^9.5.11", - "vimeo/psalm": "^4.17.0" + "vimeo/psalm": "^4.17.0 | ^5.26.1" }, "autoload": { "psr-4": {