Test on PHP 7.1 to 8.5 and fix CI #111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - '[0-9]+.x' | |
| jobs: | |
| php: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - PHP_VERSION: '7.1' | |
| RUN_PHPSTAN: 'false' | |
| RUN_PSALM: 'false' | |
| - PHP_VERSION: '7.2' | |
| RUN_PHPSTAN: 'false' | |
| RUN_PSALM: 'false' | |
| - PHP_VERSION: '7.3' | |
| RUN_PHPSTAN: 'false' | |
| RUN_PSALM: 'false' | |
| - PHP_VERSION: '7.4' | |
| RUN_PHPSTAN: 'false' | |
| RUN_PSALM: 'false' | |
| - PHP_VERSION: '8.0' | |
| RUN_PHPSTAN: 'true' | |
| RUN_PSALM: 'true' | |
| #- PHP_VERSION: '8.1' | |
| # RUN_PHPSTAN: 'false' | |
| # RUN_PSALM: 'false' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Cache Docker Image | |
| id: docker-cache-image | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/docker-cache-image.tar | |
| key: docker-cache-image:${{ matrix.PHP_VERSION }} | |
| - name: Load Docker Image | |
| if: steps.docker-cache-image.outputs.cache-hit == 'true' | |
| run: docker load --input /tmp/docker-cache-image.tar | |
| - name: Build Docker Image | |
| if: steps.docker-cache-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 }}' . | |
| - name: Cache Composer Cache Dir | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/composer-cache-dir | |
| key: composer-cache-dir:${{ matrix.PHP_VERSION }} | |
| restore-keys: | | |
| composer-cache-dir: | |
| - name: Install Composer Dependencies | |
| run: | | |
| if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then | |
| docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer remove --dev phpstan/phpstan --no-update --no-interaction | |
| fi | |
| if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then | |
| docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer remove --dev vimeo/psalm --no-update --no-interaction | |
| fi | |
| docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -v '/tmp/composer-cache-dir:/.composer-cache-dir' 'test:${{ matrix.PHP_VERSION }}' composer install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }} | |
| - name: Run Unit Test | |
| run: | | |
| docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" 'test:${{ matrix.PHP_VERSION }}' php -d 'zend.assertions=1' ./vendor/bin/phpunit | |
| - name: Run PHPStan | |
| if: ${{ matrix.RUN_PHPSTAN == 'true' }} | |
| 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 --no-interaction | |
| - name: Run psalm | |
| if: ${{ matrix.RUN_PSALM == 'true' }} | |
| 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 --no-cache | |
| - name: Export Docker Image | |
| if: steps.docker-cache-image.outputs.cache-hit != 'true' | |
| run: docker save --output /tmp/docker-cache-image.tar 'test:${{ matrix.PHP_VERSION }}' |