Skip to content

Commit 765b414

Browse files
authored
Merge pull request #7 from simplesamlphp/feature/replace-superlinter
Replace super-linter with a reusable workflow
2 parents 380601a + 8ef6a0b commit 765b414

2 files changed

Lines changed: 119 additions & 123 deletions

File tree

.github/workflows/php.yml

Lines changed: 113 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +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-
SAVE_SUPER_LINTER_OUTPUT: false
32-
# To report GitHub Actions status checks
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
LINTER_RULES_PATH: 'tools/linters'
35-
LOG_LEVEL: NOTICE
36-
VALIDATE_ALL_CODEBASE: true
37-
VALIDATE_BASH: true
38-
VALIDATE_BASH_EXEC: true
39-
VALIDATE_JSON: true
40-
VALIDATE_PHP_BUILTIN: true
41-
VALIDATE_YAML: true
42-
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
4339

44-
quality:
45-
name: Quality control
46-
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']
4749

4850
steps:
4951
- name: Setup PHP, with composer and extensions
50-
id: setup-php
5152
# https://github.com/shivammathur/setup-php
5253
uses: shivammathur/setup-php@v2
5354
with:
54-
# Should be the higest supported version, so we can use the newest tools
55-
php-version: '8.4'
56-
tools: composer, composer-require-checker, composer-unused, phpcs
55+
php-version: ${{ matrix.php-versions }}
5756
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
58-
coverage: none
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
5960

6061
- name: Setup problem matchers for PHP
6162
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6263

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+
6372
- uses: actions/checkout@v4
6473

6574
- name: Get composer cache directory
@@ -72,50 +81,60 @@ jobs:
7281
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7382
restore-keys: ${{ runner.os }}-composer-
7483

75-
- name: Validate composer.json and composer.lock
76-
run: composer validate
77-
7884
- name: Install Composer dependencies
7985
run: composer install --no-progress --prefer-dist --optimize-autoloader
8086

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

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

90-
- name: PHPStan
91-
run: |
92-
vendor/bin/phpstan analyze -c phpstan.neon -vv
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
93101

94-
- name: PHPStan (testsuite)
95-
run: |
96-
vendor/bin/phpstan analyze -c phpstan-dev.neon -vv
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']
97111

98-
security:
99-
name: Security checks
100-
runs-on: [ubuntu-latest]
101112
steps:
102113
- name: Setup PHP, with composer and extensions
103114
# https://github.com/shivammathur/setup-php
104115
uses: shivammathur/setup-php@v2
105116
with:
106-
# Should be the lowest supported version
107-
php-version: '8.1'
117+
php-version: ${{ matrix.php-versions }}
108118
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
109119
tools: composer
120+
ini-values: error_reporting=E_ALL
110121
coverage: none
111122

112123
- name: Setup problem matchers for PHP
113124
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
114125

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+
115134
- uses: actions/checkout@v4
116135

117136
- name: Get composer cache directory
118-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
119138

120139
- name: Cache composer dependencies
121140
uses: actions/cache@v4
@@ -127,47 +146,28 @@ jobs:
127146
- name: Install Composer dependencies
128147
run: composer install --no-progress --prefer-dist --optimize-autoloader
129148

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

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

149156
steps:
150157
- name: Setup PHP, with composer and extensions
158+
id: setup-php
151159
# https://github.com/shivammathur/setup-php
152160
uses: shivammathur/setup-php@v2
153161
with:
154-
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
155165
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
156-
tools: composer
157-
ini-values: error_reporting=E_ALL
158-
coverage: pcov
166+
coverage: none
159167

160168
- name: Setup problem matchers for PHP
161169
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
162170

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

173173
- name: Get composer cache directory
@@ -180,60 +180,50 @@ jobs:
180180
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181181
restore-keys: ${{ runner.os }}-composer-
182182

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

186-
- name: Run unit tests with coverage
187-
if: ${{ matrix.php-versions == '8.4' }}
188-
run: vendor/bin/phpunit
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
189191

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

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

201-
unit-tests-windows:
202-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
203-
runs-on: ${{ matrix.operating-system }}
204-
needs: [linter, quality, security]
205-
strategy:
206-
fail-fast: true
207-
matrix:
208-
operating-system: [windows-latest]
209-
php-versions: ['8.1', '8.2', '8.3', '8.4']
198+
- name: PHPStan
199+
run: |
200+
vendor/bin/phpstan analyze -c phpstan.neon -vv
201+
202+
- name: PHPStan (testsuite)
203+
run: |
204+
vendor/bin/phpstan analyze -c phpstan-dev.neon -vv
210205
206+
security:
207+
name: Security checks
208+
runs-on: [ubuntu-latest]
211209
steps:
212210
- name: Setup PHP, with composer and extensions
213211
# https://github.com/shivammathur/setup-php
214212
uses: shivammathur/setup-php@v2
215213
with:
216-
php-version: ${{ matrix.php-versions }}
214+
# Should be the lowest supported version
215+
php-version: '8.1'
217216
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
218217
tools: composer
219-
ini-values: error_reporting=E_ALL
220218
coverage: none
221219

222220
- name: Setup problem matchers for PHP
223221
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
224222

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

235225
- name: Get composer cache directory
236-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
226+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
237227

238228
- name: Cache composer dependencies
239229
uses: actions/cache@v4
@@ -245,8 +235,14 @@ jobs:
245235
- name: Install Composer dependencies
246236
run: composer install --no-progress --prefer-dist --optimize-autoloader
247237

248-
- name: Run unit tests
249-
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
250246

251247
coverage:
252248
name: Code coverage

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
"ext-filter": "*",
1616
"ext-pcre": "*",
1717

18-
"psr/clock": "^1.0",
19-
"psr/log": "^2.0 | ^3.0",
20-
"simplesamlphp/assert": "^1.8",
21-
"simplesamlphp/xml-common": "~1.24.0",
18+
"psr/clock": "~1.0.0",
19+
"psr/log": "~2.3.1 | ~3.0.0",
20+
"simplesamlphp/assert": "~1.8.1",
21+
"simplesamlphp/xml-common": "~1.24.2",
2222
"simplesamlphp/xml-security": "~1.13.0"
2323
},
2424
"require-dev": {
25-
"beste/clock": "^3.0",
26-
"simplesamlphp/simplesamlphp-test-framework": "^1.8"
25+
"beste/clock": "~3.0.0",
26+
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
2727
},
2828
"autoload": {
2929
"psr-4": {

0 commit comments

Comments
 (0)