-
Notifications
You must be signed in to change notification settings - Fork 36
124 lines (110 loc) · 5.15 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Test
on:
pull_request:
push:
branches:
- master
- '[0-9]+.x'
jobs:
php:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- PHP_VERSION: 7.1
CODE_COVERAGE: false
RUN_PHPSTAN: false
RUN_PSALM: false
RUN_BENCHMARK: false
- PHP_VERSION: 7.2
CODE_COVERAGE: true
RUN_PHPSTAN: false
RUN_PSALM: false
RUN_BENCHMARK: true
- PHP_VERSION: 7.3
CODE_COVERAGE: true
RUN_PHPSTAN: false
RUN_PSALM: false
RUN_BENCHMARK: false
- PHP_VERSION: 7.4
CODE_COVERAGE: true
RUN_PHPSTAN: true
RUN_PSALM: true
RUN_BENCHMARK: false
- PHP_VERSION: 8.0
CODE_COVERAGE: true
RUN_PHPSTAN: true
RUN_PSALM: true
RUN_BENCHMARK: false
- PHP_VERSION: 8.1
CODE_COVERAGE: true
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
- name: Cache Docker Image
id: cache-docker-image
uses: actions/cache@v2
with:
path: /tmp/docker-image.tar
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'
run: docker load --input /tmp/docker-image.tar
- 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 && '-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 && '-xdebug' || '' }}
restore-keys: |
cache-composer-cache-files-
- name: Install Composer Dependencies
run: |
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 && '-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 -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
- name: Upload Codecov Report
uses: codecov/codecov-action@v1
if: ${{ matrix.CODE_COVERAGE }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .clover.xml
- 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 && '-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 && '-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 && '-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 && '-xdebug' || '' }}'