Skip to content

Commit 4687e04

Browse files
committed
Replace super-linter with custom linters
1 parent bb9e3c6 commit 4687e04

File tree

1 file changed

+126
-123
lines changed

1 file changed

+126
-123
lines changed

.github/workflows/php.yml

Lines changed: 126 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,62 @@ 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.3
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@v5
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@v8
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_JSON: true
38-
VALIDATE_PHP_BUILTIN: true
39-
VALIDATE_YAML: true
40-
VALIDATE_XML: true
41-
VALIDATE_GITHUB_ACTIONS: true
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.3
34+
with:
35+
enable_eslinter: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
38+
enable_yamllinter: true
4239

43-
quality:
44-
name: Quality control
45-
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+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
operating-system: [ubuntu-latest]
49+
php-versions: ['8.1', '8.2', '8.3', '8.4']
4650

4751
steps:
4852
- name: Setup PHP, with composer and extensions
49-
id: setup-php
5053
# https://github.com/shivammathur/setup-php
5154
uses: shivammathur/setup-php@v2
5255
with:
53-
# Should be the higest supported version, so we can use the newest tools
54-
php-version: '8.3'
55-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
56-
# optional performance gain for psalm: opcache
57-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
56+
php-version: ${{ matrix.php-versions }}
57+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
58+
tools: composer
59+
ini-values: error_reporting=E_ALL
60+
coverage: pcov
5861

5962
- name: Setup problem matchers for PHP
6063
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6164

65+
- name: Setup problem matchers for PHPUnit
66+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
67+
68+
- name: Set git to use LF
69+
run: |
70+
git config --global core.autocrlf false
71+
git config --global core.eol lf
72+
6273
- uses: actions/checkout@v5
6374

6475
- name: Get composer cache directory
@@ -71,50 +82,60 @@ jobs:
7182
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7283
restore-keys: ${{ runner.os }}-composer-
7384

74-
- name: Validate composer.json and composer.lock
75-
run: composer validate
76-
7785
- name: Install Composer dependencies
7886
run: composer install --no-progress --prefer-dist --optimize-autoloader
7987

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

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

89-
- name: PHPStan
90-
run: |
91-
vendor/bin/phpstan analyze -c phpstan.neon
96+
- name: Save coverage data
97+
if: ${{ matrix.php-versions == '8.4' }}
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: coverage-data
101+
path: ${{ github.workspace }}/build
92102

93-
- name: PHPStan (testsuite)
94-
run: |
95-
vendor/bin/phpstan analyze -c phpstan-dev.neon
103+
unit-tests-windows:
104+
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
105+
runs-on: ${{ matrix.operating-system }}
106+
needs: [phplinter, linter]
107+
strategy:
108+
fail-fast: true
109+
matrix:
110+
operating-system: [windows-latest]
111+
php-versions: ['8.1', '8.2', '8.3', '8.4']
96112

97-
security:
98-
name: Security checks
99-
runs-on: [ubuntu-latest]
100113
steps:
101114
- name: Setup PHP, with composer and extensions
102115
# https://github.com/shivammathur/setup-php
103116
uses: shivammathur/setup-php@v2
104117
with:
105-
# Should be the lowest supported version
106-
php-version: '8.1'
107-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
118+
php-version: ${{ matrix.php-versions }}
119+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml, zip
108120
tools: composer
121+
ini-values: error_reporting=E_ALL
109122
coverage: none
110123

111124
- name: Setup problem matchers for PHP
112125
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
113126

127+
- name: Setup problem matchers for PHPUnit
128+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
129+
130+
- name: Set git to use LF
131+
run: |
132+
git config --global core.autocrlf false
133+
git config --global core.eol lf
134+
114135
- uses: actions/checkout@v5
115136

116137
- name: Get composer cache directory
117-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
138+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
118139

119140
- name: Cache composer dependencies
120141
uses: actions/cache@v4
@@ -124,49 +145,31 @@ jobs:
124145
restore-keys: ${{ runner.os }}-composer-
125146

126147
- name: Install Composer dependencies
127-
run: composer install --no-progress --prefer-dist --optimize-autoloader
128-
129-
- name: Security check for locked dependencies
130-
run: composer audit
131-
132-
- name: Update Composer dependencies
133-
run: composer update --no-progress --prefer-dist --optimize-autoloader
148+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
134149

135-
- name: Security check for updated dependencies
136-
run: composer audit
150+
- name: Run unit tests
151+
run: vendor/bin/phpunit --no-coverage
137152

138-
unit-tests-linux:
139-
name: "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.1', '8.2', '8.3']
153+
quality:
154+
name: Quality control
155+
runs-on: [ubuntu-latest]
156+
needs: [unit-tests-linux]
147157

148158
steps:
149159
- name: Setup PHP, with composer and extensions
160+
id: setup-php
150161
# https://github.com/shivammathur/setup-php
151162
uses: shivammathur/setup-php@v2
152163
with:
153-
php-version: ${{ matrix.php-versions }}
154-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
155-
tools: composer
156-
ini-values: error_reporting=E_ALL
157-
coverage: pcov
164+
# Should be the higest supported version, so we can use the newest tools
165+
php-version: '8.4'
166+
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
167+
# optional performance gain for psalm: opcache
168+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
158169

159170
- name: Setup problem matchers for PHP
160171
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
161172

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-
170173
- uses: actions/checkout@v5
171174

172175
- name: Get composer cache directory
@@ -179,60 +182,52 @@ jobs:
179182
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
180183
restore-keys: ${{ runner.os }}-composer-
181184

185+
- name: Validate composer.json and composer.lock
186+
run: composer validate
187+
182188
- name: Install Composer dependencies
183189
run: composer install --no-progress --prefer-dist --optimize-autoloader
184190

185-
- name: Run unit tests with coverage
186-
if: ${{ matrix.php-versions == '8.3' }}
187-
run: vendor/bin/phpunit
191+
- name: Check code for hard dependencies missing in composer.json
192+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
188193

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

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

200-
unit-tests-windows:
201-
name: "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.1', '8.2', '8.3']
200+
- name: PHPStan
201+
run: |
202+
vendor/bin/phpstan analyze -c phpstan.neon
203+
204+
- name: PHPStan (testsuite)
205+
run: |
206+
vendor/bin/phpstan analyze -c phpstan-dev.neon
207+
208+
security:
209+
name: Security checks
210+
runs-on: [ubuntu-latest]
211+
needs: [unit-tests-linux]
209212

210213
steps:
211214
- name: Setup PHP, with composer and extensions
212215
# https://github.com/shivammathur/setup-php
213216
uses: shivammathur/setup-php@v2
214217
with:
215-
php-version: ${{ matrix.php-versions }}
216-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml, zip
218+
# Should be the lowest supported version
219+
php-version: '8.1'
220+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
217221
tools: composer
218-
ini-values: error_reporting=E_ALL
219222
coverage: none
220223

221224
- name: Setup problem matchers for PHP
222225
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
223226

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-
232227
- uses: actions/checkout@v5
233228

234229
- name: Get composer cache directory
235-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
230+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
236231

237232
- name: Cache composer dependencies
238233
uses: actions/cache@v4
@@ -242,15 +237,22 @@ jobs:
242237
restore-keys: ${{ runner.os }}-composer-
243238

244239
- name: Install Composer dependencies
245-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
240+
run: composer install --no-progress --prefer-dist --optimize-autoloader
246241

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

250251
coverage:
251252
name: Code coverage
252253
runs-on: [ubuntu-latest]
253254
needs: [unit-tests-linux]
255+
254256
steps:
255257
- uses: actions/checkout@v5
256258

@@ -268,8 +270,9 @@ jobs:
268270

269271
cleanup:
270272
name: Cleanup artifacts
271-
needs: [unit-tests-linux, coverage]
272273
runs-on: [ubuntu-latest]
274+
needs: [unit-tests-linux, coverage]
275+
273276
if: |
274277
always() &&
275278
needs.coverage.result == 'success' ||

0 commit comments

Comments
 (0)