Skip to content

Commit 63de162

Browse files
committed
Update test-suite with superlinter
1 parent 831b5c0 commit 63de162

File tree

7 files changed

+171
-103
lines changed

7 files changed

+171
-103
lines changed

.github/workflows/documentation.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Documentation
22

3-
on:
3+
on: # yamllint disable-line rule:truthy
44
push:
5-
branches: [ master, release-* ]
5+
branches: ['master', 'release-*']
66
paths:
77
- '**.md'
88
pull_request:
9-
branches: [ master, release-* ]
9+
branches: ['master', 'release-*']
1010
paths:
1111
- '**.md'
1212

@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v3
2020

2121
- name: Lint markdown files
22-
uses: nosborn/github-action-markdown-cli@v3.1.0
22+
uses: nosborn/github-action-markdown-cli@v3.2.0
2323
with:
2424
files: .
2525
ignore_path: .markdownlintignore

.github/workflows/php.yml

Lines changed: 149 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
1+
---
2+
13
name: CI
24

3-
on:
5+
on: # yamllint disable-line rule:truthy
46
push:
5-
branches: [ '**' ]
7+
branches: ['**']
68
paths-ignore:
79
- '**.md'
810
pull_request:
9-
branches: [ master, release-* ]
11+
branches: [master, release-*]
1012
paths-ignore:
1113
- '**.md'
1214

1315
jobs:
14-
basic-tests:
15-
name: Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}
16-
runs-on: ${{ matrix.operating-system }}
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
operating-system: [ubuntu-latest, windows-latest]
21-
php-versions: ['8.0', '8.1', '8.2']
16+
linter:
17+
name: Linter
18+
runs-on: ['ubuntu-latest']
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Lint Code Base
26+
uses: github/super-linter/slim@v4
27+
env:
28+
VALIDATE_ALL_CODEBASE: true
29+
LINTER_RULES_PATH: 'tools/linters'
30+
VALIDATE_JSON: true
31+
VALIDATE_PHP_BUILTIN: true
32+
VALIDATE_YAML: true
33+
VALIDATE_GITHUB_ACTIONS: true
34+
35+
quality:
36+
name: Quality control
37+
runs-on: [ubuntu-latest]
2238

2339
steps:
2440
- name: Setup PHP, with composer and extensions
25-
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
41+
id: setup-php
42+
# https://github.com/shivammathur/setup-php
43+
uses: shivammathur/setup-php@v2
2644
with:
27-
php-version: ${{ matrix.php-versions }}
28-
extensions: mbstring, xml
29-
ini-values: error_reporting=E_ALL
45+
php-version: '8.0'
3046
tools: composer:v2
31-
coverage: pcov
47+
extensions: ctype, spl
3248

3349
- name: Setup problem matchers for PHP
3450
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
3551

36-
- name: Setup problem matchers for PHPUnit
37-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
38-
39-
- name: Set git to use LF
40-
run: |
41-
git config --global core.autocrlf false
42-
git config --global core.eol lf
43-
4452
- uses: actions/checkout@v3
4553

46-
- name: Get composer cache directory (linux)
47-
if: ${{ matrix.operating-system == 'ubuntu-latest' }}
48-
run: echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $GITHUB_ENV
49-
50-
- name: Get composer cache directory (windows)
51-
if: ${{ matrix.operating-system == 'windows-latest' }}
52-
run: echo "COMPOSER_CACHE=$(composer config cache-files-dir)" >> $env:GITHUB_ENV
54+
- name: Get composer cache directory
55+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
5356

5457
- name: Cache composer dependencies
5558
uses: actions/cache@v3
@@ -64,49 +67,61 @@ jobs:
6467
- name: Install Composer dependencies
6568
run: composer install --no-progress --prefer-dist --optimize-autoloader
6669

67-
- name: Syntax check PHP
68-
run: bash vendor/bin/check-syntax-php.sh
70+
- name: PHP Code Sniffer
71+
run: php vendor/simplesamlphp/simplesamlphp-test-framework/tools/phpcs
6972

70-
- name: Decide whether to run code coverage or not
71-
if: ${{ matrix.php-versions != '8.0' || matrix.operating-system != 'ubuntu-latest' }}
73+
- name: Psalm
74+
continue-on-error: true
7275
run: |
73-
echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
76+
php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
77+
-c psalm.xml \
78+
--show-info=true \
79+
--shepherd \
80+
--php-version=${{ steps.setup-php.outputs.php-version }}
7481
75-
- name: Run unit tests
82+
- name: Psalm (testsuite)
7683
run: |
77-
echo $NO_COVERAGE
78-
./vendor/bin/phpunit $NO_COVERAGE
84+
php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
85+
-c psalm-dev.xml \
86+
--show-info=true \
87+
--shepherd \
88+
--php-version=${{ steps.setup-php.outputs.php-version }}
7989
80-
- name: Save coverage data
81-
if: ${{ matrix.php-versions == '8.0' && matrix.operating-system == 'ubuntu-latest' }}
82-
uses: actions/upload-artifact@v3
83-
with:
84-
name: build-data
85-
path: ${{ github.workspace }}/build
90+
- name: Psalter
91+
run: |
92+
php vendor/simplesamlphp/simplesamlphp-test-framework/tools/psalm \
93+
--alter \
94+
--issues=UnnecessaryVarAnnotation \
95+
--dry-run \
96+
--php-version=${{ steps.setup-php.outputs.php-version }}
8697
8798
security:
8899
name: Security checks
89100
runs-on: [ubuntu-latest]
90101
steps:
91102
- name: Setup PHP, with composer and extensions
92-
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
103+
# https://github.com/shivammathur/setup-php
104+
uses: shivammathur/setup-php@v2
93105
with:
94-
php-version: '8.0'
95-
extensions: mbstring, xml
96-
tools: composer:v2
97-
coverage: none
106+
php-version: '8.0'
107+
extensions: ctype, spl
108+
tools: composer:v2
109+
coverage: none
98110

99111
- name: Setup problem matchers for PHP
100112
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
101113

102114
- uses: actions/checkout@v3
103115

116+
- name: Get composer cache directory
117+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
118+
104119
- name: Cache composer dependencies
105120
uses: actions/cache@v3
106121
with:
107-
path: $COMPOSER_CACHE
108-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
109-
restore-keys: ${{ runner.os }}-composer-
122+
path: $COMPOSER_CACHE
123+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
124+
restore-keys: ${{ runner.os }}-composer-
110125

111126
- name: Install Composer dependencies
112127
run: composer install --no-progress --prefer-dist --optimize-autoloader
@@ -120,85 +135,127 @@ jobs:
120135
- name: Security check for updated dependencies
121136
run: composer audit
122137

123-
sanity-check:
124-
name: Sanity checks
125-
runs-on: [ubuntu-latest]
138+
unit-tests-linux:
139+
name: "Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
140+
runs-on: ${{ matrix.operating-system }}
141+
needs: [linter, quality, security]
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
operating-system: [ubuntu-latest]
146+
php-versions: ['8.0', '8.1', '8.2']
126147

127148
steps:
128149
- name: Setup PHP, with composer and extensions
129-
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
150+
# https://github.com/shivammathur/setup-php
151+
uses: shivammathur/setup-php@v2
130152
with:
131-
php-version: '8.0'
132-
extensions: mbstring, xml
153+
php-version: ${{ matrix.php-versions }}
154+
extensions: ctype, spl
133155
tools: composer:v2
134-
coverage: none
156+
ini-values: error_reporting=E_ALL
157+
coverage: xdebug
135158

136159
- name: Setup problem matchers for PHP
137160
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
138161

162+
- name: Setup problem matchers for PHPUnit
163+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
164+
165+
- name: Set git to use LF
166+
run: |
167+
git config --global core.autocrlf false
168+
git config --global core.eol lf
169+
139170
- uses: actions/checkout@v3
140171

172+
- name: Get composer cache directory
173+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
174+
141175
- name: Cache composer dependencies
142176
uses: actions/cache@v3
143177
with:
144-
path: $COMPOSER_CACHE
145-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
146-
restore-keys: ${{ runner.os }}-composer-
178+
path: $COMPOSER_CACHE
179+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
180+
restore-keys: ${{ runner.os }}-composer-
147181

148182
- name: Install Composer dependencies
149183
run: composer install --no-progress --prefer-dist --optimize-autoloader
150184

151-
- name: Syntax check YAML / XML / JSON
152-
run: |
153-
bash vendor/bin/check-syntax-yaml.sh
154-
bash vendor/bin/check-syntax-xml.sh
155-
bash vendor/bin/check-syntax-json.sh
185+
- name: Run unit tests with coverage
186+
if: ${{ matrix.php-versions == '8.1' }}
187+
run: vendor/bin/phpunit
156188

157-
quality:
158-
name: Quality control
159-
runs-on: [ubuntu-latest]
160-
needs: [basic-tests]
189+
- name: Run unit tests (no coverage)
190+
if: ${{ matrix.php-versions != '8.1' }}
191+
run: vendor/bin/phpunit --no-coverage
192+
193+
- name: Save coverage data
194+
if: ${{ matrix.php-versions == '8.1' }}
195+
uses: actions/upload-artifact@v3
196+
with:
197+
name: coverage-data
198+
path: ${{ github.workspace }}/build
199+
200+
unit-tests-windows:
201+
name: "Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
202+
runs-on: ${{ matrix.operating-system }}
203+
needs: [linter, quality, security]
204+
strategy:
205+
fail-fast: true
206+
matrix:
207+
operating-system: [windows-latest]
208+
php-versions: ['8.0', '8.1', '8.2']
161209

162210
steps:
163211
- name: Setup PHP, with composer and extensions
164-
id: setup-php
165-
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
212+
# https://github.com/shivammathur/setup-php
213+
uses: shivammathur/setup-php@v2
166214
with:
167-
php-version: '8.0'
215+
php-version: ${{ matrix.php-versions }}
216+
extensions: ctype, spl
168217
tools: composer:v2
169-
extensions: mbstring, xml
218+
ini-values: error_reporting=E_ALL
219+
coverage: none
170220

171221
- name: Setup problem matchers for PHP
172222
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
173223

224+
- name: Setup problem matchers for PHPUnit
225+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
226+
227+
- name: Set git to use LF
228+
run: |
229+
git config --global core.autocrlf false
230+
git config --global core.eol lf
231+
174232
- uses: actions/checkout@v3
175233

234+
- name: Get composer cache directory
235+
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"
236+
176237
- name: Cache composer dependencies
177238
uses: actions/cache@v3
178239
with:
179-
path: $COMPOSER_CACHE
180-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
181-
restore-keys: ${{ runner.os }}-composer-
240+
path: $COMPOSER_CACHE
241+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
242+
restore-keys: ${{ runner.os }}-composer-
182243

183244
- name: Install Composer dependencies
184245
run: composer install --no-progress --prefer-dist --optimize-autoloader
185246

247+
- name: Run unit tests
248+
run: vendor/bin/phpunit --no-coverage
249+
250+
coverage:
251+
name: Code coverage
252+
runs-on: [ubuntu-latest]
253+
needs: [unit-tests-linux]
254+
steps:
186255
- uses: actions/download-artifact@v3
187256
with:
188-
name: build-data
257+
name: coverage-data
189258
path: ${{ github.workspace }}/build
190259

191260
- name: Codecov
192261
uses: codecov/codecov-action@v3
193-
194-
- name: PHP Code Sniffer
195-
continue-on-error: true
196-
run: php vendor/bin/phpcs
197-
198-
- name: Psalm
199-
continue-on-error: true
200-
run: php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
201-
202-
- name: Psalter
203-
continue-on-error: true
204-
run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}

.markdownlint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
default: true
3+
4+
MD013: false

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"webmozart/assert": "^1.11"
2020
},
2121
"require-dev": {
22-
"simplesamlphp/simplesamlphp-test-framework": "^1.3.1"
22+
"simplesamlphp/simplesamlphp-test-framework": "^1.4.1"
2323
},
2424
"autoload": {
2525
"psr-4": {
@@ -34,7 +34,7 @@
3434
},
3535
"extra": {
3636
"branch-alias": {
37-
"dev-master": "v1.0.x-dev"
37+
"dev-master": "v1.1.x-dev"
3838
}
3939
},
4040
"config": {

0 commit comments

Comments
 (0)