Skip to content

Commit 477d049

Browse files
authored
Merge pull request #1 from kenjis/add-gh-action
Add GitHub Actions workflows
2 parents 7134842 + 20f1b17 commit 477d049

File tree

9 files changed

+383
-92
lines changed

9 files changed

+383
-92
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Coding Standards
2+
3+
on:
4+
push:
5+
branches:
6+
- 1.x
7+
paths:
8+
- 'src/**'
9+
- 'tests/**'
10+
- phpcs.xml
11+
pull_request:
12+
branches:
13+
- 1.x
14+
paths:
15+
- 'src/**'
16+
- 'tests/**'
17+
- phpcs.xml
18+
workflow_dispatch:
19+
20+
jobs:
21+
coding-standards:
22+
name: Coding Standards
23+
runs-on: ubuntu-latest
24+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: 8.0
33+
tools: cs2pr
34+
coverage: none
35+
36+
- name: Get composer cache directory
37+
id: composer-cache
38+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
39+
40+
- name: Cache dependencies
41+
uses: actions/cache@v2
42+
with:
43+
path: ${{ steps.composer-cache.outputs.dir }}
44+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: ${{ runner.os }}-composer-
46+
47+
- name: Install dependencies
48+
run: composer install --no-interaction --no-progress --prefer-dist
49+
50+
- name: Validate composer.json
51+
run: composer validate --strict
52+
53+
- name: Run PHP_CodeSniffer
54+
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr

.github/workflows/phpunit.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: PHPUnit
2+
3+
on:
4+
push:
5+
branches:
6+
- 1.x
7+
paths:
8+
- 'src/**'
9+
- 'tests/**'
10+
- composer.json
11+
- phpunit.xml.dist
12+
pull_request:
13+
branches:
14+
- 1.x
15+
paths:
16+
- 'src/**'
17+
- 'tests/**'
18+
- composer.json
19+
- phpunit.xml.dist
20+
workflow_dispatch:
21+
22+
jobs:
23+
phpunit:
24+
name: PHPUnit
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
operating-system:
29+
- ubuntu-latest
30+
php-version:
31+
- '7.3'
32+
- '7.4'
33+
- '8.0'
34+
dependencies:
35+
- lowest
36+
- highest
37+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
41+
42+
- name: Setup PHP, with composer and extensions
43+
uses: shivammathur/setup-php@master
44+
with:
45+
php-version: ${{ matrix.php-version }}
46+
coverage: pcov
47+
ini-values: zend.assertions=1
48+
49+
- name: Get composer cache directory
50+
id: composer-cache
51+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
52+
53+
- name: Cache dependencies
54+
uses: actions/cache@v2
55+
with:
56+
path: ${{ steps.composer-cache.outputs.dir }}
57+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
58+
restore-keys: ${{ runner.os }}-composer-
59+
60+
- name: Install lowest dependencies
61+
if: ${{ matrix.dependencies == 'lowest' }}
62+
run: composer update --prefer-lowest --no-interaction --no-progress --no-suggest
63+
64+
- name: Install highest dependencies
65+
if: ${{ matrix.dependencies == 'highest' }}
66+
run: composer update --no-interaction --no-progress --no-suggest
67+
68+
- name: Run test suite
69+
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text
70+
71+
- name: Upload coverage report
72+
uses: codecov/codecov-action@v1
73+
with:
74+
file: ./coverage.xml

.github/workflows/static-analysis.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- 1.x
7+
paths:
8+
- 'src/**'
9+
- 'tests/**'
10+
- phpmd.xml
11+
- phpstan.neon
12+
- psalm.xml
13+
pull_request:
14+
branches:
15+
- 1.x
16+
paths:
17+
- 'src/**'
18+
- 'tests/**'
19+
- phpmd.xml
20+
- phpstan.neon
21+
- psalm.xml
22+
workflow_dispatch:
23+
24+
jobs:
25+
static-analysis-phpstan:
26+
name: Static Analysis with PHPStan
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: 8.0
36+
tools: cs2pr
37+
coverage: none
38+
39+
- name: Get composer cache directory
40+
id: composer-cache
41+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
42+
43+
- name: Cache dependencies
44+
uses: actions/cache@v2
45+
with:
46+
path: ${{ steps.composer-cache.outputs.dir }}
47+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
48+
restore-keys: ${{ runner.os }}-composer-
49+
50+
- name: Install dependencies
51+
run: composer install --no-interaction --no-progress --prefer-dist
52+
53+
- name: Run PHPStan
54+
run: ./vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction --error-format=checkstyle | cs2pr
55+
56+
static-analysis-psalm:
57+
name: Static Analysis with Psalm
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
63+
- name: Setup PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: 8.0
67+
tools: cs2pr
68+
coverage: none
69+
70+
- name: Get composer cache directory
71+
id: composer-cache
72+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
73+
74+
- name: Install dependencies
75+
run: composer install --no-interaction --no-progress --prefer-dist
76+
77+
- name: Run Psalm
78+
run: ./vendor/bin/psalm --show-info=false --output-format=checkstyle --shepherd | cs2pr
79+
80+
static-analysis-phpmd:
81+
name: Static Analysis with PHPMD
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v2
86+
87+
- name: Setup PHP
88+
uses: shivammathur/setup-php@v2
89+
with:
90+
php-version: 7.4
91+
92+
- name: Get composer cache directory
93+
id: composer-cache
94+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
95+
96+
- name: Cache dependencies
97+
uses: actions/cache@v2
98+
with:
99+
path: ${{ steps.composer-cache.outputs.dir }}
100+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
101+
restore-keys: ${{ runner.os }}-composer-
102+
103+
- name: Install dependencies
104+
run: composer install --no-interaction --no-progress --prefer-dist
105+
106+
- name: Run PHP Mess Detector
107+
run: ./vendor/bin/phpmd src text --exclude src/Annotation ./phpmd.xml
108+
109+
static-analysis-php-metrics:
110+
name: Static Analysis with PhpMetrics
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v2
115+
116+
- name: Setup PHP
117+
uses: shivammathur/setup-php@v2
118+
with:
119+
php-version: 8.0
120+
coverage: none
121+
122+
- name: Get composer cache directory
123+
id: composer-cache
124+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
125+
126+
- name: Install dependencies
127+
run: composer install --no-interaction --no-progress --prefer-dist
128+
129+
- name: Run PhpMetrics
130+
run: ./vendor/bin/phpmetrics --exclude=Exception src
131+
132+
static-analysis-composer-require-checker:
133+
name: Static Analysis with ComposerRequireChecker
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Checkout
137+
uses: actions/checkout@v2
138+
139+
- name: Setup PHP
140+
uses: shivammathur/setup-php@v2
141+
with:
142+
php-version: 8.0
143+
coverage: none
144+
145+
- name: Get composer cache directory
146+
id: composer-cache
147+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
148+
149+
- name: Install dependencies
150+
run: |
151+
composer install --no-interaction --no-progress --prefer-dist
152+
composer require --dev maglnet/composer-require-checker ^3.0
153+
154+
- name: Run composer-require-checker
155+
run: ./vendor/bin/composer-require-checker

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Provides helper traits for PHPUnit.
2424

2525
## Requirements
2626

27-
- PHP 7.2 or later
27+
- PHP 7.3 or later
2828

2929
## Installation
3030

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^7.2"
15+
"php": "^7.3||^8.0",
16+
"phpunit/phpunit": "^9.5"
1617
},
1718
"require-dev": {
18-
"bamarni/composer-bin-plugin": "^1.4",
19-
"phpunit/phpunit": "^9.5"
19+
"bamarni/composer-bin-plugin": "^1.4"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -45,7 +45,8 @@
4545
],
4646
"sa": [
4747
"./vendor/bin/phpstan analyse -c phpstan.neon",
48-
"psalm --show-info=true"
48+
"psalm --show-info=true",
49+
"./vendor/bin/phpmd src text ./phpmd.xml"
4950
],
5051
"tests": [
5152
"@cs",

0 commit comments

Comments
 (0)