forked from 4C-multiphysics/4C
-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (166 loc) · 7.14 KB
/
Copy pathcoverage.yml
File metadata and controls
171 lines (166 loc) · 7.14 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: coverage
on:
schedule:
# GitHub recommends avoiding scheduling at the start of the hour to avoid delays; thus, a random minute is set.
- cron: '29 0 * * *'
timezone: "Europe/Berlin"
jobs:
clang18_coverage_build:
runs-on: ubuntu-latest
container:
image: ghcr.io/4c-multiphysics/4c-dependencies-ubuntu24.04:bf9c337f
options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
defaults:
run:
shell: bash
outputs:
test-chunks: ${{ steps.set-matrix.outputs.chunk-array }}
steps:
- uses: actions/checkout@v7
- name: Check docker hash
uses: ./.github/actions/compute-and-check-dependencies-hash
- uses: ./.github/actions/build_4C
with:
cmake-preset: docker_coverage
build-targets: full
build-directory: ${{ github.workspace }}/build
use-ccache: "false"
- uses: ./.github/actions/upload_directory
name: Upload 4C build
with:
directory: ${{ github.workspace }}/build
retention-days: 1
name: clang18_coverage_build
- uses: ./.github/actions/chunk_test_suite
id: set-matrix
# Note: We will not use previous runtimes for chunking to avoid running out of storage
with:
build-directory: ${{ github.workspace }}/build
source-directory: ${{ github.workspace }}
number-of-chunks: 30
# We need to limit the number of tests * processors to avoid accumulation of large temporary data
maximum-number-of-processor-tests: 50
clang18_coverage_test:
needs: clang18_coverage_build
runs-on: ubuntu-latest
container:
image: ghcr.io/4c-multiphysics/4c-dependencies-ubuntu24.04:bf9c337f
options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
strategy:
fail-fast: false
matrix:
test-chunk: ${{fromJson(needs.clang18_coverage_build.outputs.test-chunks)}}
defaults:
run:
shell: bash
steps:
- name: Install dependencies
run: |
apt-get update
apt-get upgrade -y
apt-get install -y llvm
- uses: actions/checkout@v7
- name: Check docker hash
uses: ./.github/actions/compute-and-check-dependencies-hash
- uses: ./.github/actions/download_directory
with:
name: clang18_coverage_build
destination: ${{ github.workspace }}/build
- name: Run all tests and collect raw coverage data
run: | # Note: Collect raw coverage data in a file distict for each process
cd $GITHUB_WORKSPACE/build
export LLVM_PROFILE_FILE="$GITHUB_WORKSPACE/4C-coverage-%m-%p.profraw"
time ctest -I $TEST_CHUNK -j `nproc` --output-on-failure --output-junit $GITHUB_WORKSPACE/clang18_coverage_test_report-$TEST_CHUNK.xml
env:
TEST_CHUNK: ${{ matrix.test-chunk }}
- name: Collect coverage data
run: |
cd $GITHUB_WORKSPACE/build
llvm-profdata merge -sparse $GITHUB_WORKSPACE/*.profraw -o $GITHUB_WORKSPACE/4C-coverage-data-$TEST_CHUNK.profdata
env:
TEST_CHUNK: ${{ matrix.test-chunk }}
- name: Upload merged coverage data
uses: actions/upload-artifact@v7
with:
name: ${{ github.job }}-4C-coverage-data-${{ matrix.test-chunk }}.profdata
path: |
${{ github.workspace }}/4C-coverage-data-${{ matrix.test-chunk }}.profdata
retention-days: 1
- name: Upload test report
uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: clang18_coverage_test_report-${{ matrix.test-chunk }}.xml
path: |
${{ github.workspace }}/clang18_coverage_test_report-${{ matrix.test-chunk }}.xml
retention-days: 1
clang18_coverage_test_report:
needs: clang18_coverage_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
sparse-checkout: .github
- uses: ./.github/actions/merge_junit_report_artifacts
with:
junit-report-base-name: clang18_coverage_test_report
retention-days: 2
report:
needs: [clang18_coverage_test, clang18_coverage_build]
runs-on: ubuntu-latest
container:
image: ghcr.io/4c-multiphysics/4c-dependencies-ubuntu24.04:bf9c337f
options: --user root --env OMPI_ALLOW_RUN_AS_ROOT=1 --env OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
steps:
- uses: actions/checkout@v7
- name: Check docker hash
uses: ./.github/actions/compute-and-check-dependencies-hash
- name: Setup developer environment for testing
run: |
cd $GITHUB_WORKSPACE
git config --global --add safe.directory $GITHUB_WORKSPACE
- uses: ./.github/actions/download_directory
with:
name: clang18_coverage_build
destination: ${{ github.workspace }}/build
- name: Setup developer environment for testing
run: |
cd $GITHUB_WORKSPACE
git config --global --add safe.directory $GITHUB_WORKSPACE
./utilities/set_up_dev_env.sh
- name: Download reports
uses: actions/download-artifact@v8
with:
path: ${{ github.workspace }}
merge-multiple: true
pattern: clang18_coverage_test-4C-coverage-data-*.profdata
- name: Install dependencies
run: |
apt-get update
apt-get install -y llvm
- name: Merge coverage data
run: |
cd $GITHUB_WORKSPACE
llvm-profdata merge -sparse *.profdata -o 4C-coverage-data.profdata
- name: Print of coverage report summary
run: |
cd $GITHUB_WORKSPACE
llvm-cov report --object ./build/lib4C.so --use-color --format=text --instr-profile=4C-coverage-data.profdata --show-branch-summary --show-instantiation-summary --show-region-summary --ignore-filename-regex=".*/build/.*"
- name: Generate coverage report
run: |
cd $GITHUB_WORKSPACE
llvm-cov show --object ./build/lib4C.so --use-color --output-dir=coverage_report --format=html --instr-profile=4C-coverage-data.profdata --show-branches=percent --show-directory-coverage --show-line-counts-or-regions -Xdemangler c++filt --project-title=4C --show-expansions --show-instantiations --ignore-filename-regex=".*/build/.*" --show-instantiation-summary
- name: Create coverage badge
run: |
cd $GITHUB_WORKSPACE
python -m venv venv
. venv/bin/activate
pip install anybadge
COVERAGE_PERCENT=`llvm-cov export --object ./build/lib4C.so --format=text --instr-profile=4C-coverage-data.profdata --summary-only --ignore-filename-regex=".*/build/.*" | python -c 'import json, sys; print(json.load(sys.stdin)["data"][0]["totals"]["lines"]["percent"])'`
anybadge -l coverage --suffix=" %" --value=$COVERAGE_PERCENT -m "%.2f" 75=red 90=orange 100=green > coverage_report/badge_coverage.svg
- name: Upload coverage html report
uses: actions/upload-artifact@v7
with:
name: 4C_coverage_report
path: ${{ github.workspace }}/coverage_report
retention-days: 2