Skip to content

Commit 65ab8e6

Browse files
committed
Add GH workflows
1 parent 7f142b7 commit 65ab8e6

File tree

4 files changed

+233
-0
lines changed

4 files changed

+233
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Coding Standards
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
pull_request:
7+
paths:
8+
- '**.php'
9+
- '**.neon.dist'
10+
- '.github/workflows/**'
11+
- composer.json
12+
- phpunit.xml.dist
13+
push:
14+
paths:
15+
- '**.php'
16+
- '**.neon.dist'
17+
- '.github/workflows/**'
18+
- composer.json
19+
- phpunit.xml.dist
20+
21+
jobs:
22+
coding-standards:
23+
name: Coding Standards with PHP CS Fixer [PHP ${{ matrix.php-version }}]
24+
runs-on: ubuntu-20.04
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php-version:
30+
- '7.3'
31+
- '7.4'
32+
- '8.0'
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v2
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: '8.0'
42+
extensions: tokenizer
43+
coverage: none
44+
45+
- name: Get composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
- name: Cache composer dependencies
50+
uses: actions/cache@v2
51+
with:
52+
path: ${{ steps.composer-cache.outputs.dir }}
53+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}
54+
restore-keys: |
55+
composer-${{ runner.os }}-${{ matrix.php-version }}-
56+
composer-${{ runner.os }}-
57+
composer-
58+
59+
- name: Setup Composer's GitHub OAuth access
60+
run: composer config --global github-oauth.github.com ${{ secrets.ACCESS_TOKEN }}
61+
62+
- name: Install dependencies on tools
63+
run: composer update --ansi --no-interaction
64+
65+
- name: Run PHP CS Fixer
66+
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff

.github/workflows/test-phpstan.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: PHPStan Static Analysis
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
pull_request:
7+
paths:
8+
- '**.php'
9+
- '**.neon.dist'
10+
- '.github/workflows/**'
11+
- composer.json
12+
- phpunit.xml.dist
13+
push:
14+
paths:
15+
- '**.php'
16+
- '**.neon.dist'
17+
- '.github/workflows/**'
18+
- composer.json
19+
- phpunit.xml.dist
20+
21+
jobs:
22+
static-analyses:
23+
name: PHPStan Static Analysis [PHP ${{ matrix.php-version }}]
24+
runs-on: ubuntu-20.04
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php-version:
30+
- '7.3'
31+
- '7.4'
32+
- '8.0'
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v2
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: '8.0'
42+
extensions: tokenizer
43+
coverage: none
44+
45+
- name: Get composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
- name: Cache composer dependencies
50+
uses: actions/cache@v2
51+
with:
52+
path: ${{ steps.composer-cache.outputs.dir }}
53+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}
54+
restore-keys: |
55+
composer-${{ runner.os }}-${{ matrix.php-version }}-
56+
composer-${{ runner.os }}-
57+
composer-
58+
59+
- name: Create PHPStan cache directory
60+
run: mkdir --parents build/phpstan
61+
62+
- name: Cache PHPStan cache directory
63+
uses: actions/cache@v2
64+
with:
65+
path: build/phpstan
66+
key: phpstan-${{ runner.os }}-${{ github.sha }}
67+
restore-keys: |
68+
phpstan-${{ runner.os }}-
69+
phpstan-
70+
71+
- name: Setup Composer's GitHub OAuth access
72+
run: composer config --global github-oauth.github.com ${{ secrets.ACCESS_TOKEN }}
73+
74+
- name: Install dependencies
75+
run: composer update --ansi --no-interaction
76+
77+
- name: Run PHPStan
78+
run: vendor/bin/phpstan analyse --ansi

.github/workflows/test-phpunit.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Unit Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
pull_request:
7+
paths:
8+
- '**.php'
9+
- '**.neon.dist'
10+
- '.github/workflows/**'
11+
- composer.json
12+
- phpunit.xml.dist
13+
push:
14+
paths:
15+
- '**.php'
16+
- '**.neon.dist'
17+
- '.github/workflows/**'
18+
- composer.json
19+
- phpunit.xml.dist
20+
21+
jobs:
22+
unit-tests:
23+
name: PHPUnit Tests [PHP ${{ matrix.php-version }}]
24+
runs-on: ubuntu-20.04
25+
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
php-version:
30+
- '7.3'
31+
- '7.4'
32+
- '8.0'
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v2
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: ${{ matrix.php-version }}
42+
extensions: tokenizer
43+
coverage: xdebug
44+
45+
- name: Get composer cache directory
46+
id: composer-cache
47+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
48+
49+
- name: Cache composer dependencies
50+
uses: actions/cache@v2
51+
with:
52+
path: ${{ steps.composer-cache.outputs.dir }}
53+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}
54+
restore-keys: |
55+
composer-${{ runner.os }}-${{ matrix.php-version }}-
56+
composer-${{ runner.os }}-
57+
composer-
58+
59+
- name: Setup Composer's GitHub OAuth access
60+
run: composer config --global github-oauth.github.com ${{ secrets.ACCESS_TOKEN }}
61+
62+
- name: Install dependencies
63+
run: composer update --ansi --no-interaction
64+
65+
- name: Run Coding Standards Test Suite
66+
run: vendor/bin/phpunit --colors=always
67+
68+
- name: Upload coverage results to Coveralls
69+
run: |
70+
composer global require --ansi php-coveralls/php-coveralls
71+
php-coveralls --verbose --coverage_clover=build/phpunit/logs/clover.xml --json_path=build/phpunit/logs/coverage-upload.json
72+
env:
73+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
COVERALLS_PARALLEL: true
75+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-version }}
76+
77+
coveralls-upload:
78+
name: Trigger parallel build webhook on Coveralls
79+
runs-on: ubuntu-20.04
80+
needs:
81+
- unit-tests
82+
83+
steps:
84+
- name: Upload to Coveralls API
85+
uses: coverallsapp/github-action@master
86+
with:
87+
github-token: ${{ secrets.GITHUB_TOKEN }}
88+
parallel-finished: true

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
],
1212
"require": {
1313
"php": "^7.3 || ^8.0",
14+
"ext-tokenizer": "*",
1415
"friendsofphp/php-cs-fixer": "^3.0",
1516
"nexusphp/cs-config": "^3.2"
1617
},

0 commit comments

Comments
 (0)