forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (74 loc) · 2.47 KB
/
go-ci-coverage.yaml
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
name: go-ci-coverage
on:
push:
branches:
- "master"
jobs:
coverage:
name: generate-coverage
runs-on: ubuntu-latest
outputs:
coverage: ${{ steps.testcov.outputs.coverage }}
color: ${{ steps.testcov.outputs.color }}
steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Run test metrics script
id: testcov
run: |
make test-coverage-report | tee test-results
TOTAL_TESTS=$(cat test-results | grep -v TestQueriesContent/ | grep -v TestQueriesMetadata/ | grep -v TestQueries/ | grep PASS | wc -l)
echo "Total Tests :: ${TOTAL_TESTS}"
echo "::set-output name=total_tests::${TOTAL_TESTS}"
- name: Generate badge
run: |
curl -L \
https://img.shields.io/badge/Go%20Coverage-${{ steps.testcov.outputs.coverage }}%25-${{ steps.testcov.outputs.color }}.svg > coverage.svg
cat coverage.svg
- uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-badge-latest
path: coverage.svg
- uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-coverage-latest
path: coverage.html
publish:
name: publish-coverage
runs-on: ubuntu-latest
needs: coverage
steps:
- name: Checkout Source
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Configure git commit author
run: |
git config --global user.name "KICSBot"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Download Coverage Report
uses: actions/download-artifact@master
with:
name: ${{ runner.os }}-coverage-latest
path: latest-coverage
- name: Download Badge svg
uses: actions/download-artifact@master
with:
name: ${{ runner.os }}-badge-latest
path: latest-coverage
- name: Generate badge
run: |
mv latest-coverage/coverage.html coverage.html
mv latest-coverage/coverage.svg coverage.svg
git add coverage.svg
git add coverage.html
if ! git status | grep "nothing to commit"; then
git commit -m 'chore(tests): updating test coverage report and badge';
git push origin gh-pages;
fi