@@ -5,56 +5,100 @@ on: [push]
5
5
jobs :
6
6
composer :
7
7
runs-on : ubuntu-latest
8
+ strategy :
9
+ matrix :
10
+ php : [ 8.1, 8.2, 8.3, 8.4 ]
8
11
9
12
steps :
10
- - uses : actions/checkout@v2
13
+ - uses : actions/checkout@v4
11
14
12
15
- name : Cache Composer dependencies
13
- uses : actions/cache@v2
16
+ uses : actions/cache@v4
14
17
with :
15
18
path : /tmp/composer-cache
16
- key : ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
19
+ key : ${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
17
20
18
- - uses : php-actions/composer@v6
21
+ - name : Composer install
22
+ uses : php-actions/composer@v6
23
+ with :
24
+ php_version : ${{ matrix.php }}
19
25
20
26
- name : Archive build
21
27
run : mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
22
28
23
29
- name : Upload build archive for test runners
24
- uses : actions/upload-artifact@v2
30
+ uses : actions/upload-artifact@v4
25
31
with :
26
- name : build-artifact
32
+ name : build-artifact-${{ matrix.php }}
27
33
path : /tmp/github-actions
28
34
29
35
phpunit :
30
36
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 }}
32
44
33
45
steps :
34
- - uses : actions/download-artifact@v2
46
+ - uses : actions/download-artifact@v4
35
47
with :
36
- name : build-artifact
48
+ name : build-artifact-${{ matrix.php }}
37
49
path : /tmp/github-actions
38
50
39
51
- name : Extract build archive
40
52
run : tar -xvf /tmp/github-actions/build.tar ./
41
53
42
54
- name : PHP Unit tests
43
- uses : php-actions/phpunit@v3
55
+ uses : php-actions/phpunit@v4
56
+ env :
57
+ XDEBUG_MODE : cover
44
58
with :
45
- php_version : 8.0
59
+ php_version : ${{ matrix.php }}
46
60
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
49
90
50
91
phpstan :
51
92
runs-on : ubuntu-latest
52
- needs : [composer]
93
+ needs : [ composer ]
94
+ strategy :
95
+ matrix :
96
+ php : [ 8.1, 8.2, 8.3, 8.4 ]
53
97
54
98
steps :
55
- - uses : actions/download-artifact@v2
99
+ - uses : actions/download-artifact@v4
56
100
with :
57
- name : build-artifact
101
+ name : build-artifact-${{ matrix.php }}
58
102
path : /tmp/github-actions
59
103
60
104
- name : Extract build archive
@@ -63,4 +107,20 @@ jobs:
63
107
- name : PHP Static Analysis
64
108
uses : php-actions/phpstan@v3
65
109
with :
110
+ php_version : ${{ matrix.php }}
66
111
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