Skip to content

Commit 8c21582

Browse files
committed
Replace superlinter with reusable workflows
1 parent 67005de commit 8c21582

File tree

8 files changed

+157
-137
lines changed

8 files changed

+157
-137
lines changed

.github/workflows/php.yml

Lines changed: 115 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -14,128 +14,33 @@ on: # yamllint disable-line rule:truthy
1414
workflow_dispatch:
1515

1616
jobs:
17-
linter:
18-
name: Linter
19-
runs-on: ['ubuntu-latest']
20-
21-
steps:
22-
- uses: actions/checkout@v5
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: github/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_YAML: true
38-
VALIDATE_XML: true
39-
VALIDATE_GITHUB_ACTIONS: true
40-
41-
quality:
42-
name: Quality control
43-
runs-on: [ubuntu-latest]
44-
45-
steps:
46-
- name: Setup PHP, with composer and extensions
47-
id: setup-php
48-
# https://github.com/shivammathur/setup-php
49-
uses: shivammathur/setup-php@v2
50-
with:
51-
# Should be the higest supported version, so we can use the newest tools
52-
php-version: '8.5'
53-
tools: composer, composer-require-checker, composer-unused, phpcs, phpstan
54-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, pdo, posix, spl, xml
55-
56-
- name: Setup problem matchers for PHP
57-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
58-
59-
- uses: actions/checkout@v5
60-
61-
- name: Get composer cache directory
62-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
63-
64-
- name: Cache composer dependencies
65-
uses: actions/cache@v4
66-
with:
67-
path: $COMPOSER_CACHE
68-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
69-
restore-keys: ${{ runner.os }}-composer-
70-
71-
- name: Validate composer.json and composer.lock
72-
run: composer validate
73-
74-
- name: Install Composer dependencies
75-
run: composer install --no-progress --prefer-dist --optimize-autoloader
76-
77-
- name: Check code for hard dependencies missing in composer.json
78-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
79-
80-
- name: Check code for unused dependencies in composer.json
81-
run: composer-unused
82-
83-
- name: PHP Code Sniffer
84-
run: vendor/bin/phpcs
85-
86-
- name: PHPStan
87-
run: |
88-
vendor/bin/phpstan analyze -c phpstan.neon --debug
89-
90-
- name: PHPStan (testsuite)
91-
run: |
92-
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
93-
94-
security:
95-
name: Security checks
96-
runs-on: [ubuntu-latest]
97-
steps:
98-
- name: Setup PHP, with composer and extensions
99-
# https://github.com/shivammathur/setup-php
100-
uses: shivammathur/setup-php@v2
101-
with:
102-
# Should be the lowest supported version
103-
php-version: '8.2'
104-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, pdo, posix, spl, xml
105-
tools: composer
106-
coverage: none
107-
108-
- name: Setup problem matchers for PHP
109-
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
110-
111-
- uses: actions/checkout@v5
112-
113-
- name: Get composer cache directory
114-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
115-
116-
- name: Cache composer dependencies
117-
uses: actions/cache@v4
118-
with:
119-
path: $COMPOSER_CACHE
120-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
121-
restore-keys: ${{ runner.os }}-composer-
122-
123-
- name: Install Composer dependencies
124-
run: composer install --no-progress --prefer-dist --optimize-autoloader
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']
12523

126-
- name: Security check for locked dependencies
127-
run: composer audit
24+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected]
25+
with:
26+
php-version: ${{ matrix.php-version }}
12827

129-
- name: Update Composer dependencies
130-
run: composer update --no-progress --prefer-dist --optimize-autoloader
28+
linter:
29+
name: 'Linter'
30+
strategy:
31+
fail-fast: false
13132

132-
- name: Security check for updated dependencies
133-
run: composer audit
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/[email protected]
34+
with:
35+
enable_eslinter: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
38+
enable_yamllinter: true
13439

13540
unit-tests-linux:
13641
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
13742
runs-on: ${{ matrix.operating-system }}
138-
needs: [linter, quality, security]
43+
needs: [phplinter, linter]
13944
strategy:
14045
fail-fast: false
14146
matrix:
@@ -198,7 +103,7 @@ jobs:
198103
unit-tests-windows:
199104
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
200105
runs-on: ${{ matrix.operating-system }}
201-
needs: [linter, quality, security]
106+
needs: [phplinter, linter]
202107
strategy:
203108
fail-fast: true
204109
matrix:
@@ -246,6 +151,100 @@ jobs:
246151
- name: Run unit tests
247152
run: vendor/bin/phpunit --no-coverage
248153

154+
quality:
155+
name: Quality control
156+
runs-on: [ubuntu-latest]
157+
158+
steps:
159+
- name: Setup PHP, with composer and extensions
160+
id: setup-php
161+
# https://github.com/shivammathur/setup-php
162+
uses: shivammathur/setup-php@v2
163+
with:
164+
# Should be the higest supported version, so we can use the newest tools
165+
php-version: '8.5'
166+
tools: composer, composer-require-checker, composer-unused, phpcs, phpstan
167+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, pdo, posix, spl, xml
168+
169+
- name: Setup problem matchers for PHP
170+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
171+
172+
- uses: actions/checkout@v5
173+
174+
- name: Get composer cache directory
175+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
176+
177+
- name: Cache composer dependencies
178+
uses: actions/cache@v4
179+
with:
180+
path: $COMPOSER_CACHE
181+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
182+
restore-keys: ${{ runner.os }}-composer-
183+
184+
- name: Validate composer.json and composer.lock
185+
run: composer validate
186+
187+
- name: Install Composer dependencies
188+
run: composer install --no-progress --prefer-dist --optimize-autoloader
189+
190+
- name: Check code for hard dependencies missing in composer.json
191+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
192+
193+
- name: Check code for unused dependencies in composer.json
194+
run: composer-unused
195+
196+
- name: PHP Code Sniffer
197+
run: vendor/bin/phpcs
198+
199+
- name: PHPStan
200+
run: |
201+
vendor/bin/phpstan analyze -c phpstan.neon --debug
202+
203+
- name: PHPStan (testsuite)
204+
run: |
205+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
206+
207+
security:
208+
name: Security checks
209+
runs-on: [ubuntu-latest]
210+
steps:
211+
- name: Setup PHP, with composer and extensions
212+
# https://github.com/shivammathur/setup-php
213+
uses: shivammathur/setup-php@v2
214+
with:
215+
# Should be the lowest supported version
216+
php-version: '8.2'
217+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, pdo, posix, spl, xml
218+
tools: composer
219+
coverage: none
220+
221+
- name: Setup problem matchers for PHP
222+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
223+
224+
- uses: actions/checkout@v5
225+
226+
- name: Get composer cache directory
227+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
228+
229+
- name: Cache composer dependencies
230+
uses: actions/cache@v4
231+
with:
232+
path: $COMPOSER_CACHE
233+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
234+
restore-keys: ${{ runner.os }}-composer-
235+
236+
- name: Install Composer dependencies
237+
run: composer install --no-progress --prefer-dist --optimize-autoloader
238+
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
247+
249248
coverage:
250249
name: Code coverage
251250
runs-on: [ubuntu-latest]

phpstan-baseline-dev.neon

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Parameter \\#1 \\$array of function asort expects array, string given\\.$#"
4+
message: '#^Parameter \#1 \$array of function asort expects array, string given\.$#'
5+
identifier: argument.type
56
count: 4
67
path: tests/src/Auth/Source/PasswordVerifyTest.php
78

89
-
9-
message: "#^Property SimpleSAML\\\\Test\\\\Module\\\\sqlauth\\\\Auth\\\\Source\\\\PasswordVerifyTest\\:\\:\\$config \\(array\\<string, string\\|null\\>\\) does not accept array\\<string, array\\<int, string\\>\\|string\\|null\\>\\.$#"
10+
message: '#^Property SimpleSAML\\Test\\Module\\sqlauth\\Auth\\Source\\PasswordVerifyTest\:\:\$config \(array\<string, string\|null\>\) does not accept array\<string, list\<string\>\|string\|null\>\.$#'
11+
identifier: assign.propertyType
1012
count: 4
1113
path: tests/src/Auth/Source/PasswordVerifyTest.php
1214

1315
-
14-
message: "#^Parameter \\#1 \\$array of function asort expects array, mixed given\\.$#"
16+
message: '#^Parameter \#1 \$array of function asort expects array, mixed given\.$#'
17+
identifier: argument.type
1518
count: 4
1619
path: tests/src/Auth/Source/SQLTest.php
1720

1821
-
19-
message: "#^Property SimpleSAML\\\\Test\\\\Module\\\\sqlauth\\\\Auth\\\\Source\\\\SQLTest\\:\\:\\$config \\(array\\<string, string\\|null\\>\\) does not accept array\\<string, array\\<int, string\\>\\|string\\|null\\>\\.$#"
22+
message: '#^Property SimpleSAML\\Test\\Module\\sqlauth\\Auth\\Source\\SQLTest\:\:\$config \(array\<string, string\|null\>\) does not accept array\<string, list\<string\>\|string\|null\>\.$#'
23+
identifier: assign.propertyType
2024
count: 4
2125
path: tests/src/Auth/Source/SQLTest.php

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
parameters:
2-
ignoreErrors:
3-
-
4-
message: "#^Strict comparison using \\=\\=\\= between mixed and null will always evaluate to false\\.$#"
5-
count: 1
6-
path: src/Auth/Source/PasswordVerify.php

src/Auth/Source/PasswordVerify.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimpleSAML\Module\sqlauth\Auth\Source;
66

7+
use SimpleSAML\Assert\Assert;
78
use SimpleSAML\Error;
89
use SimpleSAML\Logger;
910
use SimpleSAML\Module\sqlauth\Auth\Source\SQL;
@@ -50,6 +51,7 @@ class PasswordVerify extends SQL
5051
*/
5152
protected string $passwordhashcolumn = 'passwordhash';
5253

54+
5355
/**
5456
* Constructor for this authentication source.
5557
*
@@ -67,7 +69,6 @@ public function __construct(array $info, array $config)
6769
}
6870

6971

70-
7172
/**
7273
* Attempt to log in using the given username and password.
7374
*
@@ -142,16 +143,7 @@ protected function login(string $username, string $password): array
142143
* This should never happen as the count(data) test above would have already thrown.
143144
* But checking twice doesn't hurt.
144145
*/
145-
if ($pwhash === null) {
146-
if ($pwhash != $row[$this->passwordhashcolumn]) {
147-
Logger::error(sprintf(
148-
'sqlauth:%s: column `%s` does not contain a password hash.',
149-
$this->authId,
150-
$this->passwordhashcolumn,
151-
));
152-
throw new Error\Error('WRONGUSERPASS');
153-
}
154-
}
146+
Assert::notNull($pwhash);
155147

156148
/**
157149
* VERIFICATION!

src/Auth/Source/SQL.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class SQL extends UserPassBase
7070
*/
7171
protected array $query;
7272

73+
7374
/**
7475
* Constructor for this authentication source.
7576
*
@@ -155,6 +156,7 @@ protected function connect(): PDO
155156
return $db;
156157
}
157158

159+
158160
/**
159161
* Extract SQL columns into SAML attribute array
160162
*
@@ -191,6 +193,7 @@ protected function extractAttributes(array &$attributes, array $data, array $for
191193
return $attributes;
192194
}
193195

196+
194197
/**
195198
* Execute the query with given parameters and return the tuples that result.
196199
*
@@ -223,6 +226,7 @@ protected function executeQuery(PDO $db, string $query, array $params): array
223226
}
224227
}
225228

229+
226230
/**
227231
* If there is a username_regex then verify the passed username against it and
228232
* throw an exception if it fails.
@@ -240,6 +244,7 @@ protected function verifyUserNameWithRegex(string $username): void
240244
}
241245
}
242246

247+
243248
/**
244249
* Attempt to log in using the given username and password.
245250
*

0 commit comments

Comments
 (0)