Skip to content

Commit afe23e2

Browse files
committed
Replace superlinter with reusable workflows
1 parent 373bacd commit afe23e2

File tree

1 file changed

+115
-116
lines changed

1 file changed

+115
-116
lines changed

.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@v5
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: github/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_JAVASCRIPT_ES: true
36-
VALIDATE_JSON: 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, phpcs, phpstan
54-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, pdo, posix, 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@v5
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, pdo, posix, 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@v5
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.1', '8.2', '8.3', '8.4']
12523

126-
- name: Security check for locked dependencies
127-
run: composer audit
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected]
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/[email protected]
34+
with:
35+
enable_eslinter: true
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
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:
@@ -198,7 +103,7 @@ jobs:
198103
unit-tests-windows:
199104
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
200105
runs-on: ${{ matrix.operating-system }}
201-
needs: [linter, quality, security]
106+
needs: [phplinter, linter]
202107
strategy:
203108
fail-fast: true
204109
matrix:
@@ -246,6 +151,100 @@ jobs:
246151
- name: Run unit tests
247152
run: vendor/bin/phpunit --no-coverage
248153

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

0 commit comments

Comments
 (0)