Skip to content

Commit 250c929

Browse files
committed
Migrate superlinter to custom linters and fix CI
1 parent 62584ad commit 250c929

File tree

2 files changed

+128
-127
lines changed

2 files changed

+128
-127
lines changed

.github/workflows/php.yml

Lines changed: 124 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,62 @@ 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.3', '8.4', '8.5']
23+
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.11.1
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@v6
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@v8
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_CSS: true
38-
VALIDATE_JAVASCRIPT_ES: true
39-
VALIDATE_JSON: true
40-
VALIDATE_PHP_BUILTIN: true
41-
VALIDATE_YAML: true
42-
VALIDATE_XML: true
43-
VALIDATE_GITHUB_ACTIONS: true
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.11.1
34+
with:
35+
enable_eslinter: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
38+
enable_yamllinter: true
4439

45-
quality:
46-
name: Quality control
47-
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.3', '8.4', '8.5']
4849

4950
steps:
5051
- name: Setup PHP, with composer and extensions
51-
id: setup-php
5252
# https://github.com/shivammathur/setup-php
5353
uses: shivammathur/setup-php@v2
5454
with:
55-
# Should be the higest supported version, so we can use the newest tools
56-
php-version: '8.4'
57-
tools: composer, composer-require-checker, composer-unused, phpcs, phpstan
58-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
55+
php-version: ${{ matrix.php-versions }}
56+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl,\
57+
pcre, posix, session, sodium, spl, xml
58+
tools: composer
59+
ini-values: error_reporting=E_ALL
60+
coverage: pcov
5961

6062
- name: Setup problem matchers for PHP
6163
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6264

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

6575
- name: Get composer cache directory
@@ -72,50 +82,61 @@ jobs:
7282
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7383
restore-keys: ${{ runner.os }}-composer-
7484

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

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

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

90-
- name: PHPStan
91-
run: |
92-
vendor/bin/phpstan analyze -c phpstan.neon --debug
96+
- name: Save coverage data
97+
if: ${{ matrix.php-versions == '8.5' }}
98+
uses: actions/upload-artifact@v7
99+
with:
100+
name: coverage-data
101+
path: ${{ github.workspace }}/build
93102

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

98-
security:
99-
name: Security checks
100-
runs-on: [ubuntu-latest]
101113
steps:
102114
- name: Setup PHP, with composer and extensions
103115
# https://github.com/shivammathur/setup-php
104116
uses: shivammathur/setup-php@v2
105117
with:
106-
# Should be the lowest supported version
107-
php-version: '8.1'
108-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
118+
php-version: ${{ matrix.php-versions }}
119+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl,\
120+
pcre, posix, session, sodium, spl, xml
109121
tools: composer
122+
ini-values: error_reporting=E_ALL
110123
coverage: none
111124

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

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

117138
- name: Get composer cache directory
118-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
139+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
119140

120141
- name: Cache composer dependencies
121142
uses: actions/cache@v5
@@ -125,49 +146,31 @@ jobs:
125146
restore-keys: ${{ runner.os }}-composer-
126147

127148
- name: Install Composer dependencies
128-
run: composer install --no-progress --prefer-dist --optimize-autoloader
129-
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
149+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
135150

136-
- name: Security check for updated dependencies
137-
run: composer audit
151+
- name: Run unit tests
152+
run: vendor/bin/phpunit --no-coverage
138153

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']
154+
quality:
155+
name: Quality control
156+
needs: [unit-tests-linux]
157+
runs-on: [ubuntu-latest]
148158

149159
steps:
150160
- name: Setup PHP, with composer and extensions
161+
id: setup-php
151162
# https://github.com/shivammathur/setup-php
152163
uses: shivammathur/setup-php@v2
153164
with:
154-
php-version: ${{ matrix.php-versions }}
155-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
156-
tools: composer
157-
ini-values: error_reporting=E_ALL
158-
coverage: pcov
165+
# Should be the higest supported version, so we can use the newest tools
166+
php-version: '8.5'
167+
tools: composer, composer-require-checker, composer-unused, phpcs
168+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl,\
169+
pcre, posix, session, sodium, spl, xml
159170

160171
- name: Setup problem matchers for PHP
161172
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
162173

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-
171174
- uses: actions/checkout@v6
172175

173176
- name: Get composer cache directory
@@ -180,60 +183,52 @@ jobs:
180183
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181184
restore-keys: ${{ runner.os }}-composer-
182185

186+
- name: Validate composer.json and composer.lock
187+
run: composer validate
188+
183189
- name: Install Composer dependencies
184190
run: composer install --no-progress --prefer-dist --optimize-autoloader
185191

186-
- name: Run unit tests with coverage
187-
if: ${{ matrix.php-versions == '8.4' }}
188-
run: vendor/bin/phpunit
192+
- name: Check code for hard dependencies missing in composer.json
193+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
189194

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

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

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']
201+
- name: PHPStan
202+
run: |
203+
vendor/bin/phpstan analyze -c phpstan.neon --debug
210204
205+
- name: PHPStan (testsuite)
206+
run: |
207+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
208+
209+
security:
210+
name: Security checks
211+
needs: [unit-tests-linux]
212+
runs-on: [ubuntu-latest]
211213
steps:
212214
- name: Setup PHP, with composer and extensions
213215
# https://github.com/shivammathur/setup-php
214216
uses: shivammathur/setup-php@v2
215217
with:
216-
php-version: ${{ matrix.php-versions }}
217-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
218+
# Should be the lowest supported version
219+
php-version: '8.3'
220+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix,\
221+
session, sodium, spl, xml
218222
tools: composer
219-
ini-values: error_reporting=E_ALL
220223
coverage: none
221224

222225
- name: Setup problem matchers for PHP
223226
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
224227

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-
233228
- uses: actions/checkout@v6
234229

235230
- name: Get composer cache directory
236-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
231+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
237232

238233
- name: Cache composer dependencies
239234
uses: actions/cache@v5
@@ -243,10 +238,16 @@ jobs:
243238
restore-keys: ${{ runner.os }}-composer-
244239

245240
- name: Install Composer dependencies
246-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
241+
run: composer install --no-progress --prefer-dist --optimize-autoloader
247242

248-
- name: Run unit tests
249-
run: vendor/bin/phpunit --no-coverage
243+
- name: Security check for locked dependencies
244+
run: composer audit
245+
246+
- name: Update Composer dependencies
247+
run: composer update --no-progress --prefer-dist --optimize-autoloader
248+
249+
- name: Security check for updated dependencies
250+
run: composer audit
250251

251252
coverage:
252253
name: Code coverage

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
}
3535
},
3636
"require": {
37-
"php": "^8.1",
37+
"php": "^8.3",
3838

39-
"simplesamlphp/assert": "^1.0",
40-
"simplesamlphp/simplesamlphp": "^2.1",
39+
"simplesamlphp/assert": "^3.0",
40+
"simplesamlphp/simplesamlphp": "^2.5@dev",
4141
"whitehat101/apr1-md5": "~1.0"
4242
},
4343
"require-dev": {
44-
"simplesamlphp/simplesamlphp-test-framework": "^1.5"
44+
"simplesamlphp/simplesamlphp-test-framework": "^1.11"
4545
},
4646
"support": {
4747
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-authcrypt/issues",

0 commit comments

Comments
 (0)