1+ ---
2+
13name : CI
24
3- on :
5+ on : # yamllint disable-line rule:truthy
46 push :
5- branches : [ '**' ]
7+ branches : ['**']
68 paths-ignore :
79 - ' **.md'
810 pull_request :
9- branches : [ master, release-* ]
11+ branches : [master, release-*]
1012 paths-ignore :
1113 - ' **.md'
1214 workflow_dispatch
1315
1416jobs :
15- basic-tests :
16- name : Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}
17- runs-on : ${{ matrix.operating-system }}
18- strategy :
19- fail-fast : false
20- matrix :
21- operating-system : [ubuntu-latest, windows-latest]
22- php-versions : ['7.4', '8.0', '8.1', '8.2']
17+ linter :
18+ name : Linter
19+ runs-on : ['ubuntu-latest']
20+
21+ steps :
22+ - uses : actions/checkout@v3
23+ with :
24+ fetch-depth : 0
25+
26+ - name : Lint Code Base
27+ uses : github/super-linter/slim@v5
28+ env :
29+ LOG_LEVEL : NOTICE
30+ VALIDATE_ALL_CODEBASE : true
31+ LINTER_RULES_PATH : ' tools/linters'
32+ VALIDATE_CSS : true
33+ VALIDATE_JAVASCRIPT_ES : true
34+ VALIDATE_JSON : true
35+ VALIDATE_PHP_BUILTIN : true
36+ VALIDATE_YAML : true
37+ VALIDATE_XML : true
38+ VALIDATE_GITHUB_ACTIONS : true
39+
40+ quality :
41+ name : Quality control
42+ runs-on : [ubuntu-latest]
2343
2444 steps :
2545 - name : Setup PHP, with composer and extensions
26- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
46+ id : setup-php
47+ # https://github.com/shivammathur/setup-php
48+ uses : shivammathur/setup-php@v2
2749 with :
28- coverage : pcov
29- extensions : intl, ldap, mbstring, xml
30- ini-values : error_reporting=E_ALL
31- php-version : ${{ matrix.php-versions }}
32- tools : composer:v2
50+ # Should be the higest supported version, so we can use the newest tools
51+ php-version : ' 8.2 '
52+ tools : composer, composer-require-checker, composer-unused, phpcs, psalm
53+ # optional performance gain for psalm: opcache
54+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
3355
3456 - name : Setup problem matchers for PHP
3557 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3658
37- - name : Setup problem matchers for PHPUnit
38- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
39-
40- - name : Set git to use LF
41- run : |
42- git config --global core.autocrlf false
43- git config --global core.eol lf
44-
4559 - uses : actions/checkout@v3
4660
47- - name : Get composer cache directory (linux)
48- if : ${{ matrix.operating-system == 'ubuntu-latest' }}
49- run : echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $GITHUB_ENV
50-
51- - name : Get composer cache directory (windows)
52- if : ${{ matrix.operating-system == 'windows-latest' }}
53- run : echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $env:GITHUB_ENV
61+ - name : Get composer cache directory
62+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
5463
5564 - name : Cache composer dependencies
5665 uses : actions/cache@v3
@@ -63,51 +72,67 @@ jobs:
6372 run : composer validate
6473
6574 - name : Install Composer dependencies
66- run : composer install --prefer-dist --optimize-autoloader --ignore-platform-req ext-krb5
75+ run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req ext-krb5
76+
77+ - name : Check code for hard dependencies missing in composer.json
78+ run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
6779
68- - name : Syntax check PHP
69- run : bash vendor/bin/check-syntax-php.sh
80+ - name : Check code for unused dependencies in composer.json
81+ run : composer-unused
7082
71- - name : Decide whether to run code coverage or not
72- if : ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }}
83+ - name : PHP Code Sniffer
84+ run : phpcs
85+
86+ - name : Psalm
87+ continue-on-error : true
7388 run : |
74- echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
89+ psalm -c psalm.xml \
90+ --show-info=true \
91+ --shepherd \
92+ --php-version=${{ steps.setup-php.outputs.php-version }}
7593
76- - name : Run unit tests
94+ - name : Psalm (testsuite)
7795 run : |
78- echo $NO_COVERAGE
79- ./vendor/bin/phpunit $NO_COVERAGE
96+ psalm -c psalm-dev.xml \
97+ --show-info=true \
98+ --shepherd \
99+ --php-version=${{ steps.setup-php.outputs.php-version }}
80100
81- - name : Save coverage data
82- if : ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
83- uses : actions/upload-artifact@v3
84- with :
85- name : build-data
86- path : ${{ github.workspace }}/build
101+ - name : Psalter
102+ run : |
103+ psalm --alter \
104+ --issues=UnnecessaryVarAnnotation \
105+ --dry-run \
106+ --php-version= ${{ steps.setup-php.outputs.php-version }}
87107
88108 security :
89109 name : Security checks
90110 runs-on : [ubuntu-latest]
91111 steps :
92112 - name : Setup PHP, with composer and extensions
93- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
113+ # https://github.com/shivammathur/setup-php
114+ uses : shivammathur/setup-php@v2
94115 with :
95- php-version : ' 7.4'
96- tools : composer:v2
97- extensions : ldap, mbstring, xml
98- coverage : none
116+ # Should be the lowest supported version
117+ php-version : ' 8.0'
118+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
119+ tools : composer
120+ coverage : none
99121
100122 - name : Setup problem matchers for PHP
101123 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
102124
103125 - uses : actions/checkout@v3
104126
127+ - name : Get composer cache directory
128+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
129+
105130 - name : Cache composer dependencies
106131 uses : actions/cache@v3
107132 with :
108- path : $COMPOSER_CACHE
109- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
110- restore-keys : ${{ runner.os }}-composer-
133+ path : $COMPOSER_CACHE
134+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
135+ restore-keys : ${{ runner.os }}-composer-
111136
112137 - name : Install Composer dependencies
113138 run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req ext-krb5
@@ -121,85 +146,147 @@ jobs:
121146 - name : Security check for updated dependencies
122147 run : composer audit
123148
124- sanity-check :
125- name : Sanity checks
126- runs-on : [ubuntu-latest]
149+ unit-tests-linux :
150+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
151+ runs-on : ${{ matrix.operating-system }}
152+ needs : [linter, quality, security]
153+ strategy :
154+ fail-fast : false
155+ matrix :
156+ operating-system : [ubuntu-latest]
157+ php-versions : ['8.0', '8.1', '8.2']
127158
128159 steps :
129160 - name : Setup PHP, with composer and extensions
130- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
161+ # https://github.com/shivammathur/setup-php
162+ uses : shivammathur/setup-php@v2
131163 with :
132- php-version : ' 7.4'
133- tools : composer:v2
134- extensions : ldap, mbstring, xml
135- coverage : none
164+ php-version : ${{ matrix.php-versions }}
165+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
166+ tools : composer
167+ ini-values : error_reporting=E_ALL
168+ coverage : pcov
136169
137170 - name : Setup problem matchers for PHP
138171 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
139172
173+ - name : Setup problem matchers for PHPUnit
174+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
175+
176+ - name : Set git to use LF
177+ run : |
178+ git config --global core.autocrlf false
179+ git config --global core.eol lf
180+
140181 - uses : actions/checkout@v3
141182
183+ - name : Get composer cache directory
184+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
185+
142186 - name : Cache composer dependencies
143187 uses : actions/cache@v3
144188 with :
145- path : $COMPOSER_CACHE
146- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
147- restore-keys : ${{ runner.os }}-composer-
189+ path : $COMPOSER_CACHE
190+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
191+ restore-keys : ${{ runner.os }}-composer-
148192
149193 - name : Install Composer dependencies
150194 run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req ext-krb5
151195
152- - name : Syntax check YAML / XML / JSON
153- run : |
154- bash vendor/bin/check-syntax-yaml.sh
155- bash vendor/bin/check-syntax-xml.sh
156- bash vendor/bin/check-syntax-json.sh
196+ - name : Run unit tests with coverage
197+ if : ${{ matrix.php-versions == '8.2' }}
198+ run : vendor/bin/phpunit
157199
158- quality :
159- name : Quality control
160- runs-on : [ubuntu-latest]
161- needs : [basic-tests]
200+ - name : Run unit tests (no coverage)
201+ if : ${{ matrix.php-versions != '8.2' }}
202+ run : vendor/bin/phpunit --no-coverage
203+
204+ - name : Save coverage data
205+ if : ${{ matrix.php-versions == '8.2' }}
206+ uses : actions/upload-artifact@v3
207+ with :
208+ name : coverage-data
209+ path : ${{ github.workspace }}/build
210+
211+ unit-tests-windows :
212+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
213+ runs-on : ${{ matrix.operating-system }}
214+ needs : [linter, quality, security]
215+ strategy :
216+ fail-fast : true
217+ matrix :
218+ operating-system : [windows-latest]
219+ php-versions : ['8.0', '8.1', '8.2']
162220
163221 steps :
164222 - name : Setup PHP, with composer and extensions
165- id : setup-php
166- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
223+ # https://github.com/shivammathur/ setup-php
224+ uses : shivammathur/setup-php@v2
167225 with :
168- php-version : ' 7.4'
169- tools : composer:v2
170- extensions : ldap, mbstring, xml
226+ php-version : ${{ matrix.php-versions }}
227+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
228+ tools : composer
229+ ini-values : error_reporting=E_ALL
230+ coverage : none
171231
172232 - name : Setup problem matchers for PHP
173233 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
174234
235+ - name : Setup problem matchers for PHPUnit
236+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
237+
238+ - name : Set git to use LF
239+ run : |
240+ git config --global core.autocrlf false
241+ git config --global core.eol lf
242+
175243 - uses : actions/checkout@v3
176244
245+ - name : Get composer cache directory
246+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
247+
177248 - name : Cache composer dependencies
178249 uses : actions/cache@v3
179250 with :
180- path : $COMPOSER_CACHE
181- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
182- restore-keys : ${{ runner.os }}-composer-
251+ path : $COMPOSER_CACHE
252+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
253+ restore-keys : ${{ runner.os }}-composer-
183254
184255 - name : Install Composer dependencies
185256 run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req ext-krb5
186257
258+ - name : Run unit tests
259+ run : vendor/bin/phpunit --no-coverage
260+
261+ coverage :
262+ name : Code coverage
263+ runs-on : [ubuntu-latest]
264+ needs : [unit-tests-linux]
265+ steps :
266+ - uses : actions/checkout@v3
267+
187268 - uses : actions/download-artifact@v3
188269 with :
189- name : build -data
270+ name : coverage -data
190271 path : ${{ github.workspace }}/build
191272
192273 - name : Codecov
193274 uses : codecov/codecov-action@v3
275+ with :
276+ token : ${{ secrets.CODECOV_TOKEN }}
277+ fail_ci_if_error : true
278+ verbose : true
194279
195- - name : PHP Code Sniffer
196- continue-on-error : true
197- run : php vendor/bin/phpcs
198-
199- - name : Psalm
200- continue-on-error : true
201- run : php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
280+ cleanup :
281+ name : Cleanup artifacts
282+ needs : [unit-tests-linux, coverage]
283+ runs-on : [ubuntu-latest]
284+ if : |
285+ always() &&
286+ needs.coverage.result == 'success' &&
287+ (needs.unit-tests-linux == 'success' || needs.coverage == 'skipped')
202288
203- - name : Psalter
204- continue-on-error : true
205- run : php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}
289+ steps :
290+ - uses : geekyeggo/delete-artifact@v2
291+ with :
292+ name : coverage-data
0 commit comments