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, simplesamlphp-* ]
11+ branches : [master, simplesamlphp-*]
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_CSS : true
31+ VALIDATE_JAVASCRIPT_ES : true
32+ VALIDATE_JSON : true
33+ VALIDATE_PHP_BUILTIN : true
34+ VALIDATE_YAML : true
35+ VALIDATE_GITHUB_ACTIONS : true
36+
37+ quality :
38+ name : Quality control
39+ runs-on : [ubuntu-latest]
2240
2341 steps :
2442 - name : Setup PHP, with composer and extensions
25- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
43+ id : setup-php
44+ # https://github.com/shivammathur/setup-php
45+ uses : shivammathur/setup-php@v2
2646 with :
27- php-version : ${{ matrix.php-versions }}
28- extensions : intl, mbstring, mysql, pdo, pdo_sqlite, xml
47+ php-version : ' 8.0'
2948 tools : composer:v2
30- ini-values : error_reporting=E_ALL
31- coverage : xdebug
49+ extensions : mbstring, xml
3250
3351 - name : Setup problem matchers for PHP
3452 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3553
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-
4454 - uses : actions/checkout@v3
4555
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
53-
5456 - name : Cache composer dependencies
5557 uses : actions/cache@v3
5658 with :
@@ -64,35 +66,45 @@ jobs:
6466 - name : Install Composer dependencies
6567 run : composer install --no-progress --prefer-dist --optimize-autoloader
6668
67- - name : Syntax check PHP
68- run : bash vendor/bin/check-syntax-php.sh
69+ - name : PHP Code Sniffer
70+ run : php vendor/bin/phpcs
6971
70- - name : Run unit tests with coverage
71- if : ${{ matrix.php-versions == '8.1' && matrix.operating-system == 'ubuntu-latest' }}
72- run : ./vendor/bin/phpunit
72+ - name : Psalm
73+ continue-on-error : true
74+ run : |
75+ php vendor/bin/psalm \
76+ -c psalm.xml \
77+ --show-info=true \
78+ --shepherd \
79+ --php-version=${{ steps.setup-php.outputs.php-version }}
7380
74- - name : Run unit tests (no coverage)
75- if : ${{ matrix.php-versions != '8.1' || matrix.operating-system != 'ubuntu-latest' }}
76- run : ./vendor/bin/phpunit --no-coverage
81+ - name : Psalm (testsuite)
82+ run : |
83+ php vendor/bin/psalm \
84+ -c psalm-dev.xml \
85+ --show-info=true \
86+ --shepherd \
87+ --php-version=${{ steps.setup-php.outputs.php-version }}
7788
78- - name : Save coverage data
79- if : ${{ matrix.php-versions == '8.1' && matrix.operating-system == 'ubuntu-latest' }}
80- uses : actions/upload-artifact@v3
81- with :
82- name : build-data
83- path : ${{ github.workspace }}/build
89+ - name : Psalter
90+ run : |
91+ php vendor/bin/psalter \
92+ --issues=UnnecessaryVarAnnotation \
93+ --dry-run \
94+ --php-version= ${{ steps.setup-php.outputs.php-version }}
8495
8596 security :
8697 name : Security checks
8798 runs-on : [ubuntu-latest]
8899 steps :
89100 - name : Setup PHP, with composer and extensions
90- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
101+ # https://github.com/shivammathur/setup-php
102+ uses : shivammathur/setup-php@v2
91103 with :
92- php-version : ' 8.0'
93- extensions : mbstring, xml
94- tools : composer:v2
95- coverage : none
104+ php-version : ' 8.0'
105+ extensions : mbstring, xml
106+ tools : composer:v2
107+ coverage : none
96108
97109 - name : Setup problem matchers for PHP
98110 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -102,9 +114,9 @@ jobs:
102114 - name : Cache composer dependencies
103115 uses : actions/cache@v3
104116 with :
105- path : $COMPOSER_CACHE
106- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
107- restore-keys : ${{ runner.os }}-composer-
117+ path : $COMPOSER_CACHE
118+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
119+ restore-keys : ${{ runner.os }}-composer-
108120
109121 - name : Install Composer dependencies
110122 run : composer install --no-progress --prefer-dist --optimize-autoloader
@@ -118,89 +130,127 @@ jobs:
118130 - name : Security check for updated dependencies
119131 run : composer audit
120132
121- sanity-check :
122- name : Sanity checks
123- runs-on : [ubuntu-latest]
133+ unit-tests-linux :
134+ name : " Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
135+ runs-on : ${{ matrix.operating-system }}
136+ needs : [linter, quality, security]
137+ strategy :
138+ fail-fast : false
139+ matrix :
140+ operating-system : [ubuntu-latest]
141+ php-versions : ['8.0', '8.1', '8.2']
124142
125143 steps :
126144 - name : Setup PHP, with composer and extensions
127- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
145+ # https://github.com/shivammathur/setup-php
146+ uses : shivammathur/setup-php@v2
128147 with :
129- php-version : ' 8.0 '
130- extensions : mbstring, xml
148+ php-version : ${{ matrix.php-versions }}
149+ extensions : intl, mbstring, mysql, pdo, pdo_sqlite , xml
131150 tools : composer:v2
132- coverage : none
151+ ini-values : error_reporting=E_ALL
152+ coverage : xdebug
133153
134154 - name : Setup problem matchers for PHP
135155 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
136156
157+ - name : Setup problem matchers for PHPUnit
158+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
159+
160+ - name : Set git to use LF
161+ run : |
162+ git config --global core.autocrlf false
163+ git config --global core.eol lf
164+
137165 - uses : actions/checkout@v3
138166
167+ - name : Get composer cache directory
168+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
169+
139170 - name : Cache composer dependencies
140171 uses : actions/cache@v3
141172 with :
142- path : $COMPOSER_CACHE
143- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
144- restore-keys : ${{ runner.os }}-composer-
173+ path : $COMPOSER_CACHE
174+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
175+ restore-keys : ${{ runner.os }}-composer-
145176
146177 - name : Install Composer dependencies
147178 run : composer install --no-progress --prefer-dist --optimize-autoloader
148179
149- - name : Syntax check YAML / XML / JSON
150- run : |
151- bash vendor/bin/check-syntax-yaml.sh
152- bash vendor/bin/check-syntax-xml.sh
153- bash vendor/bin/check-syntax-json.sh
180+ - name : Run unit tests with coverage
181+ if : ${{ matrix.php-versions == '8.1' }}
182+ run : ./vendor/bin/phpunit
154183
155- quality :
156- name : Quality control
157- runs-on : [ubuntu-latest]
158- needs : [basic-tests]
184+ - name : Run unit tests (no coverage)
185+ if : ${{ matrix.php-versions != '8.1' }}
186+ run : ./vendor/bin/phpunit --no-coverage
187+
188+ - name : Save coverage data
189+ if : ${{ matrix.php-versions == '8.1' }}
190+ uses : actions/upload-artifact@v3
191+ with :
192+ name : coverage-data
193+ path : ${{ github.workspace }}/build
194+
195+ unit-tests-windows :
196+ name : " Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
197+ runs-on : ${{ matrix.operating-system }}
198+ needs : [linter, quality, security]
199+ strategy :
200+ fail-fast : true
201+ matrix :
202+ operating-system : [windows-latest]
203+ php-versions : ['8.0', '8.1', '8.2']
159204
160205 steps :
161206 - name : Setup PHP, with composer and extensions
162- id : setup-php
163- uses : shivammathur/setup-php@v2 # https://github.com/shivammathur/setup-php
207+ # https://github.com/shivammathur/ setup-php
208+ uses : shivammathur/setup-php@v2
164209 with :
165- php-version : ' 8.0'
210+ php-version : ${{ matrix.php-versions }}
211+ extensions : intl, mbstring, mysql, pdo, pdo_sqlite, xml
166212 tools : composer:v2
167- extensions : mbstring, xml
213+ ini-values : error_reporting=E_ALL
214+ coverage : xdebug
168215
169216 - name : Setup problem matchers for PHP
170217 run : echo "::add-matcher::${{ runner.tool_cache }}/php.json"
171218
219+ - name : Setup problem matchers for PHPUnit
220+ run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
221+
222+ - name : Set git to use LF
223+ run : |
224+ git config --global core.autocrlf false
225+ git config --global core.eol lf
226+
172227 - uses : actions/checkout@v3
173228
229+ - name : Get composer cache directory
230+ run : echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
231+
174232 - name : Cache composer dependencies
175233 uses : actions/cache@v3
176234 with :
177- path : $COMPOSER_CACHE
178- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
179- restore-keys : ${{ runner.os }}-composer-
235+ path : $COMPOSER_CACHE
236+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
237+ restore-keys : ${{ runner.os }}-composer-
180238
181239 - name : Install Composer dependencies
182240 run : composer install --no-progress --prefer-dist --optimize-autoloader
183241
242+ - name : Run unit tests
243+ run : ./vendor/bin/phpunit --no-coverage
244+
245+ coverage :
246+ name : Code coverage
247+ runs-on : [ubuntu-latest]
248+ needs : [unit-tests-linux]
249+ steps :
184250 - uses : actions/download-artifact@v3
185251 with :
186- name : build -data
252+ name : coverage -data
187253 path : ${{ github.workspace }}/build
188254
189255 - name : Codecov
190256 uses : codecov/codecov-action@v3
191-
192- - name : PHP Code Sniffer
193- continue-on-error : false
194- run : php vendor/bin/phpcs
195-
196- - name : Psalm
197- continue-on-error : true
198- run : php vendor/bin/psalm -c psalm.xml --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
199-
200- - name : Psalm (testsuite)
201- continue-on-error : false
202- run : php vendor/bin/psalm -c psalm-dev.xml --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
203-
204- - name : Psalter
205- continue-on-error : false
206- run : php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}
0 commit comments