Skip to content

Commit f539dd0

Browse files
committed
Replace super-linter with a reusable workflow
1 parent b8506d7 commit f539dd0

File tree

1 file changed

+121
-125
lines changed

1 file changed

+121
-125
lines changed

.github/workflows/php.yml

Lines changed: 121 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -13,137 +13,33 @@ on: # yamllint disable-line rule:truthy
1313
- '**.md'
1414

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

134-
- name: Security check for locked dependencies
135-
run: composer audit
23+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected]
24+
with:
25+
php-version: ${{ matrix.php-version }}
13626

137-
- name: Update Composer dependencies
138-
run: composer update --no-progress --prefer-dist --optimize-autoloader
27+
linter:
28+
name: 'Linter'
29+
strategy:
30+
fail-fast: false
13931

140-
- name: Security check for updated dependencies
141-
run: composer audit
32+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected]
33+
with:
34+
enable_eslinter: false
35+
enable_jsonlinter: true
36+
enable_stylelinter: false
37+
enable_yamllinter: true
14238

14339
unit-tests-linux:
14440
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
14541
runs-on: ${{ matrix.operating-system }}
146-
needs: [linter, quality, security]
42+
needs: [phplinter, linter]
14743
strategy:
14844
fail-fast: false
14945
matrix:
@@ -206,7 +102,7 @@ jobs:
206102
unit-tests-windows:
207103
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
208104
runs-on: ${{ matrix.operating-system }}
209-
needs: [linter, quality, security]
105+
needs: [phplinter, linter]
210106
strategy:
211107
fail-fast: true
212108
matrix:
@@ -254,6 +150,106 @@ jobs:
254150
- name: Run unit tests
255151
run: vendor/bin/phpunit --no-coverage
256152

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

0 commit comments

Comments
 (0)