Skip to content

Commit 3daab88

Browse files
author
Greg Bowler
authored
ci: introduce multi build runners (#36)
* docs: remove scrutinizer * docs: add badges * ci: upgrade ci * build: upgrade dependencies * test: upgrade test runners * build: php 8.1 compatibility
1 parent 3d2bdec commit 3daab88

14 files changed

+1611
-649
lines changed

.github/workflows/ci.yml

+123-16
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,100 @@ on: [push]
55
jobs:
66
composer:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php: [ 8.1, 8.2, 8.3, 8.4 ]
811

912
steps:
10-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1114

1215
- name: Cache Composer dependencies
13-
uses: actions/cache@v3
16+
uses: actions/cache@v4
1417
with:
1518
path: /tmp/composer-cache
16-
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
19+
key: ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
1720

18-
- uses: php-actions/composer@v6
21+
- name: Composer install
22+
uses: php-actions/composer@v6
23+
with:
24+
php_version: ${{ matrix.php }}
1925

2026
- name: Archive build
2127
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
2228

2329
- name: Upload build archive for test runners
24-
uses: actions/upload-artifact@v3
30+
uses: actions/upload-artifact@v4
2531
with:
26-
name: build-artifact
32+
name: build-artifact-${{ matrix.php }}
2733
path: /tmp/github-actions
2834

2935
phpunit:
3036
runs-on: ubuntu-latest
31-
needs: [composer]
37+
needs: [ composer ]
38+
strategy:
39+
matrix:
40+
php: [ 8.1, 8.2, 8.3, 8.4 ]
41+
42+
outputs:
43+
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
3244

3345
steps:
34-
- uses: actions/download-artifact@v3
46+
- uses: actions/download-artifact@v4
3547
with:
36-
name: build-artifact
48+
name: build-artifact-${{ matrix.php }}
3749
path: /tmp/github-actions
3850

3951
- name: Extract build archive
4052
run: tar -xvf /tmp/github-actions/build.tar ./
4153

4254
- name: PHP Unit tests
43-
uses: php-actions/phpunit@v3
55+
uses: php-actions/phpunit@v4
56+
env:
57+
XDEBUG_MODE: cover
4458
with:
45-
php_version: 8.1
59+
php_version: ${{ matrix.php }}
4660
php_extensions: xdebug
47-
configuration: test/phpunit/phpunit.xml
48-
bootstrap: vendor/autoload.php
61+
coverage_text: _coverage/coverage.txt
62+
coverage_clover: _coverage/clover.xml
63+
64+
- name: Store coverage data
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: code-coverage-${{ matrix.php }}-${{ github.run_number }}
68+
path: _coverage
69+
70+
coverage:
71+
runs-on: ubuntu-latest
72+
needs: [ phpunit ]
73+
strategy:
74+
matrix:
75+
php: [ 8.1, 8.2, 8.3, 8.4 ]
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- uses: actions/download-artifact@v4
81+
with:
82+
name: code-coverage-${{ matrix.php }}-${{ github.run_number }}
83+
path: _coverage
84+
85+
- name: Output coverage
86+
run: cat "_coverage/coverage.txt"
87+
88+
- name: Upload to Codecov
89+
uses: codecov/codecov-action@v5
4990

5091
phpstan:
5192
runs-on: ubuntu-latest
52-
needs: [composer]
93+
needs: [ composer ]
94+
strategy:
95+
matrix:
96+
php: [ 8.1, 8.2, 8.3, 8.4 ]
5397

5498
steps:
55-
- uses: actions/download-artifact@v3
99+
- uses: actions/download-artifact@v4
56100
with:
57-
name: build-artifact
101+
name: build-artifact-${{ matrix.php }}
58102
path: /tmp/github-actions
59103

60104
- name: Extract build archive
@@ -63,4 +107,67 @@ jobs:
63107
- name: PHP Static Analysis
64108
uses: php-actions/phpstan@v3
65109
with:
110+
php_version: ${{ matrix.php }}
111+
path: src/
112+
113+
phpmd:
114+
runs-on: ubuntu-latest
115+
needs: [ composer ]
116+
strategy:
117+
matrix:
118+
php: [ 8.1, 8.2, 8.3, 8.4 ]
119+
120+
steps:
121+
- uses: actions/download-artifact@v4
122+
with:
123+
name: build-artifact-${{ matrix.php }}
124+
path: /tmp/github-actions
125+
126+
- name: Extract build archive
127+
run: tar -xvf /tmp/github-actions/build.tar ./
128+
129+
- name: PHP Mess Detector
130+
uses: php-actions/phpmd@v1
131+
with:
132+
php_version: ${{ matrix.php }}
133+
path: src/
134+
output: text
135+
ruleset: phpmd.xml
136+
137+
phpcs:
138+
runs-on: ubuntu-latest
139+
needs: [ composer ]
140+
strategy:
141+
matrix:
142+
php: [ 8.1, 8.2, 8.3, 8.4 ]
143+
144+
steps:
145+
- uses: actions/download-artifact@v4
146+
with:
147+
name: build-artifact-${{ matrix.php }}
148+
path: /tmp/github-actions
149+
150+
- name: Extract build archive
151+
run: tar -xvf /tmp/github-actions/build.tar ./
152+
153+
- name: PHP Code Sniffer
154+
uses: php-actions/phpcs@v1
155+
with:
156+
php_version: ${{ matrix.php }}
66157
path: src/
158+
standard: phpcs.xml
159+
160+
remove_old_artifacts:
161+
runs-on: ubuntu-latest
162+
163+
steps:
164+
- name: Remove old artifacts for prior workflow runs on this repository
165+
env:
166+
GH_TOKEN: ${{ github.token }}
167+
run: |
168+
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
169+
while read id
170+
do
171+
echo -n "Deleting artifact ID $id ... "
172+
gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
173+
done <artifact-id-list.txt

.scrutinizer.yml

-32
This file was deleted.

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ This repository provides the concepts of a `Loop`, different `Timer` implementat
88
***
99

1010
<a href="https://github.com/PhpGt/Async/actions" target="_blank">
11-
<img src="https://badge.status.php.gt/async-build" alt="PHP.Gt/Async build status" />
11+
<img src="https://badge.status.php.gt/async-build.svg" alt="PHP.Gt/Async build status" />
1212
</a>
13-
<a href="https://scrutinizer-ci.com/g/PhpGt/Async" target="_blank">
14-
<img src="https://badge.status.php.gt/async-quality" alt="PHP.Gt/Async code quality" />
13+
<a href="https://app.codacy.com/gh/PhpGt/Async" target="_blank">
14+
<img src="https://badge.status.php.gt/async-quality.svg" alt="PHP.Gt/Async code quality" />
1515
</a>
16-
<a href="https://scrutinizer-ci.com/g/PhpGt/Async" target="_blank">
17-
<img src="https://badge.status.php.gt/async-coverage" alt="PHP.Gt/Async code coverage" />
16+
<a href="https://app.codacy.com/gh/PhpGt/Async" target="_blank">
17+
<img src="https://badge.status.php.gt/async-coverage.svg" alt="PHP.Gt/Async code coverage" />
1818
</a>
1919
<a href="https://packagist.PhpGt/packages/PhpGt/Async" target="_blank">
20-
<img src="https://badge.status.php.gt/async-version" alt="PHP.Gt/Async latest release" />
20+
<img src="https://badge.status.php.gt/async-version.svg" alt="PHP.Gt/Async latest release" />
2121
</a>
2222
<a href="http://www.php.gt/Async" target="_blank">
23-
<img src="https://badge.status.php.gt/async-docs" alt="PHP.Gt/Async documentation" />
23+
<img src="https://badge.status.php.gt/async-docs.svg" alt="PHP.Gt/Async documentation" />
2424
</a>
2525

2626
Example usage

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"license": "MIT",
55

66
"require": {
7-
"php": ">=7.4",
7+
"php": ">=8.1",
88
"ext-dom": "*",
99
"phpgt/promise": "^2.0"
1010
},
1111
"require-dev": {
12-
"phpstan/phpstan": "^v1.8",
13-
"phpunit/phpunit": "^v9.5"
12+
"phpstan/phpstan": "^1.10",
13+
"phpunit/phpunit": "^10.1",
14+
"phpmd/phpmd": "^2.13",
15+
"squizlabs/php_codesniffer": "^3.7"
1416
},
1517

1618
"autoload": {

0 commit comments

Comments
 (0)