-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (85 loc) · 2.64 KB
/
testing.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
87
88
89
name: Testing
on:
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-20.04
name: test
steps:
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: xdebug
- uses: actions/checkout@v3
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
run: composer run-script test
coverage:
needs: [ test ]
name: coverage
permissions: write-all
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Comment code coverage
uses: danhunsaker/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
clover-file: ./tests/clover.xml
- name: Store coverage output
run: |
output=$(composer run-script current-coverage)
echo "::set-output name=percent::$output"
id: pure-coverage
- name: Set color
uses: marcdomain/set-variables@v1
with:
variables: |
BADGE_COLOR: ${{ steps.pure-coverage.outputs.percent }} > 90 ? "green" : "yellow"
- uses: actions/checkout@v4
with:
ref: 'badges'
- name: generate current time
uses: gerred/[email protected]
id: current-time
- name: amend to history
uses: DamianReeves/write-file-action@master
with:
path: '.github/badges/history'
contents: |
${{steps.current-time.outputs.time}}
write-mode: append
- name: Generate the badge SVG image
uses: emibcn/badge-action@v1
id: badge
with:
label: 'Test coverage'
status: ${{ steps.pure-coverage.outputs.percent }}%
color: ${{ env.BADGE_COLOR }}
path: '.github/badges/test-badge.svg'
- name: Upload badge as artifact
uses: actions/upload-artifact@v2
with:
name: badge
path: '.github/badges/test-badge.svg'
if-no-files-found: error
- name: Commit badge
env:
BADGE: '.github/badges/test-badge.svg'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add/Update badge"
- name: Push badge commit
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'badges'