@@ -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@v5
23- with :
24- fetch-depth : 0
25-
26- - name : Lint Code Base
27- uses : super-linter/super-linter/slim@v8
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@v5
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'
120- extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
119+ php-version : ${{ matrix.php-versions }}
120+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml, zip
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@v5
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,37 +146,26 @@ 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 }}
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, phpstan
167168 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
171169
172170 - name : Setup problem matchers for PHP
173171 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -192,43 +190,43 @@ jobs:
192190 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
193191 restore-keys : ${{ runner.os }}-composer-
194192
193+ - name : Validate composer.json and composer.lock
194+ run : composer validate
195+
195196 - name : Install Composer dependencies
196197 run : composer install --no-progress --prefer-dist --optimize-autoloader
197198
198- - name : Run unit tests with coverage
199- if : ${{ matrix.php-versions == '8.3' }}
200- run : vendor/bin/phpunit
199+ - name : Check code for hard dependencies missing in composer.json
200+ run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
201201
202- - name : Run unit tests (no coverage)
203- if : ${{ matrix.php-versions != '8.3' }}
204- run : vendor/bin/phpunit --no-coverage
202+ - name : Check code for unused dependencies in composer.json
203+ run : composer-unused
205204
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
205+ - name : PHP Code Sniffer
206+ run : phpcs
212207
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']
208+ - name : PHPStan
209+ run : |
210+ vendor/bin/phpstan analyze -c phpstan.neon
211+
212+ - name : PHPStan (testsuite)
213+ run : |
214+ vendor/bin/phpstan analyze -c phpstan-dev.neon
215+
216+ security :
217+ name : Security checks
218+ runs-on : [ubuntu-latest]
219+ needs : [unit-tests-linux]
222220
223221 steps :
224222 - name : Setup PHP, with composer and extensions
225223 # https://github.com/shivammathur/setup-php
226224 uses : shivammathur/setup-php@v2
227225 with :
228- php-version : ${{ matrix.php-versions }}
226+ # Should be the lowest supported version
227+ php-version : ' 8.1'
229228 extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
230229 tools : composer
231- ini-values : error_reporting=E_ALL
232230 coverage : none
233231
234232 - name : Setup problem matchers for PHP
@@ -245,7 +243,7 @@ jobs:
245243 - uses : actions/checkout@v5
246244
247245 - name : Get composer cache directory
248- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
246+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
249247
250248 - name : Cache composer dependencies
251249 uses : actions/cache@v4
@@ -255,15 +253,22 @@ jobs:
255253 restore-keys : ${{ runner.os }}-composer-
256254
257255 - name : Install Composer dependencies
258- run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
256+ run : composer install --no-progress --prefer-dist --optimize-autoloader
259257
260- - name : Run unit tests
261- run : vendor/bin/phpunit --no-coverage
258+ - name : Security check for locked dependencies
259+ run : composer audit
260+
261+ - name : Update Composer dependencies
262+ run : composer update --no-progress --prefer-dist --optimize-autoloader
263+
264+ - name : Security check for updated dependencies
265+ run : composer audit
262266
263267 coverage :
264268 name : Code coverage
265269 runs-on : [ubuntu-latest]
266270 needs : [unit-tests-linux]
271+
267272 steps :
268273 - uses : actions/checkout@v5
269274
0 commit comments