forked from coenjacobs/mozart
-
Notifications
You must be signed in to change notification settings - Fork 25
81 lines (65 loc) · 2.31 KB
/
codecoverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Code Coverage
# Runs PHPUnit with code coverage enabled, commits the html report to
# GitHub Pages, generates a README badge with the coverage percentage.
#
# Requires a gh-pages branch already created.
#
# git checkout --orphan gh-pages
# touch index.html
# git add index.html
# git commit -m 'Set up gh-pages branch' index.html
# git push origin gh-pages
#
# @author BrianHenryIE
on:
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
- name: Checkout GitHub Pages branch for code coverage report
uses: actions/checkout@v2
with:
ref: gh-pages
path: tests/reports/html
- name: Install dependencies
run: composer install --prefer-dist --no-suggest --no-progress
- name: Clear previous code coverage
run: |
cd tests/reports/html
rm -rf *
cd ../../..
- name: Run tests with code coverage
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover tests/reports/clover.xml --coverage-html tests/reports/html
- name: Edit phpcov html output to work with gh-pages
run: |
cd tests/reports/html
mv _css css; find . -depth -name '*.html' -exec sed -i "s/_css\//css\//" {} +
mv _icons icons; find . -depth -name '*.html' -exec sed -i "s/_icons\//icons\//" {} +
mv _js js; find . -depth -name '*.html' -exec sed -i "s/_js\//js\//" {} +
git add *
cd ../../..
- name: Commit code coverage to gh-pages
uses: stefanzweifel/[email protected]
with:
repository: tests/reports/html
branch: gh-pages
commit_message: "🤖 Commit code coverage to gh-pages"
commit_options:
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Update README badge
run: vendor/bin/php-coverage-badger tests/reports/clover.xml .github/coverage.svg
- name: Commit code coverage badge
uses: stefanzweifel/[email protected]
with:
commit_message: "🤖 Commit code coverage badge"