@@ -5,56 +5,100 @@ on: [push]
55jobs :
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@v2
13+ - uses : actions/checkout@v4
1114
1215 - name : Cache Composer dependencies
13- uses : actions/cache@v2
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@v2
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@v2
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.0
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@v2
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,20 @@ jobs:
63107 - name : PHP Static Analysis
64108 uses : php-actions/phpstan@v3
65109 with :
110+ php_version : ${{ matrix.php }}
66111 path : src/
112+
113+ remove_old_artifacts :
114+ runs-on : ubuntu-latest
115+
116+ steps :
117+ - name : Remove old artifacts for prior workflow runs on this repository
118+ env :
119+ GH_TOKEN : ${{ github.token }}
120+ run : |
121+ gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name | startswith(\"build-artifact\")) | .id" > artifact-id-list.txt
122+ while read id
123+ do
124+ echo -n "Deleting artifact ID $id ... "
125+ gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
126+ done <artifact-id-list.txt
0 commit comments