-
Notifications
You must be signed in to change notification settings - Fork 48
169 lines (161 loc) · 6.05 KB
/
coverage.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
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
name: Analyse tket C++ test coverage
on:
pull_request:
branches:
- develop
push:
branches:
- develop
schedule:
# 03:00 every Saturday morning
- cron: '0 3 * * 6'
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
tket: ${{ steps.filter.outputs.tket }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3.0.0
id: filter
with:
base: ${{ github.ref }}
filters: |
tket:
- 'tket/**'
- '.github/workflows/coverage.yml'
generate_coverage:
name: Generate coverage report
needs: changes
if: needs.changes.outputs.tket == 'true' || github.event_name == 'schedule'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install conan
uses: turtlebrowser/get-conan@v1.2
- name: Set up conan
run: |
conan profile detect
DEFAULT_PROFILE_PATH=`conan profile path default`
PROFILE_PATH=./conan-profiles/ubuntu-22.04
diff ${DEFAULT_PROFILE_PATH} ${PROFILE_PATH} || true
cp ${PROFILE_PATH} ${DEFAULT_PROFILE_PATH}
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: tket-coverage-build
- name: further ccache config
run: |
ccache --set-config compiler_check=content
ccache --set-config hash_dir=false # better performance for debug builds
ccache -p
- name: Build tket
run: |
conan build tket --user=tket --channel=stable -s build_type=Debug --build=missing -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -o test-tket/*:with_coverage=True -of build/tket
conan export-pkg tket --user=tket --channel=stable -s build_type=Debug -o boost/*:header_only=True -o tket/*:profile_coverage=True -o with_test=True -of build/tket -tf ""
- name: Install runtime test requirements
if: github.event_name == 'schedule'
run: |
sudo apt-get update
sudo apt-get install texlive texlive-latex-extra latexmk
mkdir -p ~/texmf/tex/latex
wget http://mirrors.ctan.org/graphics/pgf/contrib/quantikz/tikzlibraryquantikz.code.tex -P ~/texmf/tex/latex
- name: Run full tket tests
if: github.event_name == 'schedule'
working-directory: ./build/tket-tests/build/Debug
run: ./test-tket "[long],~[long]"
- name: Install gcovr
run: pip install gcovr~=6.0
- name: Build coverage report
run: |
mkdir test-coverage
gcovr --print-summary --html --html-details -r ./tket --exclude-lines-by-pattern '.*\bTKET_ASSERT\(.*\);' --object-directory ${PWD}/build/tket/build/Debug/CMakeFiles/tket.dir/src -o test-coverage/index.html --decisions > test-coverage/summary.txt
cat test-coverage/summary.txt
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: test_coverage
path: test-coverage/
check_coverage:
name: Check coverage
needs: generate_coverage
if: ((github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') && needs.changes.outputs.tket == 'true') || github.event_name == 'schedule'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: test_coverage
path: test-coverage/
- name: Compare with latest report from develop (short tests)
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
run: |
wget https://cqcl.github.io/tket/tket/test-coverage-short/summary.txt
./.github/workflows/compare-coverage summary.txt test-coverage/summary.txt
- name: Compare with latest report from develop (full suite)
if: github.event_name == 'schedule'
run: |
wget https://cqcl.github.io/tket/tket/test-coverage/summary.txt
./.github/workflows/compare-coverage summary.txt test-coverage/summary.txt
publish_coverage_short:
name: Publish coverage (short tests)
needs: generate_coverage
concurrency: gh_pages
if: github.event_name == 'push' && needs.changes.outputs.tket == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: test_coverage
path: test-coverage/
- name: Configure git
run: |
git config --global user.email "tket-bot@cambridgequantum.com"
git config --global user.name "«$GITHUB_WORKFLOW» github action"
- name: Remove old report
run: git rm -r docs/tket/test-coverage-short
- name: Add report to repository
run: |
mv test-coverage docs/tket/test-coverage-short
git add -f docs/tket/test-coverage-short
git commit --allow-empty -m "Add generated coverage report (short tests)."
- name: Publish report
run: git push origin gh-pages:gh-pages
publish_coverage_full:
name: Publish coverage (full suite)
needs: check_coverage
concurrency: gh_pages
if: github.event_name == 'schedule'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: test_coverage
path: test-coverage/
- name: Configure git
run: |
git config --global user.email "tket-bot@cambridgequantum.com"
git config --global user.name "«$GITHUB_WORKFLOW» github action"
- name: Remove old report
run: git rm -r docs/tket/test-coverage
- name: Add report to repository
run: |
mv test-coverage docs/tket/test-coverage
git add -f docs/tket/test-coverage
git commit --allow-empty -m "Add generated coverage report (full suite)."
- name: Publish report
run: git push origin gh-pages:gh-pages