@@ -14,50 +14,62 @@ on: # yamllint disable-line rule:truthy
1414 workflow_dispatch :
1515
1616jobs :
17+ phplinter :
18+ name : ' PHP-Linter'
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ php-version : ['8.1', '8.2', '8.3', '8.4']
23+
24+ uses :
simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected] 25+ with :
26+ php-version : ${{ matrix.php-version }}
27+
1728 linter :
18- name : Linter
19- runs-on : ['ubuntu-latest']
29+ name : ' Linter'
30+ strategy :
31+ fail-fast : false
2032
21- steps :
22- - uses : actions/checkout@v4
23- with :
24- fetch-depth : 0
25-
26- - name : Lint Code Base
27- uses : super-linter/super-linter/slim@v7
28- env :
29- SAVE_SUPER_LINTER_OUTPUT : false
30- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31- LINTER_RULES_PATH : ' tools/linters'
32- LOG_LEVEL : NOTICE
33- VALIDATE_ALL_CODEBASE : true
34- VALIDATE_CSS : true
35- VALIDATE_JAVASCRIPT_ES : true
36- VALIDATE_JSON : true
37- VALIDATE_PHP_BUILTIN : true
38- VALIDATE_YAML : true
39- VALIDATE_XML : true
40- VALIDATE_GITHUB_ACTIONS : true
33+ uses :
simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected] 34+ with :
35+ enable_eslinter : false
36+ enable_jsonlinter : true
37+ enable_stylelinter : true
38+ enable_yamllinter : true
4139
42- quality :
43- name : Quality control
44- runs-on : [ubuntu-latest]
40+ unit-tests-linux :
41+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
42+ runs-on : ${{ matrix.operating-system }}
43+ needs : [phplinter, linter]
44+
45+ strategy :
46+ fail-fast : false
47+ matrix :
48+ operating-system : [ubuntu-latest]
49+ php-versions : ['8.1', '8.2', '8.3', '8.4']
4550
4651 steps :
4752 - name : Setup PHP, with composer and extensions
48- id : setup-php
4953 # https://github.com/shivammathur/setup-php
5054 uses : shivammathur/setup-php@v2
5155 with :
52- # Should be the higest supported version, so we can use the newest tools
53- php-version : ' 8.3 '
54- tools : composer, composer-require-checker, composer-unused, phpcs, psalm
55- # optional performance gain for psalm: opcache
56- extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
56+ php- version: ${{ matrix.php-versions }}
57+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
58+ tools : composer
59+ ini-values : error_reporting=E_ALL
60+ coverage : pcov
5761
5862 - name : Setup problem matchers for PHP
5963 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6064
65+ - name : Setup problem matchers for PHPUnit
66+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
67+
68+ - name : Set git to use LF
69+ run : |
70+ git config --global core.autocrlf false
71+ git config --global core.eol lf
72+
6173 - uses : actions/checkout@v4
6274
6375 - name : Get composer cache directory
@@ -70,64 +82,61 @@ jobs:
7082 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7183 restore-keys : ${{ runner.os }}-composer-
7284
73- - name : Validate composer.json and composer.lock
74- run : composer validate
75-
7685 - name : Install Composer dependencies
7786 run : composer install --no-progress --prefer-dist --optimize-autoloader
7887
79- - name : Check code for hard dependencies missing in composer.json
80- run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
81-
82- - name : Check code for unused dependencies in composer.json
83- run : composer-unused
88+ - name : Run unit tests with coverage
89+ if : ${{ matrix.php-versions == '8.4' }}
90+ run : vendor/bin/phpunit
8491
85- - name : PHP Code Sniffer
86- run : phpcs
92+ - name : Run unit tests (no coverage)
93+ if : ${{ matrix.php-versions != '8.4' }}
94+ run : vendor/bin/phpunit --no-coverage
8795
88- - name : Psalm
89- continue-on-error : true
90- run : |
91- psalm -c psalm.xml \
92- --show-info=true \
93- --shepherd \
94- --php-version=${{ steps.setup-php.outputs.php-version }}
96+ - name : Save coverage data
97+ if : ${{ matrix.php-versions == '8.4' }}
98+ uses : actions/upload-artifact@v4
99+ with :
100+ name : coverage-data
101+ path : ${{ github.workspace }}/build
95102
96- - name : Psalm (testsuite)
97- run : |
98- psalm -c psalm-dev.xml \
99- --show-info=true \
100- --shepherd \
101- --php-version=${{ steps.setup-php.outputs.php-version }}
103+ unit-tests-windows :
104+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
105+ runs-on : ${{ matrix.operating-system }}
106+ needs : [phplinter, linter]
102107
103- - name : Psalter
104- run : |
105- psalm --alter \
106- --issues=UnnecessaryVarAnnotation \
107- --dry-run \
108- --php-version=${{ steps.setup-php.outputs.php-version }}
108+ strategy :
109+ fail-fast : true
110+ matrix :
111+ operating-system : [windows-latest]
112+ php-versions : ['8.1', '8.2', '8.3', '8.4']
109113
110- security :
111- name : Security checks
112- runs-on : [ubuntu-latest]
113114 steps :
114115 - name : Setup PHP, with composer and extensions
115116 # https://github.com/shivammathur/setup-php
116117 uses : shivammathur/setup-php@v2
117118 with :
118- # Should be the lowest supported version
119- php-version : ' 8.1'
119+ php-version : ${{ matrix.php-versions }}
120120 extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
121121 tools : composer
122+ ini-values : error_reporting=E_ALL
122123 coverage : none
123124
124125 - name : Setup problem matchers for PHP
125126 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
126127
128+ - name : Setup problem matchers for PHPUnit
129+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
130+
131+ - name : Set git to use LF
132+ run : |
133+ git config --global core.autocrlf false
134+ git config --global core.eol lf
135+
127136 - uses : actions/checkout@v4
128137
129138 - name : Get composer cache directory
130- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
139+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
131140
132141 - name : Cache composer dependencies
133142 uses : actions/cache@v4
@@ -137,49 +146,31 @@ jobs:
137146 restore-keys : ${{ runner.os }}-composer-
138147
139148 - name : Install Composer dependencies
140- run : composer install --no-progress --prefer-dist --optimize-autoloader
141-
142- - name : Security check for locked dependencies
143- run : composer audit
144-
145- - name : Update Composer dependencies
146- run : composer update --no-progress --prefer-dist --optimize-autoloader
149+ run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
147150
148- - name : Security check for updated dependencies
149- run : composer audit
151+ - name : Run unit tests
152+ run : vendor/bin/phpunit --no-coverage
150153
151- unit-tests-linux :
152- name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
153- runs-on : ${{ matrix.operating-system }}
154- needs : [linter, quality, security]
155- strategy :
156- fail-fast : false
157- matrix :
158- operating-system : [ubuntu-latest]
159- php-versions : ['8.1', '8.2', '8.3']
154+ quality :
155+ name : Quality control
156+ runs-on : [ubuntu-latest]
157+ needs : [unit-tests-linux]
160158
161159 steps :
162160 - name : Setup PHP, with composer and extensions
161+ id : setup-php
163162 # https://github.com/shivammathur/setup-php
164163 uses : shivammathur/setup-php@v2
165164 with :
166- php- version: ${{ matrix.php-versions }}
167- extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
168- tools : composer
169- ini-values : error_reporting=E_ALL
170- coverage : pcov
165+ # Should be the higest supported version, so we can use the newest tools
166+ php-version : ' 8.4 '
167+ tools : composer, composer-require-checker, composer-unused, phpcs, psalm
168+ # optional performance gain for psalm: opcache
169+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
171170
172171 - name : Setup problem matchers for PHP
173172 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
174173
175- - name : Setup problem matchers for PHPUnit
176- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
177-
178- - name : Set git to use LF
179- run : |
180- git config --global core.autocrlf false
181- git config --global core.eol lf
182-
183174 - uses : actions/checkout@v4
184175
185176 - name : Get composer cache directory
@@ -192,60 +183,66 @@ jobs:
192183 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
193184 restore-keys : ${{ runner.os }}-composer-
194185
186+ - name : Validate composer.json and composer.lock
187+ run : composer validate
188+
195189 - name : Install Composer dependencies
196190 run : composer install --no-progress --prefer-dist --optimize-autoloader
197191
198- - name : Run unit tests with coverage
199- if : ${{ matrix.php-versions == '8.3' }}
200- run : vendor/bin/phpunit
192+ - name : Check code for hard dependencies missing in composer.json
193+ run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
201194
202- - name : Run unit tests (no coverage)
203- if : ${{ matrix.php-versions != '8.3' }}
204- run : vendor/bin/phpunit --no-coverage
195+ - name : Check code for unused dependencies in composer.json
196+ run : composer-unused
205197
206- - name : Save coverage data
207- if : ${{ matrix.php-versions == '8.3' }}
208- uses : actions/upload-artifact@v4
209- with :
210- name : coverage-data
211- path : ${{ github.workspace }}/build
198+ - name : PHP Code Sniffer
199+ run : phpcs
212200
213- unit-tests-windows :
214- name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
215- runs-on : ${{ matrix.operating-system }}
216- needs : [linter, quality, security]
217- strategy :
218- fail-fast : true
219- matrix :
220- operating-system : [windows-latest]
221- php-versions : ['8.1', '8.2', '8.3']
201+ - name : Psalm
202+ continue-on-error : true
203+ run : |
204+ psalm -c psalm.xml \
205+ --show-info=true \
206+ --shepherd \
207+ --php-version=${{ steps.setup-php.outputs.php-version }}
208+
209+ - name : Psalm (testsuite)
210+ run : |
211+ psalm -c psalm-dev.xml \
212+ --show-info=true \
213+ --shepherd \
214+ --php-version=${{ steps.setup-php.outputs.php-version }}
215+
216+ - name : Psalter
217+ run : |
218+ psalm --alter \
219+ --issues=UnnecessaryVarAnnotation \
220+ --dry-run \
221+ --php-version=${{ steps.setup-php.outputs.php-version }}
222+
223+ security :
224+ name : Security checks
225+ runs-on : [ubuntu-latest]
226+ needs : [unit-tests-linux]
222227
223228 steps :
224229 - name : Setup PHP, with composer and extensions
225230 # https://github.com/shivammathur/setup-php
226231 uses : shivammathur/setup-php@v2
227232 with :
228- php-version : ${{ matrix.php-versions }}
233+ # Should be the lowest supported version
234+ php-version : ' 8.1'
229235 extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
230236 tools : composer
231- ini-values : error_reporting=E_ALL
232237 coverage : none
233238
234239 - name : Setup problem matchers for PHP
235240 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
236241
237- - name : Setup problem matchers for PHPUnit
238- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
239-
240- - name : Set git to use LF
241- run : |
242- git config --global core.autocrlf false
243- git config --global core.eol lf
244-
245242 - uses : actions/checkout@v4
246243
247244 - name : Get composer cache directory
248- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
245+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
249246
250247 - name : Cache composer dependencies
251248 uses : actions/cache@v4
@@ -255,15 +252,22 @@ jobs:
255252 restore-keys : ${{ runner.os }}-composer-
256253
257254 - name : Install Composer dependencies
258- run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
255+ run : composer install --no-progress --prefer-dist --optimize-autoloader
259256
260- - name : Run unit tests
261- run : vendor/bin/phpunit --no-coverage
257+ - name : Security check for locked dependencies
258+ run : composer audit
259+
260+ - name : Update Composer dependencies
261+ run : composer update --no-progress --prefer-dist --optimize-autoloader
262+
263+ - name : Security check for updated dependencies
264+ run : composer audit
262265
263266 coverage :
264267 name : Code coverage
265268 runs-on : [ubuntu-latest]
266269 needs : [unit-tests-linux]
270+
267271 steps :
268272 - uses : actions/checkout@v4
269273
0 commit comments