Skip to content

Commit a37ccd5

Browse files
committed
Replace superlinter with reusable workflows
1 parent 108bbf0 commit a37ccd5

1 file changed

Lines changed: 115 additions & 116 deletions

File tree

.github/workflows/php.yml

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

1616
jobs:
17-
linter:
18-
name: Linter
19-
runs-on: ['ubuntu-latest']
20-
21-
steps:
22-
- uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: super-linter/super-linter/slim@v7
28-
env:
29-
SAVE_SUPER_LINTER_OUTPUT: false
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
LINTER_RULES_PATH: 'tools/linters'
32-
LOG_LEVEL: NOTICE
33-
VALIDATE_ALL_CODEBASE: true
34-
VALIDATE_CSS: true
35-
VALIDATE_JSON: true
36-
VALIDATE_PHP_BUILTIN: true
37-
VALIDATE_YAML: true
38-
VALIDATE_XML: true
39-
VALIDATE_GITHUB_ACTIONS: true
40-
41-
quality:
42-
name: Quality control
43-
runs-on: [ubuntu-latest]
44-
45-
steps:
46-
- name: Setup PHP, with composer and extensions
47-
id: setup-php
48-
# https://github.com/shivammathur/setup-php
49-
uses: shivammathur/setup-php@v2
50-
with:
51-
# Should be the higest supported version, so we can use the newest tools
52-
php-version: '8.5'
53-
tools: composer, composer-require-checker, composer-unused
54-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
55-
56-
- name: Setup problem matchers for PHP
57-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
58-
59-
- uses: actions/checkout@v4
60-
61-
- name: Get composer cache directory
62-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
63-
64-
- name: Cache composer dependencies
65-
uses: actions/cache@v4
66-
with:
67-
path: $COMPOSER_CACHE
68-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
69-
restore-keys: ${{ runner.os }}-composer-
70-
71-
- name: Validate composer.json and composer.lock
72-
run: composer validate
73-
74-
- name: Install Composer dependencies
75-
run: composer install --no-progress --prefer-dist --optimize-autoloader
76-
77-
- name: Check code for hard dependencies missing in composer.json
78-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
79-
80-
- name: Check code for unused dependencies in composer.json
81-
run: composer-unused
82-
83-
- name: PHP Code Sniffer
84-
run: vendor/bin/phpcs
85-
86-
- name: PHPStan
87-
run: |
88-
vendor/bin/phpstan analyze -c phpstan.neon --debug
89-
90-
- name: PHPStan (testsuite)
91-
run: |
92-
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
93-
94-
security:
95-
name: Security checks
96-
runs-on: [ubuntu-latest]
97-
steps:
98-
- name: Setup PHP, with composer and extensions
99-
# https://github.com/shivammathur/setup-php
100-
uses: shivammathur/setup-php@v2
101-
with:
102-
# Should be the lowest supported version
103-
php-version: '8.2'
104-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
105-
tools: composer
106-
coverage: none
107-
108-
- name: Setup problem matchers for PHP
109-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
110-
111-
- uses: actions/checkout@v4
112-
113-
- name: Get composer cache directory
114-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
115-
116-
- name: Cache composer dependencies
117-
uses: actions/cache@v4
118-
with:
119-
path: $COMPOSER_CACHE
120-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
121-
restore-keys: ${{ runner.os }}-composer-
122-
123-
- name: Install Composer dependencies
124-
run: composer install --no-progress --prefer-dist --optimize-autoloader
17+
phplinter:
18+
name: 'PHP-Linter'
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
php-version: ['8.2', '8.3', '8.4', '8.5']
12523

126-
- name: Security check for locked dependencies
127-
run: composer audit
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.10.3
25+
with:
26+
php-version: ${{ matrix.php-version }}
12827

129-
- name: Update Composer dependencies
130-
run: composer update --no-progress --prefer-dist --optimize-autoloader
28+
linter:
29+
name: 'Linter'
30+
strategy:
31+
fail-fast: false
13132

132-
- name: Security check for updated dependencies
133-
run: composer audit
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.3
34+
with:
35+
enable_eslinter: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: true
38+
enable_yamllinter: true
13439

13540
unit-tests-linux:
13641
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
13742
runs-on: ${{ matrix.operating-system }}
138-
needs: [linter, quality, security]
43+
needs: [phplinter, linter]
13944
strategy:
14045
fail-fast: false
14146
matrix:
@@ -197,7 +102,7 @@ jobs:
197102
unit-tests-windows:
198103
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
199104
runs-on: ${{ matrix.operating-system }}
200-
needs: [linter, quality, security]
105+
needs: [phplinter, linter]
201106
strategy:
202107
fail-fast: true
203108
matrix:
@@ -244,6 +149,100 @@ jobs:
244149
- name: Run unit tests
245150
run: vendor/bin/phpunit --no-coverage
246151

152+
quality:
153+
name: Quality control
154+
runs-on: [ubuntu-latest]
155+
156+
steps:
157+
- name: Setup PHP, with composer and extensions
158+
id: setup-php
159+
# https://github.com/shivammathur/setup-php
160+
uses: shivammathur/setup-php@v2
161+
with:
162+
# Should be the higest supported version, so we can use the newest tools
163+
php-version: '8.5'
164+
tools: composer, composer-require-checker, composer-unused
165+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
166+
167+
- name: Setup problem matchers for PHP
168+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
169+
170+
- uses: actions/checkout@v4
171+
172+
- name: Get composer cache directory
173+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
174+
175+
- name: Cache composer dependencies
176+
uses: actions/cache@v4
177+
with:
178+
path: $COMPOSER_CACHE
179+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
180+
restore-keys: ${{ runner.os }}-composer-
181+
182+
- name: Validate composer.json and composer.lock
183+
run: composer validate
184+
185+
- name: Install Composer dependencies
186+
run: composer install --no-progress --prefer-dist --optimize-autoloader
187+
188+
- name: Check code for hard dependencies missing in composer.json
189+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
190+
191+
- name: Check code for unused dependencies in composer.json
192+
run: composer-unused
193+
194+
- name: PHP Code Sniffer
195+
run: vendor/bin/phpcs
196+
197+
- name: PHPStan
198+
run: |
199+
vendor/bin/phpstan analyze -c phpstan.neon --debug
200+
201+
- name: PHPStan (testsuite)
202+
run: |
203+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
204+
205+
security:
206+
name: Security checks
207+
runs-on: [ubuntu-latest]
208+
steps:
209+
- name: Setup PHP, with composer and extensions
210+
# https://github.com/shivammathur/setup-php
211+
uses: shivammathur/setup-php@v2
212+
with:
213+
# Should be the lowest supported version
214+
php-version: '8.2'
215+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, spl, xml
216+
tools: composer
217+
coverage: none
218+
219+
- name: Setup problem matchers for PHP
220+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
221+
222+
- uses: actions/checkout@v4
223+
224+
- name: Get composer cache directory
225+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
226+
227+
- name: Cache composer dependencies
228+
uses: actions/cache@v4
229+
with:
230+
path: $COMPOSER_CACHE
231+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
232+
restore-keys: ${{ runner.os }}-composer-
233+
234+
- name: Install Composer dependencies
235+
run: composer install --no-progress --prefer-dist --optimize-autoloader
236+
237+
- name: Security check for locked dependencies
238+
run: composer audit
239+
240+
- name: Update Composer dependencies
241+
run: composer update --no-progress --prefer-dist --optimize-autoloader
242+
243+
- name: Security check for updated dependencies
244+
run: composer audit
245+
247246
coverage:
248247
name: Code coverage
249248
runs-on: [ubuntu-latest]

0 commit comments

Comments
 (0)