Skip to content

Commit 74685a1

Browse files
committed
Add full CI
1 parent 0e10e73 commit 74685a1

20 files changed

+333
-180
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
55
/.github export-ignore
6-
/.phpstorm.meta.php export-ignore
6+
/infection.json.dist export-ignore
77
/Makefile export-ignore
88
/phpcs.xml.dist export-ignore
99
/phpstan.neon.dist export-ignore
1010
/phpunit.xml.dist export-ignore
11+
/psalm.xml.dist export-ignore
12+
/psalm-baseline.xml export-ignore
1113
/tests export-ignore

.github/workflows/ci.yaml

Lines changed: 72 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,74 @@
1-
name: CI
2-
on:
3-
pull_request:
4-
push:
5-
branches:
6-
- "master"
7-
schedule:
8-
- cron: "0 17 * * *"
9-
jobs:
10-
phpstan:
11-
name: PHPStan
12-
runs-on: ubuntu-20.04
13-
strategy:
14-
matrix:
15-
php-version: [7.4]
16-
dependencies: ["", --prefer-lowest]
17-
steps:
18-
- uses: actions/checkout@v2
19-
- uses: shivammathur/setup-php@v2
20-
with:
21-
coverage: none
22-
php-version: ${{ matrix.php-version }}
23-
tools: cs2pr
24-
25-
- name: Cache dependencies installed with composer
26-
uses: actions/cache@v1
27-
with:
28-
path: ~/.composer/cache
29-
key: php-${{ matrix.php-version }}-dependencies-${{ matrix.dependencies }}
30-
restore-keys: php-${{ matrix.php-version }}
31-
32-
- name: Install dependencies with composer
33-
env:
34-
COMPOSER_ARGS: "--prefer-stable ${{ matrix.dependencies }}"
35-
run: make
36-
37-
- name: Run a static analysis with phpstan/phpstan
38-
env:
39-
PHPSTAN_ARGS: --error-format=checkstyle
40-
run: make -is static-analysis | cs2pr
41-
42-
coding-standards:
43-
name: Coding Standards
44-
runs-on: ubuntu-20.04
45-
strategy:
46-
matrix:
47-
php-version: [7.4]
48-
steps:
49-
- uses: actions/checkout@v2
50-
- uses: shivammathur/setup-php@v2
51-
with:
52-
coverage: none
53-
php-version: ${{ matrix.php-version }}
54-
tools: cs2pr
55-
56-
- name: Cache dependencies installed with composer
57-
uses: actions/cache@v1
58-
with:
59-
path: ~/.composer/cache
60-
key: php-${{ matrix.php-version }}
61-
restore-keys: php-${{ matrix.php-version }}
62-
63-
- name: Install dependencies with composer
64-
env:
65-
COMPOSER_ARGS: "--prefer-stable"
66-
run: make
67-
68-
- name: Run squizlabs/php_codesniffer
69-
env:
70-
PHPCS_ARGS: -q --no-colors --report=checkstyle
71-
run: make -is cs | cs2pr
72-
73-
tests:
74-
name: Tests
75-
runs-on: ubuntu-20.04
76-
strategy:
77-
matrix:
78-
php-version: [7.4, 8.0]
79-
dependencies: ["", --prefer-lowest]
1+
name: "CI"
802

81-
steps:
82-
- uses: actions/checkout@v2
83-
- uses: shivammathur/setup-php@v2
84-
with:
85-
coverage: none
86-
php-version: ${{ matrix.php-version }}
87-
88-
- name: Cache dependencies installed with composer
89-
uses: actions/cache@v1
90-
with:
91-
path: ~/.composer/cache
92-
key: php-${{ matrix.php-version }}-dependencies-${{ matrix.dependencies }}
93-
restore-keys: php-${{ matrix.php-version }}
94-
95-
- name: Install dependencies with composer
96-
env:
97-
COMPOSER_ARGS: "--prefer-stable ${{ matrix.dependencies }}"
98-
run: make
99-
100-
- name: Run tests
101-
run: make test
102-
103-
coverage:
104-
name: Tests Coverage
105-
runs-on: ubuntu-20.04
106-
strategy:
107-
matrix:
108-
php-version: [7.4]
109-
110-
steps:
111-
- uses: actions/checkout@v2
112-
- uses: shivammathur/setup-php@v2
113-
with:
114-
coverage: pcov
115-
php-version: ${{ matrix.php-version }}
116-
117-
- name: Cache dependencies installed with composer
118-
uses: actions/cache@v1
119-
with:
120-
path: ~/.composer/cache
121-
key: php-${{ matrix.php-version }}
122-
restore-keys: php-${{ matrix.php-version }}
123-
124-
- name: Install dependencies with composer
125-
env:
126-
COMPOSER_ARGS: "--prefer-stable"
127-
run: make
128-
129-
- name: Run tests coverage
130-
env:
131-
PHPUNIT_ARGS: "--coverage-clover coverage/clover.xml"
132-
run: make test
3+
on:
4+
pull_request:
5+
push:
6+
# branches:
7+
# - "master"
8+
schedule:
9+
- cron: "42 3 * * *"
13310

134-
- name: Report to Coveralls
135-
env:
136-
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137-
COVERALLS_RUN_LOCALLY: 1
138-
run: vendor/bin/php-coveralls --coverage_clover coverage/clover.xml --json_path coverage/coveralls.json
11+
jobs:
12+
phpunit:
13+
name: "PHPUnit"
14+
runs-on: "ubuntu-20.04"
15+
16+
strategy:
17+
matrix:
18+
php-version:
19+
- "7.4"
20+
- "8.0"
21+
dependencies:
22+
- "highest"
23+
include:
24+
- dependencies: "lowest"
25+
php-version: "7.4"
26+
27+
steps:
28+
- name: "Checkout"
29+
uses: "actions/checkout@v2"
30+
with:
31+
fetch-depth: 2
32+
33+
- name: "Install PHP"
34+
uses: "shivammathur/setup-php@v2"
35+
with:
36+
php-version: "${{ matrix.php-version }}"
37+
coverage: "pcov"
38+
ini-values: "zend.assertions=1"
39+
40+
- name: "Install dependencies with Composer"
41+
uses: "ramsey/composer-install@v1"
42+
with:
43+
dependency-versions: "${{ matrix.dependencies }}"
44+
45+
- name: "Run PHPUnit"
46+
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"
47+
48+
- name: "Upload coverage file"
49+
uses: "actions/upload-artifact@v2"
50+
with:
51+
name: "phpunit-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
52+
path: "coverage.xml"
53+
54+
upload_coverage:
55+
name: "Upload coverage to Codecov"
56+
runs-on: "ubuntu-20.04"
57+
needs:
58+
- "phpunit"
59+
60+
steps:
61+
- name: "Checkout"
62+
uses: "actions/checkout@v2"
63+
with:
64+
fetch-depth: 2
65+
66+
- name: "Download coverage files"
67+
uses: "actions/download-artifact@v2"
68+
with:
69+
path: "reports"
70+
71+
- name: "Upload to Codecov"
72+
uses: "codecov/codecov-action@v1"
73+
with:
74+
directory: reports
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Coding Standards"
2+
3+
on:
4+
pull_request:
5+
push:
6+
# branches:
7+
# - "master"
8+
9+
jobs:
10+
coding-standards:
11+
name: "Coding Standards"
12+
runs-on: "ubuntu-20.04"
13+
14+
steps:
15+
- name: "Checkout"
16+
uses: "actions/checkout@v2"
17+
18+
- name: "Install PHP"
19+
uses: "shivammathur/setup-php@v2"
20+
with:
21+
php-version: "7.4"
22+
coverage: "none"
23+
tools: "cs2pr, pecl"
24+
25+
- name: "Install dependencies with Composer"
26+
uses: "ramsey/composer-install@v1"
27+
28+
- name: "Run PHP_CodeSniffer"
29+
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"

.github/workflows/infection.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Infection
2+
3+
on:
4+
pull_request:
5+
push:
6+
# branches:
7+
# - "master"
8+
9+
jobs:
10+
Infection:
11+
runs-on: ubuntu-20.04
12+
13+
steps:
14+
- name: "Checkout"
15+
uses: "actions/checkout@v2"
16+
with:
17+
fetch-depth: 2
18+
19+
- name: "Install PHP"
20+
uses: "shivammathur/setup-php@v2"
21+
with:
22+
php-version: "7.4"
23+
coverage: "pcov"
24+
25+
- name: "Install dependencies with Composer"
26+
uses: "ramsey/composer-install@v1"
27+
28+
- name: Run Infection
29+
run: vendor/bin/roave-infection-static-analysis-plugin --min-msi=60 --min-covered-msi=93 --log-verbosity=none -s
30+
env:
31+
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
pull_request:
5+
push:
6+
# branches:
7+
# - "master"
8+
9+
jobs:
10+
static-analysis-phpstan:
11+
name: "Static Analysis with PHPStan"
12+
runs-on: "ubuntu-20.04"
13+
14+
steps:
15+
- name: "Checkout code"
16+
uses: "actions/checkout@v2"
17+
18+
- name: "Install PHP"
19+
uses: "shivammathur/setup-php@v2"
20+
with:
21+
php-version: "7.4"
22+
coverage: "none"
23+
tools: "cs2pr, pecl"
24+
25+
- name: "Install dependencies with Composer"
26+
uses: "ramsey/composer-install@v1"
27+
28+
- name: "Run a static analysis with phpstan/phpstan"
29+
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
30+
31+
static-analysis-psalm:
32+
name: "Static Analysis with Psalm"
33+
runs-on: "ubuntu-20.04"
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Psalm
40+
uses: docker://vimeo/psalm-github-actions:4.4.1
41+
with:
42+
args: --shepherd
43+
composer_ignore_platform_reqs: true
44+
composer_require_dev: true
45+
security_analysis: true
46+
report_file: results.sarif
47+
env:
48+
CHECK_PLATFORM_REQUIREMENTS: "false"
49+
- name: Upload Security Analysis results to GitHub
50+
uses: github/codeql-action/upload-sarif@v1
51+
with:
52+
sarif_file: results.sarif

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/.phpcs-cache
22
/.phpunit.result.cache
33
/composer.lock
4+
/infection.json
45
/phpcs.xml
56
/phpstan.neon
7+
/psalm.xml
68
/phpunit.xml
79
/vendor/

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Cdn77 TestUtils
22

3-
[![Build Status](https://github.com/cdn77/TestUtils/workflows/CI/badge.svg?branch=master)](https://github.com/cdn77/TestUtils/actions)
4-
[![Coverage Status](https://coveralls.io/repos/github/cdn77/TestUtils/badge.svg?branch=master)](https://coveralls.io/github/cdn77/TestUtils?branch=master)
5-
[![Downloads](https://poser.pugx.org/cdn77/test-utils/d/total.svg)](https://packagist.org/packages/cdn77/test-utils)
3+
[![GitHub Actions][GA Image]][GA Link]
4+
[![Shepherd Type][Shepherd Image]][Shepherd Link]
5+
[![Code Coverage][Coverage Image]][CodeCov Link]
6+
[![Downloads][Downloads Image]][Packagist Link]
7+
[![Packagist][Packagist Image]][Packagist Link]
8+
[![Infection MSI][Infection Image]][Infection Link]
69

710
## Contents
811

@@ -235,3 +238,25 @@ yield 'Every test is final' => [
235238
new EveryTestIsFinal($testFiles),
236239
];
237240
```
241+
242+
[GA Image]: https://github.com/cdn77/TestUtils/workflows/CI/badge.svg
243+
244+
[GA Link]: https://github.com/cdn77/TestUtils/actions?query=workflow%3A%22CI%22+branch%3Amaster
245+
246+
[Shepherd Image]: https://shepherd.dev/github/cdn77/TestUtils/coverage.svg
247+
248+
[Shepherd Link]: https://shepherd.dev/github/cdn77/TestUtils
249+
250+
[Coverage Image]: https://codecov.io/gh/cdn77/TestUtils/branch/master/graph/badge.svg
251+
252+
[CodeCov Link]: https://codecov.io/gh/cdn77/TestUtils/branch/master
253+
254+
[Downloads Image]: https://poser.pugx.org/cdn77/test-utils/d/total.svg
255+
256+
[Packagist Image]: https://poser.pugx.org/cdn77/test-utils/v/stable.svg
257+
258+
[Packagist Link]: https://packagist.org/packages/simpod/test-utils
259+
260+
[Infection Image]: https://badge.stryker-mutator.io/github.com/cdn77/TestUtils/master
261+
262+
[Infection Link]: https://infection.github.io

0 commit comments

Comments
 (0)