Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit fd11f72

Browse files
authored
Merge pull request #11 from simplesamlphp/feature/replace-superlinter
Replace super-linter with a reusable workflow
2 parents 038cb6f + e967750 commit fd11f72

1 file changed

Lines changed: 113 additions & 115 deletions

File tree

.github/workflows/php.yml

Lines changed: 113 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,61 @@ 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.2
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@v4
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@v7
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_XML: true
40-
VALIDATE_GITHUB_ACTIONS: true
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
4139

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

4650
steps:
4751
- name: Setup PHP, with composer and extensions
48-
id: setup-php
4952
# https://github.com/shivammathur/setup-php
5053
uses: shivammathur/setup-php@v2
5154
with:
52-
# Should be the higest supported version, so we can use the newest tools
53-
php-version: '8.4'
54-
tools: composer, composer-require-checker, composer-unused, phpcs
55+
php-version: ${{ matrix.php-versions }}
5556
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
56-
coverage: none
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
5760

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

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

6374
- name: Get composer cache directory
@@ -70,50 +81,60 @@ jobs:
7081
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7182
restore-keys: ${{ runner.os }}-composer-
7283

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

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

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

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

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

96-
security:
97-
name: Security checks
98-
runs-on: [ubuntu-latest]
99112
steps:
100113
- name: Setup PHP, with composer and extensions
101114
# https://github.com/shivammathur/setup-php
102115
uses: shivammathur/setup-php@v2
103116
with:
104-
# Should be the lowest supported version
105-
php-version: '8.1'
117+
php-version: ${{ matrix.php-versions }}
106118
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
107119
tools: composer
120+
ini-values: error_reporting=E_ALL
108121
coverage: none
109122

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

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

115136
- name: Get composer cache directory
116-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
117138

118139
- name: Cache composer dependencies
119140
uses: actions/cache@v4
@@ -125,47 +146,28 @@ jobs:
125146
- name: Install Composer dependencies
126147
run: composer install --no-progress --prefer-dist --optimize-autoloader
127148

128-
- name: Security check for locked dependencies
129-
run: composer audit
130-
131-
- name: Update Composer dependencies
132-
run: composer update --no-progress --prefer-dist --optimize-autoloader
133-
134-
- name: Security check for updated dependencies
135-
run: composer audit
149+
- name: Run unit tests
150+
run: vendor/bin/phpunit --no-coverage
136151

137-
unit-tests-linux:
138-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
139-
runs-on: ${{ matrix.operating-system }}
140-
needs: [linter, quality, security]
141-
strategy:
142-
fail-fast: false
143-
matrix:
144-
operating-system: [ubuntu-latest]
145-
php-versions: ['8.1', '8.2', '8.3', '8.4']
152+
quality:
153+
name: Quality control
154+
runs-on: [ubuntu-latest]
146155

147156
steps:
148157
- name: Setup PHP, with composer and extensions
158+
id: setup-php
149159
# https://github.com/shivammathur/setup-php
150160
uses: shivammathur/setup-php@v2
151161
with:
152-
php-version: ${{ matrix.php-versions }}
162+
# Should be the higest supported version, so we can use the newest tools
163+
php-version: '8.4'
164+
tools: composer, composer-require-checker, composer-unused, phpcs
153165
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
154-
tools: composer
155-
ini-values: error_reporting=E_ALL
156-
coverage: pcov
166+
coverage: none
157167

158168
- name: Setup problem matchers for PHP
159169
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
160170

161-
- name: Setup problem matchers for PHPUnit
162-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
163-
164-
- name: Set git to use LF
165-
run: |
166-
git config --global core.autocrlf false
167-
git config --global core.eol lf
168-
169171
- uses: actions/checkout@v4
170172

171173
- name: Get composer cache directory
@@ -178,60 +180,50 @@ jobs:
178180
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
179181
restore-keys: ${{ runner.os }}-composer-
180182

183+
- name: Validate composer.json and composer.lock
184+
run: composer validate
185+
181186
- name: Install Composer dependencies
182187
run: composer install --no-progress --prefer-dist --optimize-autoloader
183188

184-
- name: Run unit tests with coverage
185-
if: ${{ matrix.php-versions == '8.4' }}
186-
run: vendor/bin/phpunit
189+
- name: Check code for hard dependencies missing in composer.json
190+
run: composer-require-checker check composer.json
187191

188-
- name: Run unit tests (no coverage)
189-
if: ${{ matrix.php-versions != '8.4' }}
190-
run: vendor/bin/phpunit --no-coverage
192+
- name: Check code for unused dependencies in composer.json
193+
run: composer-unused
191194

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

199-
unit-tests-windows:
200-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
201-
runs-on: ${{ matrix.operating-system }}
202-
needs: [linter, quality, security]
203-
strategy:
204-
fail-fast: true
205-
matrix:
206-
operating-system: [windows-latest]
207-
php-versions: ['8.1', '8.2', '8.3', '8.4']
198+
- name: PHPStan
199+
run: |
200+
vendor/bin/phpstan analyze -c phpstan.neon
201+
202+
- name: PHPStan (testsuite)
203+
run: |
204+
vendor/bin/phpstan analyze -c phpstan-dev.neon
208205
206+
security:
207+
name: Security checks
208+
runs-on: [ubuntu-latest]
209209
steps:
210210
- name: Setup PHP, with composer and extensions
211211
# https://github.com/shivammathur/setup-php
212212
uses: shivammathur/setup-php@v2
213213
with:
214-
php-version: ${{ matrix.php-versions }}
214+
# Should be the lowest supported version
215+
php-version: '8.1'
215216
extensions: ctype, date, dom, filter, pcre, soap, spl, xml
216217
tools: composer
217-
ini-values: error_reporting=E_ALL
218218
coverage: none
219219

220220
- name: Setup problem matchers for PHP
221221
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
222222

223-
- name: Setup problem matchers for PHPUnit
224-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
225-
226-
- name: Set git to use LF
227-
run: |
228-
git config --global core.autocrlf false
229-
git config --global core.eol lf
230-
231223
- uses: actions/checkout@v4
232224

233225
- name: Get composer cache directory
234-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
226+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
235227

236228
- name: Cache composer dependencies
237229
uses: actions/cache@v4
@@ -243,8 +235,14 @@ jobs:
243235
- name: Install Composer dependencies
244236
run: composer install --no-progress --prefer-dist --optimize-autoloader
245237

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

249247
coverage:
250248
name: Code coverage

0 commit comments

Comments
 (0)