@@ -5,33 +5,45 @@ on: [push]
55jobs :
66 composer :
77 runs-on : ubuntu-latest
8+ strategy :
9+ matrix :
10+ php : [ 8.0, 8.1, 8.2 ]
811
912 steps :
10- - uses : actions/checkout@v2
13+ - uses : actions/checkout@v3
1114
1215 - name : Cache Composer dependencies
13- uses : actions/cache@v2
16+ uses : actions/cache@v3
1417 with :
1518 path : /tmp/composer-cache
1619 key : ${{ runner.os }}-${{ 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@v3
2531 with :
2632 name : build-artifact
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.0, 8.1, 8.2 ]
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@v3
3547 with :
3648 name : build-artifact
3749 path : /tmp/github-actions
@@ -41,18 +53,47 @@ jobs:
4153
4254 - name : PHP Unit tests
4355 uses : php-actions/phpunit@v3
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@v3
66+ with :
67+ name : code-coverage
68+ path : _coverage
69+
70+ coverage :
71+ runs-on : ubuntu-latest
72+ needs : [ phpunit ]
73+
74+ steps :
75+ - uses : actions/checkout@v3
76+
77+ - uses : actions/download-artifact@v3
78+ with :
79+ name : code-coverage
80+ path : _coverage
81+
82+ - name : Output coverage
83+ run : cat "_coverage/coverage.txt"
84+
85+ - name : Upload to Codecov
86+ uses : codecov/codecov-action@v3
4987
5088 phpstan :
5189 runs-on : ubuntu-latest
52- needs : [composer]
90+ needs : [ composer ]
91+ strategy :
92+ matrix :
93+ php : [ 8.0, 8.1, 8.2 ]
5394
5495 steps :
55- - uses : actions/download-artifact@v2
96+ - uses : actions/download-artifact@v3
5697 with :
5798 name : build-artifact
5899 path : /tmp/github-actions
@@ -63,5 +104,68 @@ jobs:
63104 - name : PHP Static Analysis
64105 uses : php-actions/phpstan@v3
65106 with :
107+ php_version : ${{ matrix.php }}
66108 path : src/
67- level : 6
109+
110+ # TODO: Uncomment these once phpms and phpcs are happy https://github.com/PhpGt/Routing/pull/53
111+ # phpmd:
112+ # runs-on: ubuntu-latest
113+ # needs: [ composer ]
114+ # strategy:
115+ # matrix:
116+ # php: [ 8.0, 8.1, 8.2 ]
117+ #
118+ # steps:
119+ # - uses: actions/download-artifact@v3
120+ # with:
121+ # name: build-artifact
122+ # path: /tmp/github-actions
123+ #
124+ # - name: Extract build archive
125+ # run: tar -xvf /tmp/github-actions/build.tar ./
126+ #
127+ # - name: PHP Mess Detector
128+ # uses: php-actions/phpmd@v1
129+ # with:
130+ # php_version: ${{ matrix.php }}
131+ # path: src/
132+ # output: text
133+ # ruleset: phpmd.xml
134+ #
135+ # phpcs:
136+ # runs-on: ubuntu-latest
137+ # needs: [ composer ]
138+ # strategy:
139+ # matrix:
140+ # php: [ 8.0, 8.1, 8.2 ]
141+ #
142+ # steps:
143+ # - uses: actions/download-artifact@v3
144+ # with:
145+ # name: build-artifact
146+ # path: /tmp/github-actions
147+ #
148+ # - name: Extract build archive
149+ # run: tar -xvf /tmp/github-actions/build.tar ./
150+ #
151+ # - name: PHP Code Sniffer
152+ # uses: php-actions/phpcs@v1
153+ # with:
154+ # php_version: ${{ matrix.php }}
155+ # path: src/
156+ # standard: phpcs.xml
157+
158+ remove_old_artifacts :
159+ runs-on : ubuntu-latest
160+
161+ steps :
162+ - name : Remove old artifacts for prior workflow runs on this repository
163+ env :
164+ GH_TOKEN : ${{ github.token }}
165+ run : |
166+ gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name == \"build-artifact\") | .id" > artifact-id-list.txt
167+ while read id
168+ do
169+ echo -n "Deleting artifact ID $id ... "
170+ gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
171+ done <artifact-id-list.txt
0 commit comments