Skip to content

Commit 6179809

Browse files
committed
Replace super-linter with a reusable workflow
1 parent 9c00408 commit 6179809

File tree

2 files changed

+129
-131
lines changed

2 files changed

+129
-131
lines changed

.github/workflows/php.yml

Lines changed: 116 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,61 @@ 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
2032

21-
steps:
22-
- uses: actions/checkout@v4
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@v6
30-
env:
31-
# To report GitHub Actions status checks
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
LINTER_RULES_PATH: 'tools/linters'
34-
LOG_LEVEL: NOTICE
35-
VALIDATE_ALL_CODEBASE: true
36-
VALIDATE_BASH: true
37-
VALIDATE_BASH_EXEC: true
38-
VALIDATE_JSON: true
39-
VALIDATE_PHP_BUILTIN: true
40-
VALIDATE_YAML: true
41-
VALIDATE_GITHUB_ACTIONS: true
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
4239

43-
quality:
44-
name: Quality control
45-
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.1', '8.2', '8.3', '8.4']
4649

4750
steps:
4851
- name: Setup PHP, with composer and extensions
49-
id: setup-php
5052
# https://github.com/shivammathur/setup-php
5153
uses: shivammathur/setup-php@v2
5254
with:
53-
# Should be the higest supported version, so we can use the newest tools
54-
php-version: '8.3'
55-
tools: composer, composer-require-checker, composer-unused:0.9.2, phpcs
56-
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
57-
coverage: none
55+
php-version: ${{ matrix.php-versions }}
56+
extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, soap, spl, xml
57+
tools: composer
58+
ini-values: error_reporting=E_ALL
59+
coverage: pcov
5860

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

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+
6272
- uses: actions/checkout@v4
6373

6474
- name: Get composer cache directory
@@ -71,51 +81,60 @@ jobs:
7181
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7282
restore-keys: ${{ runner.os }}-composer-
7383

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

80-
- name: Check code for hard dependencies missing in composer.json
81-
continue-on-error: true
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
87+
- name: Run unit tests with coverage
88+
if: ${{ matrix.php-versions == '8.4' }}
89+
run: vendor/bin/phpunit
8690

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

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

94-
- name: PHPStan (testsuite)
95-
run: |
96-
vendor/bin/phpstan analyze -c phpstan-dev.neon
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', '8.4']
97111

98-
security:
99-
name: Security checks
100-
runs-on: [ubuntu-latest]
101112
steps:
102113
- name: Setup PHP, with composer and extensions
103114
# https://github.com/shivammathur/setup-php
104115
uses: shivammathur/setup-php@v2
105116
with:
106-
# Should be the lowest supported version
107-
php-version: '8.1'
108-
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
117+
php-version: ${{ matrix.php-versions }}
118+
extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, soap, spl, xml
109119
tools: composer
120+
ini-values: error_reporting=E_ALL
110121
coverage: none
111122

112123
- name: Setup problem matchers for PHP
113124
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
114125

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+
115134
- uses: actions/checkout@v4
116135

117136
- name: Get composer cache directory
118-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
137+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
119138

120139
- name: Cache composer dependencies
121140
uses: actions/cache@v4
@@ -127,47 +146,28 @@ jobs:
127146
- name: Install Composer dependencies
128147
run: composer install --no-progress --prefer-dist --optimize-autoloader
129148

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
135-
136-
- name: Security check for updated dependencies
137-
run: composer audit
149+
- name: Run unit tests
150+
run: vendor/bin/phpunit --no-coverage
138151

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']
152+
quality:
153+
name: Quality control
154+
runs-on: [ubuntu-latest]
148155

149156
steps:
150157
- name: Setup PHP, with composer and extensions
158+
id: setup-php
151159
# https://github.com/shivammathur/setup-php
152160
uses: shivammathur/setup-php@v2
153161
with:
154-
php-version: ${{ matrix.php-versions }}
162+
# Should be the higest supported version, so we can use the newest tools
163+
php-version: '8.3'
164+
tools: composer, composer-require-checker, composer-unused:0.9.2, phpcs
155165
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
156-
tools: composer
157-
ini-values: error_reporting=E_ALL
158-
coverage: pcov
166+
coverage: none
159167

160168
- name: Setup problem matchers for PHP
161169
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
162170

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-
171171
- uses: actions/checkout@v4
172172

173173
- name: Get composer cache directory
@@ -180,60 +180,51 @@ jobs:
180180
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181181
restore-keys: ${{ runner.os }}-composer-
182182

183+
- name: Validate composer.json and composer.lock
184+
run: composer validate
185+
183186
- name: Install Composer dependencies
184187
run: composer install --no-progress --prefer-dist --optimize-autoloader
185188

186-
- name: Run unit tests with coverage
187-
if: ${{ matrix.php-versions == '8.3' }}
188-
run: vendor/bin/phpunit
189+
- name: Check code for hard dependencies missing in composer.json
190+
continue-on-error: true
191+
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
189192

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

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

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']
199+
- name: PHPStan
200+
run: |
201+
vendor/bin/phpstan analyze -c phpstan.neon
210202
203+
- name: PHPStan (testsuite)
204+
run: |
205+
vendor/bin/phpstan analyze -c phpstan-dev.neon
206+
207+
security:
208+
name: Security checks
209+
runs-on: [ubuntu-latest]
211210
steps:
212211
- name: Setup PHP, with composer and extensions
213212
# https://github.com/shivammathur/setup-php
214213
uses: shivammathur/setup-php@v2
215214
with:
216-
php-version: ${{ matrix.php-versions }}
215+
# Should be the lowest supported version
216+
php-version: '8.1'
217217
extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml
218218
tools: composer
219-
ini-values: error_reporting=E_ALL
220219
coverage: none
221220

222221
- name: Setup problem matchers for PHP
223222
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
224223

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-
233224
- uses: actions/checkout@v4
234225

235226
- name: Get composer cache directory
236-
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
227+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
237228

238229
- name: Cache composer dependencies
239230
uses: actions/cache@v4
@@ -245,8 +236,14 @@ jobs:
245236
- name: Install Composer dependencies
246237
run: composer install --no-progress --prefer-dist --optimize-autoloader
247238

248-
- name: Run unit tests
249-
run: vendor/bin/phpunit --no-coverage
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
250247

251248
coverage:
252249
name: Code coverage

composer.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@
1818
"ext-pcre": "*",
1919
"ext-zlib": "*",
2020

21-
"nyholm/psr7": "^1.8",
22-
"psr/clock": "^1.0",
23-
"psr/http-message": "^2.0",
24-
"psr/log": "^2.0 || ^3.0",
25-
"simplesamlphp/assert": "^1.1",
26-
"simplesamlphp/xml-common": "^1.16",
27-
"simplesamlphp/xml-security": "^1.6",
28-
"simplesamlphp/xml-soap": "^1.3"
21+
"nyholm/psr7": "~1.8.2",
22+
"psr/clock": "~1.0.0",
23+
"psr/http-message": "~2.0",
24+
"psr/log": "~2.3.1 || ~3.0.0",
25+
"simplesamlphp/assert": "~1.8.1",
26+
"simplesamlphp/xml-common": "~1.24.2",
27+
"simplesamlphp/xml-security": "~1.13.0",
28+
"simplesamlphp/xml-soap": "~1.7.0"
2929
},
3030
"require-dev": {
31-
"beste/clock": "^3.0",
32-
"mockery/mockery": "^1.6",
33-
"simplesamlphp/simplesamlphp-test-framework": "^1.5",
34-
"icanhazstring/composer-unused": "^0.9.3"
31+
"ext-intl": "*",
32+
33+
"beste/clock": "~3.0.0",
34+
"mockery/mockery": "~1.6.12",
35+
"simplesamlphp/simplesamlphp-test-framework": "~1.9.2"
3536
},
3637
"suggest": {
3738
"ext-soap": "*"

0 commit comments

Comments
 (0)