Skip to content

Commit 90c5287

Browse files
committed
Bump minimum PHP version, replace super-linter
1 parent 2c90f65 commit 90c5287

File tree

14 files changed

+247
-234
lines changed

14 files changed

+247
-234
lines changed

.github/workflows/php.yml

Lines changed: 129 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +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.0
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-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: super-linter/super-linter/slim@v8
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
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.11.0
34+
with:
35+
enable_eslinter: true
36+
enable_jsonlinter: true
37+
enable_stylelinter: true
38+
enable_yamllinter: true
4139

42-
quality:
43-
name: Quality control
44-
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+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
operating-system: [ubuntu-latest]
49+
php-versions: ['8.3', '8.4', '8.5']
4550

4651
steps:
4752
- name: Setup PHP, with composer and extensions
48-
id: setup-php
4953
# https://github.com/shivammathur/setup-php
5054
uses: shivammathur/setup-php@v2
5155
with:
52-
# Should be the higest supported version, so we can use the newest tools
53-
php-version: '8.3'
54-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
55-
# optional performance gain for psalm: opcache
56-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl, pcre, posix, spl, xml
56+
php-version: ${{ matrix.php-versions }}
57+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sodium, spl, xml
58+
tools: composer
59+
ini-values: error_reporting=E_ALL
60+
coverage: pcov
5761

5862
- name: Setup problem matchers for PHP
5963
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
6064

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

6375
- name: Get composer cache directory
@@ -66,120 +78,101 @@ jobs:
6678
- name: Cache composer dependencies
6779
uses: actions/cache@v5
6880
with:
69-
path: $COMPOSER_CACHE
81+
path: ${{ env.COMPOSER_CACHE }}
7082
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7183
restore-keys: ${{ runner.os }}-composer-
7284

73-
- name: Validate composer.json and composer.lock
74-
run: composer validate
75-
7685
- name: Install Composer dependencies
7786
run: composer install --no-progress --prefer-dist --optimize-autoloader
7887

79-
- name: Check code for hard dependencies missing in composer.json
80-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
81-
82-
- name: Check code for unused dependencies in composer.json
83-
run: composer-unused
88+
- name: Run unit tests with coverage
89+
if: ${{ matrix.php-versions == '8.5' }}
90+
run: vendor/bin/phpunit
8491

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

88-
- name: Psalm
89-
continue-on-error: true
90-
run: |
91-
psalm -c psalm.xml \
92-
--show-info=true \
93-
--shepherd \
94-
--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@v6
99+
with:
100+
name: coverage-data
101+
path: ${{ github.workspace }}/build
95102

96-
- name: Psalm (testsuite)
97-
run: |
98-
psalm -c psalm-dev.xml \
99-
--show-info=true \
100-
--shepherd \
101-
--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: [phplinter, linter]
102107

103-
- name: Psalter
104-
run: |
105-
psalm --alter \
106-
--issues=UnnecessaryVarAnnotation \
107-
--dry-run \
108-
--php-version=${{ steps.setup-php.outputs.php-version }}
108+
strategy:
109+
fail-fast: true
110+
matrix:
111+
operating-system: [windows-latest]
112+
php-versions: ['8.3', '8.4', '8.5']
109113

110-
security:
111-
name: Security checks
112-
runs-on: [ubuntu-latest]
113114
steps:
114115
- name: Setup PHP, with composer and extensions
115116
# https://github.com/shivammathur/setup-php
116117
uses: shivammathur/setup-php@v2
117118
with:
118-
# Should be the lowest supported version
119-
php-version: '8.1'
120-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
119+
php-version: ${{ matrix.php-versions }}
120+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl,\
121+
pcre, posix, sodium, spl, xml, zip
121122
tools: composer
123+
ini-values: error_reporting=E_ALL
122124
coverage: none
123125

124126
- name: Setup problem matchers for PHP
125127
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
126128

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

129139
- name: Get composer cache directory
130-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
140+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
131141

132142
- name: Cache composer dependencies
133143
uses: actions/cache@v5
134144
with:
135-
path: $COMPOSER_CACHE
145+
path: ${{ env.COMPOSER_CACHE }}
136146
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
137147
restore-keys: ${{ runner.os }}-composer-
138148

139149
- name: Install Composer dependencies
140-
run: composer install --no-progress --prefer-dist --optimize-autoloader
141-
142-
- name: Security check for locked dependencies
143-
run: composer audit
144-
145-
- name: Update Composer dependencies
146-
run: composer update --no-progress --prefer-dist --optimize-autoloader
150+
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
147151

148-
- name: Security check for updated dependencies
149-
run: composer audit
152+
- name: Run unit tests
153+
run: vendor/bin/phpunit --no-coverage
150154

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

161160
steps:
162161
- name: Setup PHP, with composer and extensions
162+
id: setup-php
163163
# https://github.com/shivammathur/setup-php
164164
uses: shivammathur/setup-php@v2
165165
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
166+
# Should be the higest supported version, so we can use the newest tools
167+
php-version: '8.5'
168+
tools: composer, composer-require-checker, composer-unused
169+
# optional performance gain for psalm: opcache
170+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, opcache, openssl,\
171+
pcre, posix, sodium, spl, xml
171172

172173
- name: Setup problem matchers for PHP
173174
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
174175

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-
183176
- uses: actions/checkout@v6
184177

185178
- name: Get composer cache directory
@@ -188,77 +181,75 @@ jobs:
188181
- name: Cache composer dependencies
189182
uses: actions/cache@v5
190183
with:
191-
path: $COMPOSER_CACHE
184+
path: ${{ env.COMPOSER_CACHE }}
192185
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
193186
restore-keys: ${{ runner.os }}-composer-
194187

188+
- name: Validate composer.json and composer.lock
189+
run: composer validate
190+
195191
- name: Install Composer dependencies
196192
run: composer install --no-progress --prefer-dist --optimize-autoloader
197193

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

202-
- name: Run unit tests (no coverage)
203-
if: ${{ matrix.php-versions != '8.3' }}
204-
run: vendor/bin/phpunit --no-coverage
197+
- name: Check code for unused dependencies in composer.json
198+
run: composer-unused
205199

206-
- name: Save coverage data
207-
if: ${{ matrix.php-versions == '8.3' }}
208-
uses: actions/upload-artifact@v6
209-
with:
210-
name: coverage-data
211-
path: ${{ github.workspace }}/build
200+
- name: PHP Code Sniffer
201+
run: vendor/bin/phpcs
212202

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']
203+
- name: PHPStan
204+
run: |
205+
vendor/bin/phpstan analyze -c phpstan.neon
206+
207+
- name: PHPStan (testsuite)
208+
run: |
209+
vendor/bin/phpstan analyze -c phpstan-dev.neon
210+
211+
security:
212+
name: Security checks
213+
needs: [unit-tests-linux]
214+
runs-on: [ubuntu-latest]
222215

223216
steps:
224217
- name: Setup PHP, with composer and extensions
225218
# https://github.com/shivammathur/setup-php
226219
uses: shivammathur/setup-php@v2
227220
with:
228-
php-version: ${{ matrix.php-versions }}
229-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
221+
# Should be the lowest supported version
222+
php-version: '8.3'
223+
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, sodium, spl, xml
230224
tools: composer
231-
ini-values: error_reporting=E_ALL
232225
coverage: none
233226

234227
- name: Setup problem matchers for PHP
235228
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
236229

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-
245230
- uses: actions/checkout@v6
246231

247232
- name: Get composer cache directory
248-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
233+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
249234

250235
- name: Cache composer dependencies
251236
uses: actions/cache@v5
252237
with:
253-
path: $COMPOSER_CACHE
238+
path: ${{ env.COMPOSER_CACHE }}
254239
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
255240
restore-keys: ${{ runner.os }}-composer-
256241

257242
- name: Install Composer dependencies
258-
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix
243+
run: composer install --no-progress --prefer-dist --optimize-autoloader
259244

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

263254
coverage:
264255
name: Code coverage

codecov.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
---
2+
13
coverage:
24
status:
35
project:
46
default:
57
target: 0%
68
threshold: 2%
7-
patch: off
9+
patch: false
810

911
comment:
1012
layout: "diff"

0 commit comments

Comments
 (0)