Skip to content

Commit f2ba0d9

Browse files
committed
Replace super-linter with a reusable workflow
1 parent 9386d8a commit f2ba0d9

File tree

4 files changed

+150
-134
lines changed

4 files changed

+150
-134
lines changed

.github/workflows/php.yml

Lines changed: 131 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,145 @@ 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
32+
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: true
38+
enable_yamllinter: true
39+
40+
unit-tests-linux:
41+
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
42+
runs-on: ${{ matrix.operating-system }}
43+
needs: [linter, phplinter]
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
operating-system: [ubuntu-latest]
48+
php-versions: ['8.1', '8.2', '8.3', '8.4']
2049

2150
steps:
51+
- name: Setup PHP, with composer and extensions
52+
# https://github.com/shivammathur/setup-php
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: ${{ matrix.php-versions }}
56+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, soap, spl, xml
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
60+
61+
- name: Setup problem matchers for PHP
62+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
63+
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+
2272
- uses: actions/checkout@v4
73+
74+
- name: Get composer cache directory
75+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
76+
77+
- name: Cache composer dependencies
78+
uses: actions/cache@v4
2379
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: github/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_JAVASCRIPT_ES: true
38-
VALIDATE_JSON: true
39-
VALIDATE_PHP_BUILTIN: true
40-
VALIDATE_YAML: true
41-
VALIDATE_XML: true
42-
VALIDATE_GITHUB_ACTIONS: true
80+
path: $COMPOSER_CACHE
81+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
82+
restore-keys: ${{ runner.os }}-composer-
83+
84+
- name: Install Composer dependencies
85+
run: composer install --no-progress --prefer-dist --optimize-autoloader
86+
87+
- name: Run unit tests with coverage
88+
if: ${{ matrix.php-versions == '8.4' }}
89+
run: vendor/bin/phpunit
90+
91+
- name: Run unit tests (no coverage)
92+
if: ${{ matrix.php-versions != '8.4' }}
93+
run: vendor/bin/phpunit --no-coverage
94+
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
101+
102+
unit-tests-windows:
103+
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
104+
runs-on: ${{ matrix.operating-system }}
105+
needs: [linter, phplinter]
106+
strategy:
107+
fail-fast: true
108+
matrix:
109+
operating-system: [windows-latest]
110+
php-versions: ['8.1', '8.2', '8.3', '8.4']
111+
112+
steps:
113+
- name: Setup PHP, with composer and extensions
114+
# https://github.com/shivammathur/setup-php
115+
uses: shivammathur/setup-php@v2
116+
with:
117+
php-version: ${{ matrix.php-versions }}
118+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, soap, spl, xml
119+
tools: composer
120+
ini-values: error_reporting=E_ALL
121+
coverage: none
122+
123+
- name: Setup problem matchers for PHP
124+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
125+
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+
134+
- uses: actions/checkout@v4
135+
136+
- name: Get composer cache directory
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
138+
139+
- name: Cache composer dependencies
140+
uses: actions/cache@v4
141+
with:
142+
path: $COMPOSER_CACHE
143+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
144+
restore-keys: ${{ runner.os }}-composer-
145+
146+
- name: Install Composer dependencies
147+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
148+
149+
- name: Run unit tests
150+
run: vendor/bin/phpunit --no-coverage
43151

44152
quality:
45153
name: Quality control
46154
runs-on: [ubuntu-latest]
155+
needs: [unit-tests-linux]
47156

48157
steps:
49158
- name: Setup PHP, with composer and extensions
@@ -113,6 +222,7 @@ jobs:
113222
security:
114223
name: Security checks
115224
runs-on: [ubuntu-latest]
225+
needs: [unit-tests-linux]
116226
steps:
117227
- name: Setup PHP, with composer and extensions
118228
# https://github.com/shivammathur/setup-php
@@ -151,118 +261,6 @@ jobs:
151261
- name: Security check for updated dependencies
152262
run: composer audit
153263

154-
unit-tests-linux:
155-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
156-
runs-on: ${{ matrix.operating-system }}
157-
needs: [linter, quality, security]
158-
strategy:
159-
fail-fast: false
160-
matrix:
161-
operating-system: [ubuntu-latest]
162-
php-versions: ['8.1', '8.2', '8.3', '8.4']
163-
164-
steps:
165-
- name: Setup PHP, with composer and extensions
166-
# https://github.com/shivammathur/setup-php
167-
uses: shivammathur/setup-php@v2
168-
with:
169-
php-version: ${{ matrix.php-versions }}
170-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, soap, spl, xml
171-
tools: composer
172-
ini-values: error_reporting=E_ALL
173-
coverage: pcov
174-
175-
- name: Setup problem matchers for PHP
176-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
177-
178-
- name: Setup problem matchers for PHPUnit
179-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
180-
181-
- name: Set git to use LF
182-
run: |
183-
git config --global core.autocrlf false
184-
git config --global core.eol lf
185-
186-
- uses: actions/checkout@v4
187-
188-
- name: Get composer cache directory
189-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
190-
191-
- name: Cache composer dependencies
192-
uses: actions/cache@v4
193-
with:
194-
path: $COMPOSER_CACHE
195-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
196-
restore-keys: ${{ runner.os }}-composer-
197-
198-
- name: Install Composer dependencies
199-
run: composer install --no-progress --prefer-dist --optimize-autoloader
200-
201-
- name: Run unit tests with coverage
202-
if: ${{ matrix.php-versions == '8.4' }}
203-
run: vendor/bin/phpunit
204-
205-
- name: Run unit tests (no coverage)
206-
if: ${{ matrix.php-versions != '8.4' }}
207-
run: vendor/bin/phpunit --no-coverage
208-
209-
- name: Save coverage data
210-
if: ${{ matrix.php-versions == '8.4' }}
211-
uses: actions/upload-artifact@v4
212-
with:
213-
name: coverage-data
214-
path: ${{ github.workspace }}/build
215-
216-
unit-tests-windows:
217-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
218-
runs-on: ${{ matrix.operating-system }}
219-
needs: [linter, quality, security]
220-
strategy:
221-
fail-fast: true
222-
matrix:
223-
operating-system: [windows-latest]
224-
php-versions: ['8.1', '8.2', '8.3', '8.4']
225-
226-
steps:
227-
- name: Setup PHP, with composer and extensions
228-
# https://github.com/shivammathur/setup-php
229-
uses: shivammathur/setup-php@v2
230-
with:
231-
php-version: ${{ matrix.php-versions }}
232-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, soap, spl, xml
233-
tools: composer
234-
ini-values: error_reporting=E_ALL
235-
coverage: none
236-
237-
- name: Setup problem matchers for PHP
238-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
239-
240-
- name: Setup problem matchers for PHPUnit
241-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
242-
243-
- name: Set git to use LF
244-
run: |
245-
git config --global core.autocrlf false
246-
git config --global core.eol lf
247-
248-
- uses: actions/checkout@v4
249-
250-
- name: Get composer cache directory
251-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
252-
253-
- name: Cache composer dependencies
254-
uses: actions/cache@v4
255-
with:
256-
path: $COMPOSER_CACHE
257-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
258-
restore-keys: ${{ runner.os }}-composer-
259-
260-
- name: Install Composer dependencies
261-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
262-
263-
- name: Run unit tests
264-
run: vendor/bin/phpunit --no-coverage
265-
266264
coverage:
267265
name: Code coverage
268266
runs-on: [ubuntu-latest]

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"symfony/http-foundation": "^6.4"
5353
},
5454
"require-dev": {
55-
"simplesamlphp/simplesamlphp-test-framework": "~1.8.0"
55+
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
5656
},
5757
"support": {
5858
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-adfs/issues",

tools/linters/.stylelintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"rules": {
3+
}
4+
}

tools/linters/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)