Skip to content

Commit 83762d1

Browse files
committed
Update the workflow and tests; support > 2.3
1 parent 14619f7 commit 83762d1

13 files changed

Lines changed: 185 additions & 231 deletions

File tree

.github/dependabot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
# To get started with Dependabot version updates, you'll need to specify which
4+
# package ecosystems to update and where the package manifests are located.
5+
# Please see the documentation for all configuration options:
6+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
7+
8+
version: 2
9+
updates:
10+
- package-ecosystem: "github-actions" # See documentation for possible values
11+
directory: "/" # Location of package manifests
12+
schedule:
13+
interval: "monthly"
14+
groups:
15+
all-actions:
16+
patterns: ["*"]
17+
18+
- package-ecosystem: "composer" # See documentation for possible values
19+
directory: "/" # Location of package manifests
20+
schedule:
21+
interval: "monthly"
22+
allow:
23+
# Allow both direct and indirect updates for all packages
24+
- dependency-type: "all"
25+
ignore:
26+
- dependency-name: "*"
27+
update-types: ["version-update:semver-major"]
28+
groups:
29+
production-dependencies:
30+
dependency-type: "production"
31+
exclude-patterns:
32+
- "symfony/*"
33+
- "simplesamlphp/*"
34+
development-dependencies:
35+
dependency-type: "development"
36+
simplesamlphp:
37+
patterns:
38+
- "simplesamlphp/*"
39+
symfony:
40+
patterns:
41+
- "symfony/*"

.github/workflows/php.yml

Lines changed: 99 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,68 @@ on: # yamllint disable-line rule:truthy
88
paths-ignore:
99
- '**.md'
1010
pull_request:
11-
branches: [master, release-*]
11+
branches: [main, release-*]
1212
paths-ignore:
1313
- '**.md'
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.10.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@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Lint Code Base
27-
uses: github/super-linter/slim@v4
28-
env:
29-
LOG_LEVEL: NOTICE
30-
VALIDATE_ALL_CODEBASE: true
31-
LINTER_RULES_PATH: 'tools/linters'
32-
VALIDATE_CSS: true
33-
VALIDATE_JAVASCRIPT_ES: true
34-
VALIDATE_JSON: true
35-
VALIDATE_PHP_BUILTIN: true
36-
VALIDATE_YAML: true
37-
VALIDATE_XML: true
38-
VALIDATE_GITHUB_ACTIONS: true
39-
GITHUB_ACTIONS_COMMAND_ARGS: '-ignore SC2016:'
33+
uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.10.0
34+
with:
35+
enable_eslinter: false
36+
enable_jsonlinter: true
37+
enable_stylelinter: false
38+
enable_yamllinter: true
4039

41-
quality:
42-
name: Quality control
43-
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']
4449

4550
steps:
4651
- name: Setup PHP, with composer and extensions
47-
id: setup-php
4852
# https://github.com/shivammathur/setup-php
4953
uses: shivammathur/setup-php@v2
5054
with:
51-
# Should be the higest supported version, so we can use the newest tools
52-
php-version: '8.2'
53-
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
54-
# optional performance gain for psalm: opcache
55-
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, pcre, posix, spl, xdebug, xml
57+
tools: composer
58+
ini-values: error_reporting=E_ALL, pcov.directory=.
59+
coverage: pcov
5660

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

60-
- uses: actions/checkout@v4
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+
72+
- uses: actions/checkout@v5
6173

6274
- name: Get composer cache directory
6375
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
@@ -69,61 +81,43 @@ jobs:
6981
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7082
restore-keys: ${{ runner.os }}-composer-
7183

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

78-
- name: Check code for hard dependencies missing in composer.json
79-
run: composer-require-checker check --config-file=tools/composer-require-checker.json composer.json
80-
81-
- name: Check code for unused dependencies in composer.json
82-
run: composer-unused
83-
84-
- name: PHP Code Sniffer
85-
run: phpcs
86-
87-
- name: Psalm
88-
continue-on-error: true
89-
run: |
90-
psalm -c psalm.xml \
91-
--show-info=true \
92-
--shepherd \
93-
--php-version=${{ steps.setup-php.outputs.php-version }}
87+
- name: Run unit tests with coverage
88+
if: ${{ matrix.php-versions == '8.4' }}
89+
run: vendor/bin/phpunit --exclude-group skipOnGithub
9490

95-
- name: Psalm (testsuite)
96-
run: |
97-
psalm -c psalm-dev.xml \
98-
--show-info=true \
99-
--shepherd \
100-
--php-version=${{ steps.setup-php.outputs.php-version }}
91+
- name: Run unit tests (no coverage)
92+
if: ${{ matrix.php-versions != '8.4' }}
93+
run: vendor/bin/phpunit --exclude-group skipOnGithub --no-coverage
10194

102-
- name: Psalter
103-
run: |
104-
psalm --alter \
105-
--issues=UnnecessaryVarAnnotation \
106-
--dry-run \
107-
--php-version=${{ steps.setup-php.outputs.php-version }}
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
108101

109-
security:
110-
name: Security checks
102+
quality:
103+
name: Quality control
111104
runs-on: [ubuntu-latest]
105+
112106
steps:
113107
- name: Setup PHP, with composer and extensions
108+
id: setup-php
114109
# https://github.com/shivammathur/setup-php
115110
uses: shivammathur/setup-php@v2
116111
with:
117-
# Should be the lowest supported version
118-
php-version: '8.0'
119-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
120-
tools: composer
121-
coverage: none
112+
# Should be the higest supported version, so we can use the newest tools
113+
php-version: '8.4'
114+
tools: composer, composer-require-checker, composer-unused
115+
extensions: ctype, date, dom, filter, hash, intl, mbstring, opcache, openssl, pcre, spl, xml
122116

123117
- name: Setup problem matchers for PHP
124118
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
125119

126-
- uses: actions/checkout@v4
120+
- uses: actions/checkout@v5
127121

128122
- name: Get composer cache directory
129123
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
@@ -135,76 +129,49 @@ jobs:
135129
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
136130
restore-keys: ${{ runner.os }}-composer-
137131

132+
- name: Validate composer.json and composer.lock
133+
run: composer validate
134+
138135
- name: Install Composer dependencies
139136
run: composer install --no-progress --prefer-dist --optimize-autoloader
140137

141-
- name: Security check for locked dependencies
142-
run: composer audit
138+
- name: Check code for hard dependencies missing in composer.json
139+
run: composer-require-checker check --config-file tools/composer-require-checker.json composer.json
143140

144-
- name: Update Composer dependencies
145-
run: composer update --no-progress --prefer-dist --optimize-autoloader
141+
- name: Check code for unused dependencies in composer.json
142+
run: |
143+
composer-unused \
144+
--excludePackage=simplesamlphp/simplesamlphp-assets-jquery
146145
147-
- name: Security check for updated dependencies
148-
run: composer audit
146+
- name: PHP Code Sniffer
147+
run: vendor/bin/phpcs
149148

150-
unit-tests-linux:
151-
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
152-
runs-on: ${{ matrix.operating-system }}
153-
needs: [linter, quality, security]
154-
strategy:
155-
fail-fast: false
156-
matrix:
157-
operating-system: [ubuntu-latest]
158-
php-versions: ['8.0', '8.1', '8.2']
149+
- name: PHPStan
150+
run: |
151+
vendor/bin/phpstan analyze -c phpstan.neon --debug
159152
160-
steps:
161-
- name: Setup test MySQL database
153+
- name: PHPStan (testsuite)
162154
run: |
163-
sudo systemctl start mysql.service
164-
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS simplesamlphp;'
165-
mysql -uroot -proot -e '
166-
CREATE TABLE IF NOT EXISTS `AttributeFromSQL` (
167-
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
168-
`uid` VARCHAR(100) NOT NULL,
169-
`sp` VARCHAR(250) DEFAULT "%",
170-
`attribute` VARCHAR(30) NOT NULL,
171-
`value` TEXT,
172-
`expires` DATE DEFAULT "9999-12-31",
173-
PRIMARY KEY (`id`)
174-
) DEFAULT CHARSET=utf8;
175-
CREATE USER IF NOT EXISTS `phpunit`@`localhost` IDENTIFIED BY "phpunit";
176-
GRANT ALL ON `simplesamlphp`.* TO `phpunit`@`localhost`;
177-
' simplesamlphp
178-
mysql -uroot -proot -e "
179-
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonEntitlement', 'urn:mace:exampleIdP.org:demoservice:demo-admin');
180-
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', 'https://idp.example.org/idp/shibboleth', 'eduPersonEntitlement', 'urn:mace:grnet.gr:eduroam:admin');
181-
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonAffiliation', 'faculty');
182-
INSERT INTO AttributeFromSQL (uid, attribute, value) VALUES ('user@example.org', 'mail', 'user@example.org');
183-
INSERT INTO AttributeFromSQL (uid, attribute, value, expires) VALUES ('user@example.org', 'mail', 'marty@example.org', '2015-10-21');
184-
" simplesamlphp
155+
vendor/bin/phpstan analyze -c phpstan-dev.neon --debug
185156
157+
security:
158+
name: Security checks
159+
runs-on: [ubuntu-latest]
160+
steps:
186161
- name: Setup PHP, with composer and extensions
187162
# https://github.com/shivammathur/setup-php
188163
uses: shivammathur/setup-php@v2
189164
with:
190-
php-version: ${{ matrix.php-versions }}
191-
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, openssl, pcre, posix, spl, xml
165+
# Should be the lowest supported version
166+
php-version: '8.1'
167+
extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, spl, xml
192168
tools: composer
193-
ini-values: error_reporting=E_ALL
194-
coverage: pcov
169+
coverage: none
195170

196171
- name: Setup problem matchers for PHP
197172
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
198173

199-
- name: Setup problem matchers for PHPUnit
200-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
201-
202-
- name: Set git to use LF
203-
run: |
204-
git config --global core.autocrlf false
205-
git config --global core.eol lf
206-
207-
- uses: actions/checkout@v4
174+
- uses: actions/checkout@v5
208175

209176
- name: Get composer cache directory
210177
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
@@ -219,50 +186,22 @@ jobs:
219186
- name: Install Composer dependencies
220187
run: composer install --no-progress --prefer-dist --optimize-autoloader
221188

222-
- name: Run unit tests with coverage
223-
if: ${{ matrix.php-versions == '8.2' }}
224-
run: vendor/bin/phpunit
225-
226-
- name: Run unit tests (no coverage)
227-
if: ${{ matrix.php-versions != '8.2' }}
228-
run: vendor/bin/phpunit --no-coverage
229-
230-
- name: Save coverage data
231-
if: ${{ matrix.php-versions == '8.2' }}
232-
uses: actions/upload-artifact@v4
233-
with:
234-
name: coverage-data
235-
path: ${{ github.workspace }}/build
236-
237-
coverage:
238-
name: Code coverage
239-
runs-on: [ubuntu-latest]
240-
needs: [unit-tests-linux]
241-
steps:
242-
- uses: actions/checkout@v4
189+
- name: Security check for locked dependencies
190+
run: composer audit
243191

244-
- uses: actions/download-artifact@v4
245-
with:
246-
name: coverage-data
247-
path: ${{ github.workspace }}/build
192+
- name: Update Composer dependencies
193+
run: composer update --no-progress --prefer-dist --optimize-autoloader
248194

249-
- name: Codecov
250-
uses: codecov/codecov-action@v3
251-
with:
252-
token: ${{ secrets.CODECOV_TOKEN }}
253-
fail_ci_if_error: true
254-
verbose: true
195+
- name: Security check for updated dependencies
196+
run: composer audit
255197

256198
cleanup:
257199
name: Cleanup artifacts
258-
needs: [unit-tests-linux, coverage]
200+
needs: [unit-tests-linux]
259201
runs-on: [ubuntu-latest]
260-
if: |
261-
always() &&
262-
needs.coverage.result == 'success' ||
263-
(needs.unit-tests-linux == 'success' && needs.coverage == 'skipped')
202+
if: ${{ always() && needs.unit-tests-linux.result == 'success' }}
264203

265204
steps:
266-
- uses: geekyeggo/delete-artifact@v2
205+
- uses: geekyeggo/delete-artifact@v5
267206
with:
268207
name: coverage-data

0 commit comments

Comments
 (0)