Skip to content

Commit c97c2ff

Browse files
committed
Replace super-linter with a reusable workflow
1 parent 7eaa2c6 commit c97c2ff

2 files changed

Lines changed: 115 additions & 118 deletions

File tree

.github/workflows/php.yml

Lines changed: 113 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,61 @@ on: # yamllint disable-line rule:truthy
1414
workflow_dispatch:
1515

1616
jobs:
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-
# super-linter needs the full git history to get the
25-
# list of files that changed across commits
26-
fetch-depth: 0
27-
28-
- name: Lint Code Base
29-
uses: super-linter/super-linter/slim@v7
30-
env:
31-
SAVE_SUPER_LINTER_OUTPUT: false
32-
# To report GitHub Actions status checks
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
LINTER_RULES_PATH: 'tools/linters'
35-
LOG_LEVEL: NOTICE
36-
VALIDATE_ALL_CODEBASE: true
37-
VALIDATE_BASH: true
38-
VALIDATE_BASH_EXEC: true
39-
VALIDATE_JSON: true
40-
VALIDATE_PHP_BUILTIN: true
41-
VALIDATE_YAML: true
42-
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
4339

44-
quality:
45-
name: Quality control
46-
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']
4749

4850
steps:
4951
- name: Setup PHP, with composer and extensions
50-
id: setup-php
5152
# https://github.com/shivammathur/setup-php
5253
uses: shivammathur/setup-php@v2
5354
with:
54-
# Should be the higest supported version, so we can use the newest tools
55-
php-version: '8.4'
56-
tools: composer, composer-require-checker, composer-unused, phpcs
55+
php-version: ${{ matrix.php-versions }}
5756
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
58-
coverage: none
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
5960

6061
- name: Setup problem matchers for PHP
6162
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6263

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+
6372
- uses: actions/checkout@v4
6473

6574
- name: Get composer cache directory
@@ -72,50 +81,60 @@ jobs:
7281
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7382
restore-keys: ${{ runner.os }}-composer-
7483

75-
- name: Validate composer.json and composer.lock
76-
run: composer validate
77-
7884
- name: Install Composer dependencies
7985
run: composer install --no-progress --prefer-dist --optimize-autoloader
8086

81-
- name: Check code for hard dependencies missing in composer.json
82-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
83-
84-
- name: Check code for unused dependencies in composer.json
85-
run: composer-unused
87+
- name: Run unit tests with coverage
88+
if: ${{ matrix.php-versions == '8.4' }}
89+
run: vendor/bin/phpunit
8690

87-
- name: PHP Code Sniffer
88-
run: phpcs
91+
- name: Run unit tests (no coverage)
92+
if: ${{ matrix.php-versions != '8.4' }}
93+
run: vendor/bin/phpunit --no-coverage
8994

90-
- name: PHPStan
91-
run: |
92-
vendor/bin/phpstan analyze -c phpstan.neon -vv
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
93101

94-
- name: PHPStan (testsuite)
95-
run: |
96-
vendor/bin/phpstan analyze -c phpstan-dev.neon -vv
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']
97111

98-
security:
99-
name: Security checks
100-
runs-on: [ubuntu-latest]
101112
steps:
102113
- name: Setup PHP, with composer and extensions
103114
# https://github.com/shivammathur/setup-php
104115
uses: shivammathur/setup-php@v2
105116
with:
106-
# Should be the lowest supported version
107-
php-version: '8.1'
117+
php-version: ${{ matrix.php-versions }}
108118
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
109119
tools: composer
120+
ini-values: error_reporting=E_ALL
110121
coverage: none
111122

112123
- name: Setup problem matchers for PHP
113124
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
114125

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+
115134
- uses: actions/checkout@v4
116135

117136
- name: Get composer cache directory
118-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
119138

120139
- name: Cache composer dependencies
121140
uses: actions/cache@v4
@@ -127,47 +146,29 @@ jobs:
127146
- name: Install Composer dependencies
128147
run: composer install --no-progress --prefer-dist --optimize-autoloader
129148

130-
- name: Security check for locked dependencies
131-
run: composer audit
132-
133-
- name: Update Composer dependencies
134-
run: composer update --no-progress --prefer-dist --optimize-autoloader
149+
- name: Run unit tests
150+
run: vendor/bin/phpunit --no-coverage
135151

136-
- name: Security check for updated dependencies
137-
run: composer audit
138152

139-
unit-tests-linux:
140-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
141-
runs-on: ${{ matrix.operating-system }}
142-
needs: [linter, quality, security]
143-
strategy:
144-
fail-fast: false
145-
matrix:
146-
operating-system: [ubuntu-latest]
147-
php-versions: ['8.1', '8.2', '8.3', '8.4']
153+
quality:
154+
name: Quality control
155+
runs-on: [ubuntu-latest]
148156

149157
steps:
150158
- name: Setup PHP, with composer and extensions
159+
id: setup-php
151160
# https://github.com/shivammathur/setup-php
152161
uses: shivammathur/setup-php@v2
153162
with:
154-
php-version: ${{ matrix.php-versions }}
163+
# Should be the higest supported version, so we can use the newest tools
164+
php-version: '8.4'
165+
tools: composer, composer-require-checker, composer-unused, phpcs
155166
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
156-
tools: composer
157-
ini-values: error_reporting=E_ALL
158-
coverage: pcov
167+
coverage: none
159168

160169
- name: Setup problem matchers for PHP
161170
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
162171

163-
- name: Setup problem matchers for PHPUnit
164-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
165-
166-
- name: Set git to use LF
167-
run: |
168-
git config --global core.autocrlf false
169-
git config --global core.eol lf
170-
171172
- uses: actions/checkout@v4
172173

173174
- name: Get composer cache directory
@@ -180,60 +181,50 @@ jobs:
180181
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181182
restore-keys: ${{ runner.os }}-composer-
182183

184+
- name: Validate composer.json and composer.lock
185+
run: composer validate
186+
183187
- name: Install Composer dependencies
184188
run: composer install --no-progress --prefer-dist --optimize-autoloader
185189

186-
- name: Run unit tests with coverage
187-
if: ${{ matrix.php-versions == '8.4' }}
188-
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
189192

190-
- name: Run unit tests (no coverage)
191-
if: ${{ matrix.php-versions != '8.4' }}
192-
run: vendor/bin/phpunit --no-coverage
193+
- name: Check code for unused dependencies in composer.json
194+
run: composer-unused
193195

194-
- name: Save coverage data
195-
if: ${{ matrix.php-versions == '8.4' }}
196-
uses: actions/upload-artifact@v4
197-
with:
198-
name: coverage-data
199-
path: ${{ github.workspace }}/build
196+
- name: PHP Code Sniffer
197+
run: phpcs
200198

201-
unit-tests-windows:
202-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
203-
runs-on: ${{ matrix.operating-system }}
204-
needs: [linter, quality, security]
205-
strategy:
206-
fail-fast: true
207-
matrix:
208-
operating-system: [windows-latest]
209-
php-versions: ['8.1', '8.2', '8.3', '8.4']
199+
- name: PHPStan
200+
run: |
201+
vendor/bin/phpstan analyze -c phpstan.neon -vv
202+
203+
- name: PHPStan (testsuite)
204+
run: |
205+
vendor/bin/phpstan analyze -c phpstan-dev.neon -vv
210206
207+
security:
208+
name: Security checks
209+
runs-on: [ubuntu-latest]
211210
steps:
212211
- name: Setup PHP, with composer and extensions
213212
# https://github.com/shivammathur/setup-php
214213
uses: shivammathur/setup-php@v2
215214
with:
216-
php-version: ${{ matrix.php-versions }}
215+
# Should be the lowest supported version
216+
php-version: '8.1'
217217
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
218218
tools: composer
219-
ini-values: error_reporting=E_ALL
220219
coverage: none
221220

222221
- name: Setup problem matchers for PHP
223222
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
224223

225-
- name: Setup problem matchers for PHPUnit
226-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
227-
228-
- name: Set git to use LF
229-
run: |
230-
git config --global core.autocrlf false
231-
git config --global core.eol lf
232-
233224
- uses: actions/checkout@v4
234225

235226
- name: Get composer cache directory
236-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
227+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
237228

238229
- name: Cache composer dependencies
239230
uses: actions/cache@v4
@@ -245,8 +236,14 @@ jobs:
245236
- name: Install Composer dependencies
246237
run: composer install --no-progress --prefer-dist --optimize-autoloader
247238

248-
- name: Run unit tests
249-
run: vendor/bin/phpunit --no-coverage
239+
- name: Security check for locked dependencies
240+
run: composer audit
241+
242+
- name: Update Composer dependencies
243+
run: composer update --no-progress --prefer-dist --optimize-autoloader
244+
245+
- name: Security check for updated dependencies
246+
run: composer audit
250247

251248
coverage:
252249
name: Code coverage

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"php": "^8.1",
1616
"ext-mbstring": "*",
1717

18-
"composer/composer": "~2.8.3",
18+
"composer/composer": "~2.8.9",
1919
"composer-plugin-api": "~2.6.0",
2020
"simplesamlphp/assert": "~1.8.1"
2121
},
2222
"require-dev": {
23-
"simplesamlphp/simplesamlphp-test-framework": "~1.8.0"
23+
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
2424
},
2525
"config": {
2626
"allow-plugins": {

0 commit comments

Comments
 (0)