Skip to content

Commit a040419

Browse files
tvdijenthijskh
authored andcommitted
Add test-framework
1 parent 0aed294 commit a040419

12 files changed

Lines changed: 408 additions & 2 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- '**.md'
8+
pull_request:
9+
branches: [ main ]
10+
paths:
11+
- '**.md'
12+
13+
jobs:
14+
quality:
15+
name: Quality checks
16+
runs-on: [ubuntu-latest]
17+
18+
steps:
19+
- name: Setup PHP, with composer and extensions
20+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
21+
with:
22+
php-version: '8.0'
23+
tools: composer:v2
24+
extensions: intl, mbstring, xml
25+
26+
- name: Setup problem matchers for PHP
27+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
28+
29+
- uses: actions/checkout@v3
30+
31+
- name: Get composer cache directory
32+
id: composer-cache
33+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
34+
35+
- name: Cache composer dependencies
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: ${{ runner.os }}-composer-
41+
42+
- name: Install Composer dependencies
43+
run: composer install --no-progress --prefer-dist --optimize-autoloader
44+
45+
- name: Lint markdown files
46+
uses: nosborn/github-action-markdown-cli@v3.1.0
47+
with:
48+
files: .
49+
ignore_path: .markdownlintignore

.github/workflows/php.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
basic-tests:
11+
name: Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}
12+
runs-on: ${{ matrix.operating-system }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
operating-system: [ubuntu-latest, windows-latest]
17+
php-versions: ['7.4', '8.0', '8.1']
18+
19+
steps:
20+
- name: Setup PHP, with composer and extensions
21+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
extensions: intl, mbstring, xml
25+
tools: composer:v2
26+
ini-values: error_reporting=E_ALL
27+
coverage: xdebug
28+
29+
- name: Setup problem matchers for PHP
30+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
31+
32+
- name: Setup problem matchers for PHPUnit
33+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
34+
35+
- name: Set git to use LF
36+
run: |
37+
git config --global core.autocrlf false
38+
git config --global core.eol lf
39+
40+
- uses: actions/checkout@v2
41+
42+
- name: Get composer cache directory
43+
id: composer-cache
44+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
45+
46+
- name: Cache composer dependencies
47+
uses: actions/cache@v1
48+
with:
49+
path: ${{ steps.composer-cache.outputs.dir }}
50+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
51+
restore-keys: ${{ runner.os }}-composer-
52+
53+
- name: Validate composer.json and composer.lock
54+
run: composer validate
55+
56+
- name: Install Composer dependencies
57+
run: composer install --no-progress --prefer-dist --optimize-autoloader
58+
59+
- name: Syntax check PHP
60+
run: bash vendor/bin/check-syntax-php.sh
61+
62+
- name: Decide whether to run code coverage or not
63+
if: ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }}
64+
run: |
65+
echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
66+
67+
- name: Run unit tests
68+
run: |
69+
echo $NO_COVERAGE
70+
./vendor/bin/phpunit $NO_COVERAGE
71+
72+
- name: Save coverage data
73+
if: ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: build-data
77+
path: ${{ github.workspace }}/build
78+
79+
security:
80+
name: Security checks
81+
runs-on: [ubuntu-latest]
82+
steps:
83+
- name: Setup PHP, with composer and extensions
84+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
85+
with:
86+
php-version: '7.4'
87+
extensions: mbstring, xml
88+
tools: composer:v2
89+
coverage: none
90+
91+
- name: Setup problem matchers for PHP
92+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
93+
94+
- uses: actions/checkout@v2
95+
96+
- name: Get composer cache directory
97+
id: composer-cache
98+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
99+
100+
- name: Cache composer dependencies
101+
uses: actions/cache@v1
102+
with:
103+
path: ${{ steps.composer-cache.outputs.dir }}
104+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
105+
restore-keys: ${{ runner.os }}-composer-
106+
107+
- name: Install Composer dependencies
108+
run: composer install --no-progress --prefer-dist --optimize-autoloader
109+
110+
- name: Security check for locked dependencies
111+
uses: symfonycorp/security-checker-action@v2
112+
113+
- name: Update Composer dependencies
114+
run: composer update --no-progress --prefer-dist --optimize-autoloader
115+
116+
- name: Security check for updated dependencies
117+
uses: symfonycorp/security-checker-action@v2
118+
119+
sanity-check:
120+
name: Sanity checks
121+
runs-on: [ubuntu-latest]
122+
123+
steps:
124+
- name: Setup PHP, with composer and extensions
125+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
126+
with:
127+
php-version: '7.4'
128+
extensions: mbstring, xml
129+
tools: composer:v2
130+
coverage: none
131+
132+
- name: Setup problem matchers for PHP
133+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
134+
135+
- uses: actions/checkout@v2
136+
137+
- name: Get composer cache directory
138+
id: composer-cache
139+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
140+
141+
- name: Cache composer dependencies
142+
uses: actions/cache@v1
143+
with:
144+
path: ${{ steps.composer-cache.outputs.dir }}
145+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
146+
restore-keys: ${{ runner.os }}-composer-
147+
148+
- name: Install Composer dependencies
149+
run: composer install --no-progress --prefer-dist --optimize-autoloader
150+
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
156+
157+
quality:
158+
name: Quality control
159+
runs-on: [ubuntu-latest]
160+
needs: [basic-tests]
161+
162+
steps:
163+
- name: Setup PHP, with composer and extensions
164+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
165+
with:
166+
php-version: '7.4'
167+
tools: composer:v2
168+
extensions: mbstring, xml
169+
170+
- name: Setup problem matchers for PHP
171+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
172+
173+
- uses: actions/checkout@v2
174+
175+
- name: Get composer cache directory
176+
id: composer-cache
177+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
178+
179+
- name: Cache composer dependencies
180+
uses: actions/cache@v1
181+
with:
182+
path: ${{ steps.composer-cache.outputs.dir }}
183+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
184+
restore-keys: ${{ runner.os }}-composer-
185+
186+
- name: Install Composer dependencies
187+
run: composer install --no-progress --prefer-dist --optimize-autoloader
188+
189+
- uses: actions/download-artifact@v3
190+
with:
191+
name: build-data
192+
path: ${{ github.workspace }}/build
193+
194+
- name: Codecov
195+
uses: codecov/codecov-action@v1
196+
197+
- name: PHP Code Sniffer
198+
continue-on-error: true
199+
run: php vendor/bin/phpcs
200+
201+
- name: Psalm
202+
continue-on-error: true
203+
run: php vendor/bin/psalm --show-info=true --shepherd
204+
205+
- name: Psalter
206+
continue-on-error: true
207+
run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run

.markdownlintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/*

.markdownlintrc

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

.php_cs.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->in([
4+
__DIR__ . '/src',
5+
__DIR__ . '/tests',
6+
])
7+
;
8+
return PhpCsFixer\Config::create()
9+
->setRules([
10+
'@PSR2' => true,
11+
'@PSR4' => true,
12+
'@PSR5' => true,
13+
])
14+
->setFinder($finder)
15+
;

codecov.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 0%
6+
threshold: 2%
7+
patch: off
8+
comment:
9+
layout: "diff"
10+
behavior: once
11+
require_changes: true
12+
require_base: no
13+
require_head: yes
14+
branches: null
15+
16+
github_checks:
17+
annotations: false

composer.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,32 @@
55
"homepage": "https://github.com/OpenConextApps/simplesamlphp-module-stepupsfo",
66
"license": "LGPL-2.1",
77
"type": "simplesamlphp-module",
8+
"config": {
9+
"preferred-install": {
10+
"simplesamlphp/simplesamlphp": "source",
11+
"*": "dist"
12+
},
13+
"allow-plugins": {
14+
"composer/package-versions-deprecated": true,
15+
"simplesamlphp/composer-module-installer": true
16+
}
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"SimpleSAML\\Module\\stepupsfo\\": "src/"
21+
}
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
26+
}
27+
},
828
"require": {
9-
"simplesamlphp/composer-module-installer": "~1.1.8",
10-
"simplesamlphp/simplesamlphp": "^2.0"
29+
"simplesamlphp/composer-module-installer": "~1.1.8"
30+
},
31+
"require-dev": {
32+
"simplesamlphp/simplesamlphp": "^2.0",
33+
"simplesamlphp/simplesamlphp-test-framework": "^1.2.1"
1134
},
1235
"support": {
1336
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-stepupsfo/issues",

default-enable

Whitespace-only changes.

phpcs.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="SimpleSAMLphp SAML2 ruleset">
3+
<config name="ignore_warnings_on_exit" value="1"/>
4+
5+
<description>
6+
By default it is less stringent about long lines than other coding standards
7+
</description>
8+
9+
<file>src</file>
10+
<file>tests</file>
11+
12+
<!-- Use this to exclude paths. You can have multiple patterns -->
13+
<!--<exclude-pattern>*/tests/*</exclude-pattern>-->
14+
<!--<exclude-pattern>*/other/*</exclude-pattern>-->
15+
16+
<!-- This is the rule we inherit from. If you want to exclude some specific rules, see the docs on how to do that -->
17+
<rule ref="PSR12"/>
18+
</ruleset>
19+

phpunit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/logs/clover.xml"/>
9+
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
10+
<text outputFile="php://stdout" showUncoveredFiles="true"/>
11+
</report>
12+
</coverage>
13+
<testsuites>
14+
<testsuite name="The project's test suite">
15+
<directory>./vendor/simplesamlphp/simplesamlphp-test-framework/src</directory>
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<logging/>
20+
</phpunit>

0 commit comments

Comments
 (0)