-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.63 KB
/
php.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
80
81
82
83
84
85
86
name: Deps & Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run phpstan
id: PHPStan
run: composer run-script phpstan
- name: Run test suite
id: PHPUnit
run: composer run-script phpunit-cov -- --coverage-clover=coverage.xml
- name: Check test coverage
uses: johanvanhelden/gha-clover-test-coverage-check@v1
id: coverage
with:
percentage: "90"
filename: "coverage.xml"
# Use the output from the `coverage` step
- name: Generate the badge SVG image
uses: emibcn/badge-action@v1
id: badge
with:
label: 'PHPUnit Coverage'
status: ${{ steps.coverage.outputs.coverage-rounded-display }}
path: ./test-coverage.svg
color: ${{
steps.coverage.outputs.coverage > 90 && 'green' ||
steps.coverage.outputs.coverage > 80 && 'yellow,green' ||
steps.coverage.outputs.coverage > 70 && 'yellow' ||
steps.coverage.outputs.coverage > 60 && 'orange,yellow' ||
steps.coverage.outputs.coverage > 50 && 'orange' ||
steps.coverage.outputs.coverage > 40 && 'red,orange' ||
steps.coverage.outputs.coverage > 30 && 'red,red,orange' ||
steps.coverage.outputs.coverage > 20 && 'red,red,red,orange' ||
'red' }}
- name: Update gist
uses: sergeysova/jq-action@v2
id: gist
with:
cmd: |
jq --null-input '{description: $description, public: true, files:{"badge.svg": {content: $file}}}' \
--arg description "Badge from coverage testing" \
--rawfile file test-coverage.svg | curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GIST_API_TOKEN }}" \
https://api.github.com/gists/a143261dcd5d0d9456c01f854eccecd0 \
--data @-