@@ -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@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
0 commit comments