@@ -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- 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/reusable_linter.yml@v1.9.2
34+ with :
35+ enable_eslinter : false
36+ enable_jsonlinter : true
37+ enable_stylelinter : false
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+ strategy :
45+ fail-fast : false
46+ matrix :
47+ operating-system : [ubuntu-latest]
48+ php-versions : ['8.1', '8.2', '8.3', '8.4']
4549
4650 steps :
4751 - name : Setup PHP, with composer and extensions
48- id : setup-php
4952 # https://github.com/shivammathur/setup-php
5053 uses : shivammathur/setup-php@v2
5154 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, sockets, spl, xml
55+ php- version: ${{ matrix.php-versions }}
56+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sockets, 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,64 +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 --config-file=tools/composer-require-checker.json composer.json
81-
82- - name : Check code for unused dependencies in composer.json
83- run : composer-unused
84-
85- - name : PHP Code Sniffer
86- run : phpcs
87+ - name : Run unit tests with coverage
88+ if : ${{ matrix.php-versions == '8.4' }}
89+ run : vendor/bin/phpunit
8790
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 }}
91+ - name : Run unit tests (no coverage)
92+ if : ${{ matrix.php-versions != '8.4' }}
93+ run : vendor/bin/phpunit --no-coverage
9594
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 }}
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
102101
103- - name : Psalter
104- run : |
105- psalm --alter \
106- --issues=UnnecessaryVarAnnotation \
107- --dry-run \
108- --php-version=${{ steps.setup-php.outputs.php-version }}
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']
109111
110- security :
111- name : Security checks
112- runs-on : [ubuntu-latest]
113112 steps :
114113 - name : Setup PHP, with composer and extensions
115114 # https://github.com/shivammathur/setup-php
116115 uses : shivammathur/setup-php@v2
117116 with :
118- # Should be the lowest supported version
119- php-version : ' 8.1'
117+ php-version : ${{ matrix.php-versions }}
120118 extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sockets, spl, xml
121119 tools : composer
120+ ini-values : error_reporting=E_ALL
122121 coverage : none
123122
124123 - name : Setup problem matchers for PHP
125124 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
126125
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+
127134 - uses : actions/checkout@v4
128135
129136 - name : Get composer cache directory
130- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
131138
132139 - name : Cache composer dependencies
133140 uses : actions/cache@v4
@@ -137,49 +144,31 @@ jobs:
137144 restore-keys : ${{ runner.os }}-composer-
138145
139146 - 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
147+ run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
147148
148- - name : Security check for updated dependencies
149- run : composer audit
149+ - name : Run unit tests
150+ run : vendor/bin/phpunit --no-coverage
150151
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']
152+ quality :
153+ name : Quality control
154+ runs-on : [ubuntu-latest]
160155
161156 steps :
162157 - name : Setup PHP, with composer and extensions
158+ id : setup-php
163159 # https://github.com/shivammathur/setup-php
164160 uses : shivammathur/setup-php@v2
165161 with :
166- php-version : ${{ matrix.php-versions }}
167- extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sockets, spl, xml
168- tools : composer
169- ini-values : error_reporting=E_ALL
170- coverage : pcov
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, psalm
165+ # optional performance gain for psalm: opcache
166+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, \
167+ pcre, posix, sockets, spl, xml
171168
172169 - name : Setup problem matchers for PHP
173170 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
174171
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-
183172 - uses : actions/checkout@v4
184173
185174 - name : Get composer cache directory
@@ -192,60 +181,64 @@ jobs:
192181 key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
193182 restore-keys : ${{ runner.os }}-composer-
194183
184+ - name : Validate composer.json and composer.lock
185+ run : composer validate
186+
195187 - name : Install Composer dependencies
196188 run : composer install --no-progress --prefer-dist --optimize-autoloader
197189
198- - name : Run unit tests with coverage
199- if : ${{ matrix.php-versions == '8.3' }}
200- run : vendor/bin/phpunit
190+ - name : Check code for hard dependencies missing in composer.json
191+ run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
201192
202- - name : Run unit tests (no coverage)
203- if : ${{ matrix.php-versions != '8.3' }}
204- run : vendor/bin/phpunit --no-coverage
193+ - name : Check code for unused dependencies in composer.json
194+ run : composer-unused
205195
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
196+ - name : PHP Code Sniffer
197+ run : phpcs
212198
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']
199+ - name : Psalm
200+ continue-on-error : true
201+ run : |
202+ psalm -c psalm.xml \
203+ --show-info=true \
204+ --shepherd \
205+ --php-version=${{ steps.setup-php.outputs.php-version }}
222206
207+ - name : Psalm (testsuite)
208+ run : |
209+ psalm -c psalm-dev.xml \
210+ --show-info=true \
211+ --shepherd \
212+ --php-version=${{ steps.setup-php.outputs.php-version }}
213+
214+ - name : Psalter
215+ run : |
216+ psalm --alter \
217+ --issues=UnnecessaryVarAnnotation \
218+ --dry-run \
219+ --php-version=${{ steps.setup-php.outputs.php-version }}
220+
221+ security :
222+ name : Security checks
223+ runs-on : [ubuntu-latest]
223224 steps :
224225 - name : Setup PHP, with composer and extensions
225226 # https://github.com/shivammathur/setup-php
226227 uses : shivammathur/setup-php@v2
227228 with :
228- php-version : ${{ matrix.php-versions }}
229+ # Should be the lowest supported version
230+ php-version : ' 8.1'
229231 extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sockets, spl, xml
230232 tools : composer
231- ini-values : error_reporting=E_ALL
232233 coverage : none
233234
234235 - name : Setup problem matchers for PHP
235236 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
236237
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-
245238 - uses : actions/checkout@v4
246239
247240 - name : Get composer cache directory
248- run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env: GITHUB_ENV"
241+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
249242
250243 - name : Cache composer dependencies
251244 uses : actions/cache@v4
@@ -255,10 +248,16 @@ jobs:
255248 restore-keys : ${{ runner.os }}-composer-
256249
257250 - name : Install Composer dependencies
258- run : composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
251+ run : composer install --no-progress --prefer-dist --optimize-autoloader
259252
260- - name : Run unit tests
261- run : vendor/bin/phpunit --no-coverage
253+ - name : Security check for locked dependencies
254+ run : composer audit
255+
256+ - name : Update Composer dependencies
257+ run : composer update --no-progress --prefer-dist --optimize-autoloader
258+
259+ - name : Security check for updated dependencies
260+ run : composer audit
262261
263262 coverage :
264263 name : Code coverage
0 commit comments