Skip to content

Commit a6b1ac3

Browse files
committed
Add CI
1 parent cdf5fe3 commit a6b1ac3

3 files changed

Lines changed: 93 additions & 5 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# GitHub Actions Documentation: https://docs.github.com/en/actions
2+
3+
name: "build"
4+
5+
on:
6+
push:
7+
branches:
8+
- "main"
9+
tags:
10+
- "*"
11+
pull_request:
12+
branches:
13+
- "main"
14+
15+
# Cancels all previous workflow runs for the same branch that have not yet completed.
16+
concurrency:
17+
# The concurrency group contains the workflow name and the branch name.
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
env:
22+
COMPOSER_ROOT_VERSION: "1.99.99"
23+
24+
jobs:
25+
coding-standards:
26+
name: "Coding standards"
27+
runs-on: "ubuntu-latest"
28+
steps:
29+
- name: "Checkout repository"
30+
uses: "actions/checkout@v2"
31+
32+
- name: "Install PHP"
33+
uses: "shivammathur/setup-php@v2"
34+
with:
35+
php-version: "7.4"
36+
coverage: none
37+
38+
- name: "Install dependencies (Composer)"
39+
uses: "ramsey/composer-install@v2"
40+
41+
- name: "Check coding standards (PHP CS Fixer)"
42+
shell: "bash"
43+
run: "composer style-lint"
44+
45+
static-analysis:
46+
name: "Static analysis"
47+
runs-on: "ubuntu-latest"
48+
steps:
49+
- name: "Checkout repository"
50+
uses: "actions/checkout@v2"
51+
52+
- name: "Install PHP"
53+
uses: "shivammathur/setup-php@v2"
54+
with:
55+
php-version: "7.4"
56+
coverage: "none"
57+
58+
- name: "Install dependencies (Composer)"
59+
uses: "ramsey/composer-install@v2"
60+
61+
- name: "Statically analyze code (PHPStan)"
62+
shell: "bash"
63+
run: "composer stan"
64+
65+
unit-tests:
66+
name: "Unit tests"
67+
runs-on: "ubuntu-latest"
68+
steps:
69+
- name: "Checkout repository"
70+
uses: "actions/checkout@v2"
71+
72+
- name: "Install PHP"
73+
uses: "shivammathur/setup-php@v2"
74+
with:
75+
php-version: 7.4"
76+
ini-values: "memory_limit=-1"
77+
78+
- name: "Install dependencies (Composer)"
79+
uses: "ramsey/composer-install@v2"
80+
81+
- name: "Run unit tests (PHPUnit)"
82+
shell: "bash"
83+
run: "composer test"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/coverage/
44
/.phpunit.result.cache
55
/.php_cs.cache
6+
/build

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@
4545
}
4646
},
4747
"scripts": {
48-
"style": "php-cs-fixer fix --dry-run --verbose --show-progress=none",
48+
"style-lint": "php-cs-fixer fix --dry-run --verbose --show-progress=none",
4949
"style-fix": "php-cs-fixer fix",
5050
"stan": "phpstan analyse --level=5 src tests",
51-
"test": "phpunit",
52-
"test-unit": "phpunit --testsuite=unit",
53-
"test-integ": "phpunit --testsuite=integ",
54-
"test-all": ["@style", "@stan", "@test"]
51+
"test": "phpunit --bootstrap=vendor/autoload.php --no-coverage tests",
52+
"test-coverage": "XDEBUG_MODE=coverage phpunit --bootstrap=vendor/autoload.php --coverage-html=build/coverage --whitelist=src tests",
53+
"test-debug": "XDEBUG_MODE=debug phpunit --bootstrap=vendor/autoload.php --no-coverage --debug tests",
54+
"test-all": [
55+
"@style-lint",
56+
"@stan",
57+
"@test-coverage"
58+
]
5559
}
5660
}

0 commit comments

Comments
 (0)