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 : ['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@v4
27+ env :
28+ VALIDATE_ALL_CODEBASE : true
29+ LINTER_RULES_PATH : ' tools/linters'
30+ VALIDATE_JSON : true
31+ VALIDATE_PHP_BUILTIN : true
32+ VALIDATE_YAML : true
33+ VALIDATE_GITHUB_ACTIONS : true
34+
35+ quality :
36+ name : Quality control
37+ runs-on : [ubuntu-latest]
2238
2339 steps :
2440 - name : Setup PHP, with composer and extensions
25- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
41+ id : setup-php
42+ # https://github.com/shivammathur/setup-php
43+ uses : shivammathur/setup-php@v2
2644 with :
27- php-version : ${{ matrix.php-versions }}
28- extensions : mbstring, xml
29- ini-values : error_reporting=E_ALL
45+ php-version : ' 8.0'
3046 tools : composer:v2
31- coverage : pcov
47+ extensions : ctype, spl
3248
3349 - name : Setup problem matchers for PHP
3450 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3551
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-
4452 - uses : actions/checkout@v3
4553
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
54+ - name : Get composer cache directory
55+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
5356
5457 - name : Cache composer dependencies
5558 uses : actions/cache@v3
@@ -64,49 +67,61 @@ jobs:
6467 - name : Install Composer dependencies
6568 run : composer install --no-progress --prefer-dist --optimize-autoloader
6669
67- - name : Syntax check PHP
68- run : bash vendor/bin/check-syntax-php.sh
70+ - name : PHP Code Sniffer
71+ run : php vendor/simplesamlphp/simplesamlphp-test-framework/tools/phpcs
6972
70- - name : Decide whether to run code coverage or not
71- if : ${{ matrix.php-versions != '8.0' || matrix.operating-system != 'ubuntu-latest' }}
73+ - name : Psalm
74+ continue-on-error : true
7275 run : |
73- echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
76+ php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
77+ -c psalm.xml \
78+ --show-info=true \
79+ --shepherd \
80+ --php-version=${{ steps.setup-php.outputs.php-version }}
7481
75- - name : Run unit tests
82+ - name : Psalm (testsuite)
7683 run : |
77- echo $NO_COVERAGE
78- ./vendor/bin/phpunit $NO_COVERAGE
84+ php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
85+ -c psalm-dev.xml \
86+ --show-info=true \
87+ --shepherd \
88+ --php-version=${{ steps.setup-php.outputs.php-version }}
7989
80- - name : Save coverage data
81- if : ${{ matrix.php-versions == '8.0' && matrix.operating-system == 'ubuntu-latest' }}
82- uses : actions/upload-artifact@v3
83- with :
84- name : build-data
85- path : ${{ github.workspace }}/build
90+ - name : Psalter
91+ run : |
92+ php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
93+ --alter \
94+ --issues=UnnecessaryVarAnnotation \
95+ --dry-run \
96+ --php-version=${{ steps.setup-php.outputs.php-version }}
8697
8798 security :
8899 name : Security checks
89100 runs-on : [ubuntu-latest]
90101 steps :
91102 - name : Setup PHP, with composer and extensions
92- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
103+ # https://github.com/shivammathur/setup-php
104+ uses : shivammathur/setup-php@v2
93105 with :
94- php-version : ' 8.0'
95- extensions : mbstring, xml
96- tools : composer:v2
97- coverage : none
106+ php-version : ' 8.0'
107+ extensions : ctype, spl
108+ tools : composer:v2
109+ coverage : none
98110
99111 - name : Setup problem matchers for PHP
100112 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
101113
102114 - uses : actions/checkout@v3
103115
116+ - name : Get composer cache directory
117+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
118+
104119 - name : Cache composer dependencies
105120 uses : actions/cache@v3
106121 with :
107- path : $COMPOSER_CACHE
108- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
109- restore-keys : ${{ runner.os }}-composer-
122+ path : $COMPOSER_CACHE
123+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
124+ restore-keys : ${{ runner.os }}-composer-
110125
111126 - name : Install Composer dependencies
112127 run : composer install --no-progress --prefer-dist --optimize-autoloader
@@ -120,85 +135,127 @@ jobs:
120135 - name : Security check for updated dependencies
121136 run : composer audit
122137
123- sanity-check :
124- name : Sanity checks
125- runs-on : [ubuntu-latest]
138+ unit-tests-linux :
139+ name : " Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
140+ runs-on : ${{ matrix.operating-system }}
141+ needs : [linter, quality, security]
142+ strategy :
143+ fail-fast : false
144+ matrix :
145+ operating-system : [ubuntu-latest]
146+ php-versions : ['8.0', '8.1', '8.2']
126147
127148 steps :
128149 - name : Setup PHP, with composer and extensions
129- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
150+ # https://github.com/shivammathur/setup-php
151+ uses : shivammathur/setup-php@v2
130152 with :
131- php-version : ' 8.0 '
132- extensions : mbstring, xml
153+ php-version : ${{ matrix.php-versions }}
154+ extensions : ctype, spl
133155 tools : composer:v2
134- coverage : none
156+ ini-values : error_reporting=E_ALL
157+ coverage : xdebug
135158
136159 - name : Setup problem matchers for PHP
137160 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
138161
162+ - name : Setup problem matchers for PHPUnit
163+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
164+
165+ - name : Set git to use LF
166+ run : |
167+ git config --global core.autocrlf false
168+ git config --global core.eol lf
169+
139170 - uses : actions/checkout@v3
140171
172+ - name : Get composer cache directory
173+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
174+
141175 - name : Cache composer dependencies
142176 uses : actions/cache@v3
143177 with :
144- path : $COMPOSER_CACHE
145- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
146- restore-keys : ${{ runner.os }}-composer-
178+ path : $COMPOSER_CACHE
179+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
180+ restore-keys : ${{ runner.os }}-composer-
147181
148182 - name : Install Composer dependencies
149183 run : composer install --no-progress --prefer-dist --optimize-autoloader
150184
151- - name : Syntax check YAML / XML / JSON
152- run : |
153- bash vendor/bin/check-syntax-yaml.sh
154- bash vendor/bin/check-syntax-xml.sh
155- bash vendor/bin/check-syntax-json.sh
185+ - name : Run unit tests with coverage
186+ if : ${{ matrix.php-versions == '8.1' }}
187+ run : vendor/bin/phpunit
156188
157- quality :
158- name : Quality control
159- runs-on : [ubuntu-latest]
160- needs : [basic-tests]
189+ - name : Run unit tests (no coverage)
190+ if : ${{ matrix.php-versions != '8.1' }}
191+ run : vendor/bin/phpunit --no-coverage
192+
193+ - name : Save coverage data
194+ if : ${{ matrix.php-versions == '8.1' }}
195+ uses : actions/upload-artifact@v3
196+ with :
197+ name : coverage-data
198+ path : ${{ github.workspace }}/build
199+
200+ unit-tests-windows :
201+ name : " Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
202+ runs-on : ${{ matrix.operating-system }}
203+ needs : [linter, quality, security]
204+ strategy :
205+ fail-fast : true
206+ matrix :
207+ operating-system : [windows-latest]
208+ php-versions : ['8.0', '8.1', '8.2']
161209
162210 steps :
163211 - name : Setup PHP, with composer and extensions
164- id : setup-php
165- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
212+ # https://github.com/shivammathur/ setup-php
213+ uses : shivammathur/setup-php@v2
166214 with :
167- php-version : ' 8.0'
215+ php-version : ${{ matrix.php-versions }}
216+ extensions : ctype, spl
168217 tools : composer:v2
169- extensions : mbstring, xml
218+ ini-values : error_reporting=E_ALL
219+ coverage : none
170220
171221 - name : Setup problem matchers for PHP
172222 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
173223
224+ - name : Setup problem matchers for PHPUnit
225+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
226+
227+ - name : Set git to use LF
228+ run : |
229+ git config --global core.autocrlf false
230+ git config --global core.eol lf
231+
174232 - uses : actions/checkout@v3
175233
234+ - name : Get composer cache directory
235+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
236+
176237 - name : Cache composer dependencies
177238 uses : actions/cache@v3
178239 with :
179- path : $COMPOSER_CACHE
180- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181- restore-keys : ${{ runner.os }}-composer-
240+ path : $COMPOSER_CACHE
241+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
242+ restore-keys : ${{ runner.os }}-composer-
182243
183244 - name : Install Composer dependencies
184245 run : composer install --no-progress --prefer-dist --optimize-autoloader
185246
247+ - name : Run unit tests
248+ run : vendor/bin/phpunit --no-coverage
249+
250+ coverage :
251+ name : Code coverage
252+ runs-on : [ubuntu-latest]
253+ needs : [unit-tests-linux]
254+ steps :
186255 - uses : actions/download-artifact@v3
187256 with :
188- name : build -data
257+ name : coverage -data
189258 path : ${{ github.workspace }}/build
190259
191260 - name : Codecov
192261 uses : codecov/codecov-action@v3
193-
194- - name : PHP Code Sniffer
195- continue-on-error : true
196- run : php vendor/bin/phpcs
197-
198- - name : Psalm
199- continue-on-error : true
200- run : php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
201-
202- - name : Psalter
203- continue-on-error : true
204- run : php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}
0 commit comments