Skip to content

Commit a6499b3

Browse files
committed
Replace superlinter with reusable workflows
1 parent 25a5bea commit a6499b3

1 file changed

Lines changed: 120 additions & 121 deletions

File tree

.github/workflows/php.yml

Lines changed: 120 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -14,133 +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@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-
# To report GitHub Actions status checks
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
LINTER_RULES_PATH: 'tools/linters'
34-
LOG_LEVEL: NOTICE
35-
VALIDATE_ALL_CODEBASE: true
36-
VALIDATE_JSON: true
37-
# VALIDATE_PHP_BUILTIN: true
38-
VALIDATE_YAML: 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.4'
53-
tools: composer, composer-require-checker, composer-unused, phpcs
54-
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
55-
coverage: none
56-
57-
- name: Setup problem matchers for PHP
58-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
59-
60-
- uses: actions/checkout@v5
61-
62-
- name: Get composer cache directory
63-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
64-
65-
- name: Cache composer dependencies
66-
uses: actions/cache@v4
67-
with:
68-
path: $COMPOSER_CACHE
69-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
70-
restore-keys: ${{ runner.os }}-composer-
71-
72-
- name: Validate composer.json and composer.lock
73-
run: composer validate
74-
75-
- name: Install Composer dependencies
76-
run: composer install --no-progress --prefer-dist --optimize-autoloader
77-
78-
- name: Check code for hard dependencies missing in composer.json
79-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
80-
81-
- name: Check code for unused dependencies in composer.json
82-
run: composer-unused
83-
84-
- name: PHP Code Sniffer
85-
run: phpcs
86-
87-
- name: PHPStan
88-
run: |
89-
vendor/bin/phpstan analyze -c phpstan.neon --debug
90-
91-
- name: PHPStan (testsuite)
92-
run: |
93-
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
94-
95-
- name: Rector
96-
run: |
97-
vendor/bin/rector --dry-run
98-
99-
security:
100-
name: Security checks
101-
runs-on: [ubuntu-latest]
102-
steps:
103-
- name: Setup PHP, with composer and extensions
104-
# https://github.com/shivammathur/setup-php
105-
uses: shivammathur/setup-php@v2
106-
with:
107-
# Should be the lowest supported version
108-
php-version: '8.2'
109-
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
110-
tools: composer
111-
coverage: none
112-
113-
- name: Setup problem matchers for PHP
114-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
115-
116-
- uses: actions/checkout@v5
117-
118-
- name: Get composer cache directory
119-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
120-
121-
- name: Cache composer dependencies
122-
uses: actions/cache@v4
123-
with:
124-
path: $COMPOSER_CACHE
125-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
126-
restore-keys: ${{ runner.os }}-composer-
127-
128-
- name: Install Composer dependencies
129-
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']
13023

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

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

137-
- name: Security check for updated dependencies
138-
run: composer audit
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
13939

14040
unit-tests-linux:
14141
name: "Unit tests, PHP ${{ matrix.php-versions }}, JWT ${{ matrix.jwt-version }}, ${{ matrix.operating-system }}"
14242
runs-on: ${{ matrix.operating-system }}
143-
needs: [linter, quality, security]
43+
needs: [phplinter, linter]
14444
strategy:
14545
fail-fast: false
14646
matrix:
@@ -206,7 +106,7 @@ jobs:
206106
unit-tests-windows:
207107
name: "Unit tests, PHP ${{ matrix.php-versions }}, JWT ${{ matrix.jwt-version }}, ${{ matrix.operating-system }}"
208108
runs-on: ${{ matrix.operating-system }}
209-
needs: [linter, quality, security]
109+
needs: [phplinter, linter]
210110
strategy:
211111
fail-fast: true
212112
matrix:
@@ -257,6 +157,105 @@ jobs:
257157
- name: Run unit tests
258158
run: vendor/bin/phpunit --no-coverage
259159

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

0 commit comments

Comments
 (0)