Skip to content

Commit 773198e

Browse files
committed
Bump dependencies & migrate psalm > phpstan
1 parent d9b4756 commit 773198e

6 files changed

Lines changed: 140 additions & 202 deletions

File tree

.github/workflows/php.yml

Lines changed: 125 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +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: true
36+
enable_jsonlinter: true
37+
enable_stylelinter: true
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: [linter, phplinter]
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.3'
57-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
58-
# optional performance gain for psalm: opcache
59-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, 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
6061

6162
- name: Setup problem matchers for PHP
6263
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6364

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+
6473
- uses: actions/checkout@v6
6574

6675
- name: Get composer cache directory
@@ -73,64 +82,61 @@ jobs:
7382
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7483
restore-keys: ${{ runner.os }}-composer-
7584

76-
- name: Validate composer.json and composer.lock
77-
run: composer validate
78-
7985
- name: Install Composer dependencies
8086
run: composer install --no-progress --prefer-dist --optimize-autoloader
8187

82-
- name: Check code for hard dependencies missing in composer.json
83-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
84-
85-
- name: Check code for unused dependencies in composer.json
86-
run: composer-unused
87-
88-
- name: PHP Code Sniffer
89-
run: phpcs
88+
- name: Run unit tests with coverage
89+
if: ${{ matrix.php-versions == '8.5' }}
90+
run: vendor/bin/phpunit
9091

91-
- name: Psalm
92-
continue-on-error: true
93-
run: |
94-
psalm -c psalm.xml \
95-
--show-info=true \
96-
--shepherd \
97-
--php-version=${{ steps.setup-php.outputs.php-version }}
92+
- name: Run unit tests (no coverage)
93+
if: ${{ matrix.php-versions != '8.5' }}
94+
run: vendor/bin/phpunit --no-coverage
9895

99-
- name: Psalm (testsuite)
100-
run: |
101-
psalm -c psalm-dev.xml \
102-
--show-info=true \
103-
--shepherd \
104-
--php-version=${{ steps.setup-php.outputs.php-version }}
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
105102

106-
- name: Psalter
107-
run: |
108-
psalm --alter \
109-
--issues=UnnecessaryVarAnnotation \
110-
--dry-run \
111-
--php-version=${{ steps.setup-php.outputs.php-version }}
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']
112112

113-
security:
114-
name: Security checks
115-
runs-on: [ubuntu-latest]
116113
steps:
117114
- name: Setup PHP, with composer and extensions
118115
# https://github.com/shivammathur/setup-php
119116
uses: shivammathur/setup-php@v2
120117
with:
121-
# Should be the lowest supported version
122-
php-version: '8.1'
123-
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, pcre, posix,\
120+
session, sodium, spl, xml
124121
tools: composer
122+
ini-values: error_reporting=E_ALL
125123
coverage: none
126124

127125
- name: Setup problem matchers for PHP
128126
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
129127

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+
130136
- uses: actions/checkout@v6
131137

132138
- name: Get composer cache directory
133-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
139+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
134140

135141
- name: Cache composer dependencies
136142
uses: actions/cache@v5
@@ -140,49 +146,32 @@ jobs:
140146
restore-keys: ${{ runner.os }}-composer-
141147

142148
- name: Install Composer dependencies
143-
run: composer install --no-progress --prefer-dist --optimize-autoloader
144-
145-
- name: Security check for locked dependencies
146-
run: composer audit
147-
148-
- name: Update Composer dependencies
149-
run: composer update --no-progress --prefer-dist --optimize-autoloader
149+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
150150

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

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

164159
steps:
165160
- name: Setup PHP, with composer and extensions
161+
id: setup-php
166162
# https://github.com/shivammathur/setup-php
167163
uses: shivammathur/setup-php@v2
168164
with:
169-
php-version: ${{ matrix.php-versions }}
170-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
171-
tools: composer
172-
ini-values: error_reporting=E_ALL
173-
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
168+
# optional performance gain for psalm: opcache
169+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl,\
170+
pcre, posix, session, sodium, spl, xml
174171

175172
- name: Setup problem matchers for PHP
176173
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
177174

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-
186175
- uses: actions/checkout@v6
187176

188177
- name: Get composer cache directory
@@ -195,60 +184,52 @@ jobs:
195184
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
196185
restore-keys: ${{ runner.os }}-composer-
197186

187+
- name: Validate composer.json and composer.lock
188+
run: composer validate
189+
198190
- name: Install Composer dependencies
199191
run: composer install --no-progress --prefer-dist --optimize-autoloader
200192

201-
- name: Run unit tests with coverage
202-
if: ${{ matrix.php-versions == '8.3' }}
203-
run: vendor/bin/phpunit
193+
- name: Check code for hard dependencies missing in composer.json
194+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
204195

205-
- name: Run unit tests (no coverage)
206-
if: ${{ matrix.php-versions != '8.3' }}
207-
run: vendor/bin/phpunit --no-coverage
196+
- name: Check code for unused dependencies in composer.json
197+
run: composer-unused
208198

209-
- name: Save coverage data
210-
if: ${{ matrix.php-versions == '8.3' }}
211-
uses: actions/upload-artifact@v7
212-
with:
213-
name: coverage-data
214-
path: ${{ github.workspace }}/build
199+
- name: PHP Code Sniffer
200+
run: vendor/bin/phpcs
215201

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']
202+
- name: PHPStan
203+
run: |
204+
vendor/bin/phpstan analyze -c phpstan.neon
205+
206+
- name: PHPStan (testsuite)
207+
run: |
208+
vendor/bin/phpstan analyze -c phpstan-dev.neon
225209
210+
security:
211+
name: Security checks
212+
needs: [unit-tests-linux]
213+
runs-on: [ubuntu-latest]
226214
steps:
227215
- name: Setup PHP, with composer and extensions
228216
# https://github.com/shivammathur/setup-php
229217
uses: shivammathur/setup-php@v2
230218
with:
231-
php-version: ${{ matrix.php-versions }}
232-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
219+
# Should be the lowest supported version
220+
php-version: '8.3'
221+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl,\
222+
pcre, posix, session, sodium, spl, xml
233223
tools: composer
234-
ini-values: error_reporting=E_ALL
235224
coverage: none
236225

237226
- name: Setup problem matchers for PHP
238227
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
239228

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-
248229
- uses: actions/checkout@v6
249230

250231
- name: Get composer cache directory
251-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
232+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
252233

253234
- name: Cache composer dependencies
254235
uses: actions/cache@v5
@@ -258,10 +239,16 @@ jobs:
258239
restore-keys: ${{ runner.os }}-composer-
259240

260241
- name: Install Composer dependencies
261-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
242+
run: composer install --no-progress --prefer-dist --optimize-autoloader
262243

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

266253
coverage:
267254
name: Code coverage

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
}
3838
},
3939
"require": {
40-
"php": "^8.1",
40+
"php": "^8.3",
4141

42-
"guzzlehttp/guzzle": "^7.8",
43-
"simplesamlphp/assert": "^1.0",
44-
"surfnet/yubikey-api-client": "^2.3",
45-
"symfony/http-foundation": "^6.4"
42+
"guzzlehttp/guzzle": "^7.10",
43+
"simplesamlphp/assert": "^2.0",
44+
"surfnet/yubikey-api-client": "^2.4",
45+
"symfony/http-foundation": "^7.4"
4646
},
4747
"require-dev": {
48-
"simplesamlphp/simplesamlphp": "^2.2",
49-
"simplesamlphp/simplesamlphp-test-framework": "^1.7"
48+
"simplesamlphp/simplesamlphp": "^2.5@dev",
49+
"simplesamlphp/simplesamlphp-test-framework": "^1.11"
5050
},
5151
"support": {
5252
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-authyubikey/issues",

phpstan-dev.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- tests

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src

0 commit comments

Comments
 (0)