-
Notifications
You must be signed in to change notification settings - Fork 27
48 lines (41 loc) · 1.45 KB
/
github-workflow.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
---
name: Coverage
on:
push:
branches:
- main
- dev
jobs:
coverage:
runs-on: ubuntu-22.04
container:
image: kcov/kcov:v42
options: --privileged
# volumes:
# - ${{ github.workspace }}:/workspace
steps:
- name: Checkout code
uses: actions/checkout@v3.6.0
- name: Install specific version of bats
run: |
curl -L https://github.com/bats-core/bats-core/archive/v1.4.1.tar.gz | tar -xz
cd bats-core-1.4.1
./install.sh /usr/local
rm -rf bats-core-1.4.1
- name: Run coverage script
run: |
chmod +x ./coverage.sh
./coverage.sh
- name: Generate coverage percentage
id: coverage
run: |
coverage=$(grep -o 'Overall coverage rate.*' <path_to_coverage_report> | grep -o '[0-9]*\.[0-9]*')
echo "::set-output name=coverage::$coverage"
- name: Update README.md with coverage badge
run: |
sed -i 's|\[!\[Coverage\](https://img.shields.io/badge/Coverage-[0-9]*%25-brightgreen)\]|[!\[Coverage\](https://img.shields.io/badge/Coverage-${{ steps.coverage.outputs.coverage }}%25-brightgreen)]|' README.md
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git commit -m "Update coverage badge"
git push origin main