forked from PartExa/PartExa
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.79 KB
/
coverage.yml
File metadata and controls
75 lines (63 loc) · 2.79 KB
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
name: Coverage
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container:
image: dealii/dealii:master-focal
options: --user root
steps:
- name: Setup
run: |
apt-get update
apt-get install -y lcov bc
- uses: actions/checkout@v2
- name: Compile
run: |
mkdir build
cd build
cmake ../ -DCMAKE_CXX_FLAGS="-Werror -O0 -fprofile-arcs -ftest-coverage" -DCMAKE_EXE_LINKER_FLAGS="-lgcov" -DCMAKE_BUILD_TYPE=Release
make test
- name: Generate
run: |
lcov --capture --initial --no-external --directory ./build --base-directory . --output-file coverage_base.info >> coverage.out 2>> coverage.err
lcov --capture --no-external --directory ./build --base-directory . --output-file coverage_tests.info >> coverage.out 2>> coverage.err
lcov --add-tracefile coverage_base.info --add-tracefile coverage_tests.info --output-file coverage.info >> coverage.out 2>> coverage.err
lcov --remove coverage.info '*/tests/*' '*/CMakeCXXCompilerId.cpp' -o coverage_filtered.info >> coverage.out 2>> coverage.err 2>> coverage.err
genhtml coverage_filtered.info --legend --demangle-cpp --output-directory ./coverage_report --title "PartExa coverage report" >> coverage.out 2>> coverage.err
grep "Overall coverage rate:" -A 2 coverage.out
- name: Badge
run: |
mkdir ./coverage_report/badge
CVGE="$(grep "Overall coverage rate:" -A 2 coverage.out | grep "lines" | grep -oE "[[:digit:]]{1,3}.[[:digit:]]")"
if (( $(echo "$CVGE < 75.0" | bc -l) )); then COLOR=E03E28; elif (( $(echo "$CVGE < 90.0" | bc -l) )); then COLOR=E8C62E; else COLOR=34D058; fi
wget "https://img.shields.io/static/v1?label=Coverage&labelColor=323940&message=$CVGE%25&color=$COLOR" -O ./coverage_report/badge/badge.svg
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage_report
deploy:
if: ${{ github.repository_owner == 'PartExa' && ( github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ) }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: coverage
path: ./coverage_report
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY_COVERAGE }}
external_repository: PartExa/PartExa-Coverage
publish_branch: master
publish_dir: ./coverage_report