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
1315jobs :
14- basic-tests :
15- name : Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}
16- runs-on : ${{ matrix.operating-system }}
17- strategy :
18- fail-fast : false
19- matrix :
20- operating-system : [ubuntu-latest, windows-latest]
21- php-versions : ['7.4', '8.0', '8.1', '8.2']
16+ linter :
17+ name : Linter
18+ runs-on : ['ubuntu-latest']
19+
20+ steps :
21+ - uses : actions/checkout@v3
22+ with :
23+ fetch-depth : 0
24+
25+ - name : Lint Code Base
26+ uses : github/super-linter/slim@v5
27+ env :
28+ LOG_LEVEL : NOTICE
29+ VALIDATE_ALL_CODEBASE : true
30+ LINTER_RULES_PATH : ' tools/linters'
31+ VALIDATE_CSS : true
32+ VALIDATE_JAVASCRIPT_ES : true
33+ VALIDATE_JSON : true
34+ VALIDATE_PHP_BUILTIN : true
35+ VALIDATE_YAML : true
36+ VALIDATE_XML : true
37+ VALIDATE_GITHUB_ACTIONS : true
38+
39+ quality :
40+ name : Quality control
41+ runs-on : [ubuntu-latest]
2242
2343 steps :
2444 - name : Setup PHP, with composer and extensions
25- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
45+ id : setup-php
46+ # https://github.com/shivammathur/setup-php
47+ uses : shivammathur/setup-php@v2
2648 with :
27- coverage : pcov
28- extensions : intl, mbstring, xml
29- ini-values : error_reporting=E_ALL
30- php-version : ${{ matrix.php-versions }}
31- tools : composer:v2
49+ # Should be the higest supported version, so we can use the newest tools
50+ php-version : ' 8.2 '
51+ tools : composer, composer-require-checker, composer-unused, phpcs, psalm
52+ # optional performance gain for psalm: opcache
53+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
3254
3355 - name : Setup problem matchers for PHP
3456 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3557
36- - name : Setup problem matchers for PHPUnit
37- run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
38-
39- - name : Set git to use LF
40- run : |
41- git config --global core.autocrlf false
42- git config --global core.eol lf
43-
4458 - uses : actions/checkout@v3
4559
46- - name : Get composer cache directory (linux)
47- if : ${{ matrix.operating-system == 'ubuntu-latest' }}
48- run : echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $GITHUB_ENV
49-
50- - name : Get composer cache directory (windows)
51- if : ${{ matrix.operating-system == 'windows-latest' }}
52- run : echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $env:GITHUB_ENV
60+ - name : Get composer cache directory
61+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
5362
5463 - name : Cache composer dependencies
5564 uses : actions/cache@v3
@@ -64,54 +73,65 @@ jobs:
6473 - name : Install Composer dependencies
6574 run : composer install --no-progress --prefer-dist --optimize-autoloader
6675
67- - name : Syntax check PHP
68- run : bash vendor/bin/ check-syntax-php.sh
76+ - name : Check code for hard dependencies missing in composer.json
77+ run : composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
6978
70- - name : Create ticket cache
71- run : |
72- echo "SIMPLESAMLPHP_CONFIG_DIR=${{ github.workspace }}/tests/config/" >> $GITHUB_ENV
73- mkdir ${{ github.workspace }}/tests/ticketcache
79+ - name : Check code for unused dependencies in composer.json
80+ run : composer-unused
7481
75- - name : Decide whether to run code coverage or not
76- if : ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }}
82+ - name : PHP Code Sniffer
83+ run : phpcs
84+
85+ - name : Psalm
86+ continue-on-error : true
7787 run : |
78- echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
88+ psalm -c psalm.xml \
89+ --show-info=true \
90+ --shepherd \
91+ --php-version=${{ steps.setup-php.outputs.php-version }}
7992
80- - name : Run unit tests
93+ - name : Psalm (testsuite)
8194 run : |
82- echo $NO_COVERAGE
83- ./vendor/bin/phpunit $NO_COVERAGE
95+ psalm -c psalm-dev.xml \
96+ --show-info=true \
97+ --shepherd \
98+ --php-version=${{ steps.setup-php.outputs.php-version }}
8499
85- - name : Save coverage data
86- if : ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
87- uses : actions/upload-artifact@v3
88- with :
89- name : build-data
90- path : ${{ github.workspace }}/build
100+ - name : Psalter
101+ run : |
102+ psalm --alter \
103+ --issues=UnnecessaryVarAnnotation \
104+ --dry-run \
105+ --php-version= ${{ steps.setup-php.outputs.php-version }}
91106
92107 security :
93108 name : Security checks
94109 runs-on : [ubuntu-latest]
95110 steps :
96111 - name : Setup PHP, with composer and extensions
97- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
112+ # https://github.com/shivammathur/setup-php
113+ uses : shivammathur/setup-php@v2
98114 with :
99- php-version : ' 7.4'
100- tools : composer:v2
101- extensions : ldap, mbstring, xml
102- coverage : none
115+ # Should be the lowest supported version
116+ php-version : ' 8.0'
117+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
118+ tools : composer
119+ coverage : none
103120
104121 - name : Setup problem matchers for PHP
105122 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
106123
107124 - uses : actions/checkout@v3
108125
126+ - name : Get composer cache directory
127+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
128+
109129 - name : Cache composer dependencies
110130 uses : actions/cache@v3
111131 with :
112- path : ${{ steps.composer-cache.outputs.dir }}
113- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
114- restore-keys : ${{ runner.os }}-composer-
132+ path : $COMPOSER_CACHE
133+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
134+ restore-keys : ${{ runner.os }}-composer-
115135
116136 - name : Install Composer dependencies
117137 run : composer install --no-progress --prefer-dist --optimize-autoloader
@@ -125,85 +145,129 @@ jobs:
125145 - name : Security check for updated dependencies
126146 run : composer audit
127147
128- sanity-check :
129- name : Sanity checks
130- runs-on : [ubuntu-latest]
148+ unit-tests-linux :
149+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
150+ runs-on : ${{ matrix.operating-system }}
151+ needs : [linter, quality, security]
152+ strategy :
153+ fail-fast : false
154+ matrix :
155+ operating-system : [ubuntu-latest]
156+ php-versions : ['8.0', '8.1', '8.2']
131157
132158 steps :
133159 - name : Setup PHP, with composer and extensions
134- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
160+ # https://github.com/shivammathur/setup-php
161+ uses : shivammathur/setup-php@v2
135162 with :
136- php-version : ' 7.4'
137- tools : composer:v2
138- extensions : ldap, mbstring, xml
139- coverage : none
163+ php-version : ${{ matrix.php-versions }}
164+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
165+ tools : composer
166+ ini-values : error_reporting=E_ALL
167+ coverage : pcov
140168
141169 - name : Setup problem matchers for PHP
142170 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
143171
172+ - name : Setup problem matchers for PHPUnit
173+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
174+
175+ - name : Set git to use LF
176+ run : |
177+ git config --global core.autocrlf false
178+ git config --global core.eol lf
179+
144180 - uses : actions/checkout@v3
145181
182+ - name : Get composer cache directory
183+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
184+
146185 - name : Cache composer dependencies
147186 uses : actions/cache@v3
148187 with :
149- path : $COMPOSER_CACHE
150- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
151- restore-keys : ${{ runner.os }}-composer-
188+ path : $COMPOSER_CACHE
189+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
190+ restore-keys : ${{ runner.os }}-composer-
152191
153192 - name : Install Composer dependencies
154193 run : composer install --no-progress --prefer-dist --optimize-autoloader
155194
156- - name : Syntax check YAML / XML / JSON
157- run : |
158- bash vendor/bin/check-syntax-yaml.sh
159- bash vendor/bin/check-syntax-xml.sh
160- bash vendor/bin/check-syntax-json.sh
195+ - name : Run unit tests with coverage
196+ if : ${{ matrix.php-versions == '8.2' }}
197+ run : vendor/bin/phpunit
161198
162- quality :
163- name : Quality control
164- runs-on : [ubuntu-latest]
165- needs : [basic-tests]
199+ - name : Run unit tests (no coverage)
200+ if : ${{ matrix.php-versions != '8.2' }}
201+ run : vendor/bin/phpunit --no-coverage
202+
203+ - name : Save coverage data
204+ if : ${{ matrix.php-versions == '8.2' }}
205+ uses : actions/upload-artifact@v3
206+ with :
207+ name : coverage-data
208+ path : ${{ github.workspace }}/build
209+
210+ unit-tests-windows :
211+ name : " Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
212+ runs-on : ${{ matrix.operating-system }}
213+ needs : [linter, quality, security]
214+ strategy :
215+ fail-fast : true
216+ matrix :
217+ operating-system : [windows-latest]
218+ php-versions : ['8.0', '8.1', '8.2']
166219
167220 steps :
168221 - name : Setup PHP, with composer and extensions
169- id : setup-php
170- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
222+ # https://github.com/shivammathur/ setup-php
223+ uses : shivammathur/setup-php@v2
171224 with :
172- php-version : ' 7.4'
173- tools : composer:v2
174- extensions : ldap, mbstring, xml
225+ php-version : ${{ matrix.php-versions }}
226+ extensions : ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
227+ tools : composer
228+ ini-values : error_reporting=E_ALL
229+ coverage : none
175230
176231 - name : Setup problem matchers for PHP
177232 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
178233
234+ - name : Setup problem matchers for PHPUnit
235+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
236+
237+ - name : Set git to use LF
238+ run : |
239+ git config --global core.autocrlf false
240+ git config --global core.eol lf
241+
179242 - uses : actions/checkout@v3
180243
244+ - name : Get composer cache directory
245+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
246+
181247 - name : Cache composer dependencies
182248 uses : actions/cache@v3
183249 with :
184- path : $COMPOSER_CACHE
185- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
186- restore-keys : ${{ runner.os }}-composer-
250+ path : $COMPOSER_CACHE
251+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
252+ restore-keys : ${{ runner.os }}-composer-
187253
188254 - name : Install Composer dependencies
189255 run : composer install --no-progress --prefer-dist --optimize-autoloader
190256
257+ - name : Run unit tests
258+ run : vendor/bin/phpunit --no-coverage
259+
260+ coverage :
261+ name : Code coverage
262+ runs-on : [ubuntu-latest]
263+ needs : [unit-tests-linux]
264+ steps :
265+ - uses : actions/checkout@v3
266+
191267 - uses : actions/download-artifact@v3
192268 with :
193- name : build -data
269+ name : coverage -data
194270 path : ${{ github.workspace }}/build
195271
196272 - name : Codecov
197273 uses : codecov/codecov-action@v3
198-
199- - name : PHP Code Sniffer
200- continue-on-error : true
201- run : php vendor/bin/phpcs
202-
203- - name : Psalm
204- continue-on-error : true
205- run : php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
206-
207- - name : Psalter
208- continue-on-error : true
209- run : php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}
0 commit comments