@@ -14,50 +14,61 @@ 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/reusable_phplinter.yml@v1.9.2
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- # super-linter needs the full git history to get the
25- # list of files that changed across commits
26- fetch-depth : 0
27-
28- - name : Lint Code Base
29- uses : super-linter/super-linter/slim@v7
30- env :
31- SAVE_SUPER_LINTER_OUTPUT : false
32- # To report GitHub Actions status checks
33- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
34- LOG_LEVEL : NOTICE
35- LINTER_RULES_PATH : ' tools/linters'
36- VALIDATE_ALL_CODEBASE : true
37- VALIDATE_JSON : true
38- VALIDATE_PHP_BUILTIN : true
39- VALIDATE_YAML : true
40- VALIDATE_XML : true
41- VALIDATE_GITHUB_ACTIONS : true
33+ uses : simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.2
34+ with :
35+ enable_eslinter : false
36+ enable_jsonlinter : true
37+ enable_stylelinter : false
38+ enable_yamllinter : true
4239
43- quality :
44- name : Quality control
45- 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+ strategy :
45+ fail-fast : false
46+ matrix :
47+ operating-system : [ubuntu-latest]
48+ php-versions : ['8.1', '8.2', '8.3', '8.4']
4649
4750 steps :
4851 - name : Setup PHP, with composer and extensions
49- id : setup-php
5052 # https://github.com/shivammathur/setup-php
5153 uses : shivammathur/setup-php@v2
5254 with :
53- # Should be the higest supported version, so we can use the newest tools
54- php-version : ' 8.4'
55- tools : composer, composer-require-checker, composer-unused, phpcs
55+ php-version : ${{ matrix.php-versions }}
5656 extensions : ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
57+ tools : composer
58+ ini-values : error_reporting=E_ALL
59+ coverage : pcov
5760
5861 - name : Setup problem matchers for PHP
5962 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6063
64+ - name : Setup problem matchers for PHPUnit
65+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
66+
67+ - name : Set git to use LF
68+ run : |
69+ git config --global core.autocrlf false
70+ git config --global core.eol lf
71+
6172 - uses : actions/checkout@v4
6273
6374 - name : Get composer cache directory
@@ -70,50 +81,60 @@ jobs:
7081 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7182 restore-keys : ${{ runner.os }}-composer-
7283
73- - name : Validate composer.json and composer.lock
74- run : composer validate
75-
7684 - name : Install Composer dependencies
7785 run : composer install --no-progress --prefer-dist --optimize-autoloader
7886
79- - name : Check code for hard dependencies missing in composer.json
80- run : composer-require-checker check composer.json
81-
82- - name : Check code for unused dependencies in composer.json
83- run : composer-unused
87+ - name : Run unit tests with coverage
88+ if : ${{ matrix.php-versions == '8.4' }}
89+ run : vendor/bin/phpunit
8490
85- - name : PHP Code Sniffer
86- run : phpcs
91+ - name : Run unit tests (no coverage)
92+ if : ${{ matrix.php-versions != '8.4' }}
93+ run : vendor/bin/phpunit --no-coverage
8794
88- - name : PHPStan
89- run : |
90- vendor/bin/phpstan analyze -c phpstan.neon
95+ - name : Save coverage data
96+ if : ${{ matrix.php-versions == '8.4' }}
97+ uses : actions/upload-artifact@v4
98+ with :
99+ name : coverage-data
100+ path : ${{ github.workspace }}/build
91101
92- - name : Psalm (testsuite)
93- run : |
94- vendor/bin/phpstan analyze -c phpstan-dev.neon
102+ unit-tests-windows :
103+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
104+ runs-on : ${{ matrix.operating-system }}
105+ needs : [phplinter, linter]
106+ strategy :
107+ fail-fast : true
108+ matrix :
109+ operating-system : [windows-latest]
110+ php-versions : ['8.1', '8.2', '8.3', '8.4']
95111
96- security :
97- name : Security checks
98- runs-on : [ubuntu-latest]
99112 steps :
100113 - name : Setup PHP, with composer and extensions
101114 # https://github.com/shivammathur/setup-php
102115 uses : shivammathur/setup-php@v2
103116 with :
104- # Should be the lowest supported version
105- php-version : ' 8.1'
117+ php-version : ${{ matrix.php-versions }}
106118 extensions : ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
107119 tools : composer
120+ ini-values : error_reporting=E_ALL
108121 coverage : none
109122
110123 - name : Setup problem matchers for PHP
111124 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
112125
126+ - name : Setup problem matchers for PHPUnit
127+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
128+
129+ - name : Set git to use LF
130+ run : |
131+ git config --global core.autocrlf false
132+ git config --global core.eol lf
133+
113134 - uses : actions/checkout@v4
114135
115136 - name : Get composer cache directory
116- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
117138
118139 - name : Cache composer dependencies
119140 uses : actions/cache@v4
@@ -125,47 +146,27 @@ jobs:
125146 - name : Install Composer dependencies
126147 run : composer install --no-progress --prefer-dist --optimize-autoloader
127148
128- - name : Security check for locked dependencies
129- run : composer audit
130-
131- - name : Update Composer dependencies
132- run : composer update --no-progress --prefer-dist --optimize-autoloader
133-
134- - name : Security check for updated dependencies
135- run : composer audit
149+ - name : Run unit tests
150+ run : vendor/bin/phpunit --no-coverage
136151
137- unit-tests-linux :
138- name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
139- runs-on : ${{ matrix.operating-system }}
140- needs : [linter, quality, security]
141- strategy :
142- fail-fast : false
143- matrix :
144- operating-system : [ubuntu-latest]
145- php-versions : ['8.1', '8.2', '8.3', '8.4']
152+ quality :
153+ name : Quality control
154+ runs-on : [ubuntu-latest]
146155
147156 steps :
148157 - name : Setup PHP, with composer and extensions
158+ id : setup-php
149159 # https://github.com/shivammathur/setup-php
150160 uses : shivammathur/setup-php@v2
151161 with :
152- php-version : ${{ matrix.php-versions }}
162+ # Should be the higest supported version, so we can use the newest tools
163+ php-version : ' 8.4'
164+ tools : composer, composer-require-checker, composer-unused, phpcs
153165 extensions : ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
154- tools : composer
155- ini-values : error_reporting=E_ALL
156- coverage : pcov
157166
158167 - name : Setup problem matchers for PHP
159168 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
160169
161- - name : Setup problem matchers for PHPUnit
162- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
163-
164- - name : Set git to use LF
165- run : |
166- git config --global core.autocrlf false
167- git config --global core.eol lf
168-
169170 - uses : actions/checkout@v4
170171
171172 - name : Get composer cache directory
@@ -178,60 +179,50 @@ jobs:
178179 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
179180 restore-keys : ${{ runner.os }}-composer-
180181
182+ - name : Validate composer.json and composer.lock
183+ run : composer validate
184+
181185 - name : Install Composer dependencies
182186 run : composer install --no-progress --prefer-dist --optimize-autoloader
183187
184- - name : Run unit tests with coverage
185- if : ${{ matrix.php-versions == '8.4' }}
186- run : vendor/bin/phpunit
188+ - name : Check code for hard dependencies missing in composer.json
189+ run : composer-require-checker check composer.json
187190
188- - name : Run unit tests (no coverage)
189- if : ${{ matrix.php-versions != '8.4' }}
190- run : vendor/bin/phpunit --no-coverage
191+ - name : Check code for unused dependencies in composer.json
192+ run : composer-unused
191193
192- - name : Save coverage data
193- if : ${{ matrix.php-versions == '8.4' }}
194- uses : actions/upload-artifact@v4
195- with :
196- name : coverage-data
197- path : ${{ github.workspace }}/build
194+ - name : PHP Code Sniffer
195+ run : phpcs
198196
199- unit-tests-windows :
200- name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
201- runs-on : ${{ matrix.operating-system }}
202- needs : [linter, quality, security]
203- strategy :
204- fail-fast : true
205- matrix :
206- operating-system : [windows-latest]
207- php-versions : ['8.1', '8.2', '8.3', '8.4']
197+ - name : PHPStan
198+ run : |
199+ vendor/bin/phpstan analyze -c phpstan.neon
200+
201+ - name : Psalm (testsuite)
202+ run : |
203+ vendor/bin/phpstan analyze -c phpstan-dev.neon
208204
205+ security :
206+ name : Security checks
207+ runs-on : [ubuntu-latest]
209208 steps :
210209 - name : Setup PHP, with composer and extensions
211210 # https://github.com/shivammathur/setup-php
212211 uses : shivammathur/setup-php@v2
213212 with :
214- php-version : ${{ matrix.php-versions }}
213+ # Should be the lowest supported version
214+ php-version : ' 8.1'
215215 extensions : ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
216216 tools : composer
217- ini-values : error_reporting=E_ALL
218217 coverage : none
219218
220219 - name : Setup problem matchers for PHP
221220 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
222221
223- - name : Setup problem matchers for PHPUnit
224- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
225-
226- - name : Set git to use LF
227- run : |
228- git config --global core.autocrlf false
229- git config --global core.eol lf
230-
231222 - uses : actions/checkout@v4
232223
233224 - name : Get composer cache directory
234- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
225+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
235226
236227 - name : Cache composer dependencies
237228 uses : actions/cache@v4
@@ -243,8 +234,14 @@ jobs:
243234 - name : Install Composer dependencies
244235 run : composer install --no-progress --prefer-dist --optimize-autoloader
245236
246- - name : Run unit tests
247- run : vendor/bin/phpunit --no-coverage
237+ - name : Security check for locked dependencies
238+ run : composer audit
239+
240+ - name : Update Composer dependencies
241+ run : composer update --no-progress --prefer-dist --optimize-autoloader
242+
243+ - name : Security check for updated dependencies
244+ run : composer audit
248245
249246 coverage :
250247 name : Code coverage
0 commit comments