11name : Test
22
3- on : [push, pull_request]
3+ on :
4+ pull_request :
5+ push :
6+ branches :
7+ - master
8+ - ' [0-9]+.x'
49
510jobs :
611 php :
@@ -12,36 +17,63 @@ jobs:
1217 - PHP_VERSION : 7.2
1318 - PHP_VERSION : 7.3
1419 - PHP_VERSION : 7.4
20+ RUN_PHPSTAN : true
21+ RUN_PSALM : true
1522 RUN_BENCHMARK : true
1623 - PHP_VERSION : 8.0-rc
24+ RUN_PHPSTAN : true
25+ RUN_PSALM : true
1726 RUN_BENCHMARK : true
1827 COMPOSER_EXTRA_ARGS : --ignore-platform-reqs
1928 env :
2029 PHP_IMAGE : php:${{ matrix.PHP_VERSION }}-cli-alpine
2130 steps :
2231 - uses : actions/checkout@v2
2332
24- - name : Cache composer install
33+ - name : Cache Composer Phar
34+ id : cache-composer-phar
2535 uses : actions/cache@v2
2636 with :
2737 path : composer.phar
28- key : composer. phar
38+ key : cache- composer- phar
2939
30- - name : Install composer
40+ - name : Install Composer
41+ if : steps.cache-composer-phar.outputs.cache-hit != 'true'
3142 run : curl -sS https://getcomposer.org/installer | php -- --install-dir=. --filename=composer.phar
3243
33- - name : Install dependencies
34- run : docker run --rm -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php ./composer.phar install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }}
44+ - name : Get Composer Setup
45+ id : composer-setup
46+ run : |
47+ echo "::set-output name=version::$(composer --version)"
48+ echo "::set-output name=cache-files-dir::$(composer config cache-files-dir)"
3549
36- - name : Run unit test
37- run : docker run --rm -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php -d 'zend.assertions=1' ./vendor/bin/phpunit
50+ - name : Cache Composer Cache Files
51+ uses : actions/cache@v2
52+ with :
53+ path : ${{ steps.composer-setup.outputs.cache-files-dir }}
54+ key : cache-composer-cache-files-dir-${{ steps.composer-setup.outputs.version }}-${{ matrix.PHP_VERSION }}
55+ restore-keys : |
56+ cache-composer-cache-files-dir-${{ steps.composer-setup.outputs.version }}-
57+ cache-composer-cache-files-dir-
58+
59+ - name : Install Composer Dependencies
60+ run : |
61+ if [ "${{ matrix.RUN_PHPSTAN }}" != "true" ]; then ./composer.phar remove --dev phpstan/phpstan --no-update --no-interaction; fi
62+ if [ "${{ matrix.RUN_PSALM }}" != "true" ]; then ./composer.phar remove --dev vimeo/psalm --no-update --no-interaction; fi
63+ if [ "${{ matrix.RUN_BENCHMARK }}" != "true" ]; then ./composer.phar remove --dev phpbench/phpbench --no-update --no-interaction; fi
64+ docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -w '/workdir' -v '${{ steps.composer-setup.outputs.cache-files-dir }}:/.composer' -e 'COMPOSER_CACHE_DIR=/.composer' $PHP_IMAGE php ./composer.phar install --no-interaction --no-progress --prefer-dist ${{ matrix.COMPOSER_EXTRA_ARGS }}
65+
66+ - name : Run Unit Test
67+ run : docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php -d 'zend.assertions=1' ./vendor/bin/phpunit
3868
3969 - name : Run PHPStan
40- run : docker run --rm -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php ./vendor/bin/phpstan analyse --level max src/ tests/
70+ if : ${{ matrix.RUN_PHPSTAN }}
71+ run : docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php ./vendor/bin/phpstan analyse --level max src/ tests/
4172
4273 - name : Run psalm
43- run : docker run --rm -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php ./vendor/bin/psalm
74+ if : ${{ matrix.RUN_PSALM }}
75+ run : mkdir -p "$HOME/.cache/psalm" && docker run --rm -u "$(id -u):$(id -g)" -v "$(pwd):/workdir" -w '/workdir' -v "$HOME/.cache/psalm:/.cache/psalm" $PHP_IMAGE php ./vendor/bin/psalm
4476
4577 - name : Run benchmark
4678 if : ${{ matrix.RUN_BENCHMARK }}
47- run : docker run --rm -v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=travis
79+ run : docker run --rm -u "$(id -u):$(id -g)" - v "$(pwd):/workdir" -w '/workdir' $PHP_IMAGE php -d 'zend.assertions=-1' ./vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 --progress=travis
0 commit comments