Skip to content

Commit 2aa22ec

Browse files
committed
Replace super-linter with a reusable workflow
1 parent bffd06f commit 2aa22ec

File tree

4 files changed

+156
-137
lines changed

4 files changed

+156
-137
lines changed

.github/workflows/php.yml

Lines changed: 133 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +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: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
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: [phplinter, linter]
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
operating-system: [ubuntu-latest]
48+
php-versions: ['8.1', '8.2', '8.3']
49+
50+
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, 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+
72+
- 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
79+
with:
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.3' }}
89+
run: vendor/bin/phpunit
90+
91+
- name: Run unit tests (no coverage)
92+
if: ${{ matrix.php-versions != '8.3' }}
93+
run: vendor/bin/phpunit --no-coverage
94+
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
101+
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']
20111

21112
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, posix, 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+
22134
- 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
23141
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
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
41151

42152
quality:
43153
name: Quality control
44154
runs-on: [ubuntu-latest]
155+
needs: [unit-tests-linux]
45156

46157
steps:
47158
- name: Setup PHP, with composer and extensions
@@ -110,6 +221,8 @@ jobs:
110221
security:
111222
name: Security checks
112223
runs-on: [ubuntu-latest]
224+
needs: [unit-tests-linux]
225+
113226
steps:
114227
- name: Setup PHP, with composer and extensions
115228
# https://github.com/shivammathur/setup-php
@@ -148,122 +261,11 @@ jobs:
148261
- name: Security check for updated dependencies
149262
run: composer audit
150263

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

routing/routes/routes.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
---
2+
13
consentsimpleadmin-admin:
2-
path: /admin
3-
defaults: { _controller: 'SimpleSAML\Module\consentsimpleadmin\Controller\Admin::admin' }
4-
methods: [GET]
4+
path: /admin
5+
defaults: {
6+
_controller: 'SimpleSAML\Module\consentsimpleadmin\Controller\Admin::admin'
7+
}
8+
methods: [GET]
59

610
consentsimpleadmin-stats:
7-
path: /stats
8-
defaults: { _controller: 'SimpleSAML\Module\consentsimpleadmin\Controller\Stats::stats' }
9-
methods: [GET]
11+
path: /stats
12+
defaults: {
13+
_controller: 'SimpleSAML\Module\consentsimpleadmin\Controller\Stats::stats'
14+
}
15+
methods: [GET]

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/.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

0 commit comments

Comments
 (0)