Skip to content

Commit b72afe2

Browse files
committed
Replace super-linter with a reusable workflow
1 parent 8c8262f commit b72afe2

File tree

3 files changed

+137
-116
lines changed

3 files changed

+137
-116
lines changed

.github/workflows/php.yml

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +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-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: super-linter/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_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: true
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.3'
54-
tools: composer, composer-require-checker, composer-unused, phpcs
55+
php-version: ${{ matrix.php-versions }}
5556
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, posix, spl, xml
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
5660

5761
- name: Setup problem matchers for PHP
5862
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
5963

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

6274
- name: Get composer cache directory
@@ -69,50 +81,60 @@ jobs:
6981
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7082
restore-keys: ${{ runner.os }}-composer-
7183

72-
- name: Validate composer.json and composer.lock
73-
run: composer validate
74-
7584
- name: Install Composer dependencies
7685
run: composer install --no-progress --prefer-dist --optimize-autoloader
7786

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
87+
- name: Run unit tests with coverage
88+
if: ${{ matrix.php-versions == '8.3' }}
89+
run: vendor/bin/phpunit
8390

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

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

91-
- name: PHPStan (testsuite)
92-
run: |
93-
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
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']
94111

95-
security:
96-
name: Security checks
97-
runs-on: [ubuntu-latest]
98112
steps:
99113
- name: Setup PHP, with composer and extensions
100114
# https://github.com/shivammathur/setup-php
101115
uses: shivammathur/setup-php@v2
102116
with:
103-
# Should be the lowest supported version
104-
php-version: '8.1'
117+
php-version: ${{ matrix.php-versions }}
105118
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, posix, spl, xml
106119
tools: composer
120+
ini-values: error_reporting=E_ALL
107121
coverage: none
108122

109123
- name: Setup problem matchers for PHP
110124
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
111125

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

114136
- name: Get composer cache directory
115-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
116138

117139
- name: Cache composer dependencies
118140
uses: actions/cache@v4
@@ -122,49 +144,30 @@ jobs:
122144
restore-keys: ${{ runner.os }}-composer-
123145

124146
- name: Install Composer dependencies
125-
run: composer install --no-progress --prefer-dist --optimize-autoloader
126-
127-
- name: Security check for locked dependencies
128-
run: composer audit
129-
130-
- name: Update Composer dependencies
131-
run: composer update --no-progress --prefer-dist --optimize-autoloader
147+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
132148

133-
- name: Security check for updated dependencies
134-
run: composer audit
149+
- name: Run unit tests
150+
run: vendor/bin/phpunit --no-coverage
135151

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

146157
steps:
147158
- name: Setup PHP, with composer and extensions
159+
id: setup-php
148160
# https://github.com/shivammathur/setup-php
149161
uses: shivammathur/setup-php@v2
150162
with:
151-
php-version: ${{ matrix.php-versions }}
163+
# Should be the higest supported version, so we can use the newest tools
164+
php-version: '8.3'
165+
tools: composer, composer-require-checker, composer-unused, phpcs
152166
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, posix, spl, xml
153-
tools: composer
154-
ini-values: error_reporting=E_ALL
155-
coverage: pcov
156167

157168
- name: Setup problem matchers for PHP
158169
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
159170

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

170173
- name: Get composer cache directory
@@ -177,60 +180,51 @@ jobs:
177180
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
178181
restore-keys: ${{ runner.os }}-composer-
179182

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

183-
- name: Run unit tests with coverage
184-
if: ${{ matrix.php-versions == '8.3' }}
185-
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
186191

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

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

198-
unit-tests-windows:
199-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
200-
runs-on: ${{ matrix.operating-system }}
201-
needs: [linter, quality, security]
202-
strategy:
203-
fail-fast: true
204-
matrix:
205-
operating-system: [windows-latest]
206-
php-versions: ['8.1', '8.2', '8.3']
198+
- name: PHPStan
199+
run: |
200+
vendor/bin/phpstan analyze -c phpstan.neon --debug
201+
202+
- name: PHPStan (testsuite)
203+
run: |
204+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
207205
206+
security:
207+
name: Security checks
208+
runs-on: [ubuntu-latest]
209+
needs: [unit-tests-linux]
208210
steps:
209211
- name: Setup PHP, with composer and extensions
210212
# https://github.com/shivammathur/setup-php
211213
uses: shivammathur/setup-php@v2
212214
with:
213-
php-version: ${{ matrix.php-versions }}
215+
# Should be the lowest supported version
216+
php-version: '8.1'
214217
extensions: ctype, date, dom, fileinfo, filter, hash, intl, ldap, mbstring, openssl, pcre, posix, spl, xml
215218
tools: composer
216-
ini-values: error_reporting=E_ALL
217219
coverage: none
218220

219221
- name: Setup problem matchers for PHP
220222
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
221223

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

232226
- name: Get composer cache directory
233-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
227+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
234228

235229
- name: Cache composer dependencies
236230
uses: actions/cache@v4
@@ -240,10 +234,16 @@ jobs:
240234
restore-keys: ${{ runner.os }}-composer-
241235

242236
- name: Install Composer dependencies
243-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
237+
run: composer install --no-progress --prefer-dist --optimize-autoloader
244238

245-
- name: Run unit tests
246-
run: vendor/bin/phpunit --no-coverage
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
247247

248248
coverage:
249249
name: Code coverage

tools/.yaml-lint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
extends: default
4+
5+
rules:
6+
line-length:
7+
max: 120

tools/eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// eslint.config.js
2+
const { defineConfig } = require("eslint/config");
3+
4+
module.exports = defineConfig([
5+
{
6+
files: [
7+
"**/*.js",
8+
],
9+
rules: {
10+
semi: "error",
11+
"prefer-const": "error"
12+
}
13+
}
14+
]);

0 commit comments

Comments
 (0)