-
Notifications
You must be signed in to change notification settings - Fork 48
183 lines (182 loc) · 7.33 KB
/
test_libs.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: test libraries
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: {}
env:
ALL_LIBS: '["tklog", "tkassert", "tkrng", "tktokenswap", "tkwsm"]'
jobs:
changes:
runs-on: ubuntu-24.04
outputs:
tklog: ${{ steps.filter.outputs.tklog }}
tkassert: ${{ steps.filter.outputs.tkassert }}
tkrng: ${{ steps.filter.outputs.tkrng }}
libs: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3.0.2
id: filter
with:
base: ${{ github.ref }}
filters: |
tklog:
- 'libs/tklog/**'
tkassert:
- 'libs/tkassert/**'
tkrng:
- 'libs/tkrng/**'
tktokenswap:
- 'libs/tktokenswap/**'
tkwsm:
- 'libs/tkwsm/**'
gh_actions:
- '.github/workflows/test_libs.yml'
set_libs_matrix:
name: Set the libs strategy matrix
needs: changes
runs-on: ubuntu-24.04
outputs:
libs: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set LIBS_TO_TEST to all the libraries
# Test all libraries if the test_libs.yml file was modified
if: ${{ contains(needs.changes.outputs.libs, 'gh_actions') }}
run: |
echo "LIBS_TO_TEST=${{ toJSON(env.ALL_LIBS) }}" >> $GITHUB_ENV
- name: Set LIBS_TO_TEST to the modified libraries only
if: ${{ ! contains(needs.changes.outputs.libs, 'gh_actions') }}
run: |
echo "LIBS_TO_TEST=${{ toJSON(needs.changes.outputs.libs) }}" >> $GITHUB_ENV
- name: Set libs matrix
id: set-matrix
run: echo "matrix=${LIBS_TO_TEST}" >> $GITHUB_OUTPUT
test_libraries:
name: test library
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-24.04', 'macos-13', 'macos-15', 'windows-2022']
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Select Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install conan
uses: turtlebrowser/get-conan@v1.2
- name: Set up conan
shell: bash
run: |
conan profile detect
DEFAULT_PROFILE_PATH=`conan profile path default`
PROFILE_PATH=./conan-profiles/${{ matrix.os }}
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: build ${{ matrix.lib }}
run: conan create libs/${{ matrix.lib }} -o boost/*:header_only=True --build=missing
- name: build ${{ matrix.lib }} tests
run: conan create -o boost/*:header_only=True libs/${{ matrix.lib }}/test --build=missing --format json > test-${{ matrix.lib }}.json
- name: run ${{ matrix.lib }} tests
shell: bash
run: |
PKGPATH=`./rootpath test-${{ matrix.lib }}.json test-${{ matrix.lib }}`
cd ${PKGPATH}/bin
./test-${{ matrix.lib }}
generate_coverage:
name: Generate coverage report
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4
- name: Select Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- 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-24.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: build ${{ matrix.lib }}
run: |
conan build libs/${{ matrix.lib }} -s build_type=Debug --build=missing -o boost/*:header_only=True -o ${{ matrix.lib }}/*:profile_coverage=True -of build/${{ matrix.lib }}
conan export-pkg libs/${{ matrix.lib }} -s build_type=Debug -o boost/*:header_only=True -o ${{ matrix.lib }}/*:profile_coverage=True -of build/${{ matrix.lib }} -tf ""
- name: build ${{ matrix.lib }} tests
run: |
conan build libs/${{ matrix.lib }}/test -s build_type=Debug --build=missing -o boost/*:header_only=True -o test-${{ matrix.lib }}/*:with_coverage=True -of build/${{ matrix.lib }}-tests
- name: run ${{ matrix.lib }} tests
working-directory: ./build/${{ matrix.lib }}-tests/build/Debug
run: ./test-${{ matrix.lib }}
- name: install gcovr
run: pip install gcovr~=6.0
- name: build coverage report
run: |
mkdir ${{ matrix.lib }}-coverage
gcovr --print-summary --html --html-details -r ${GITHUB_WORKSPACE}/libs/${{ matrix.lib }} --exclude-lines-by-pattern '.*\bTKET_ASSERT\(.*\);' --object-directory ${GITHUB_WORKSPACE}/build/${{ matrix.lib }}/build/Debug/CMakeFiles/${{ matrix.lib }}.dir/src -o ${{ matrix.lib }}-coverage/index.html --decisions > ${{ matrix.lib }}-coverage/summary.txt
cat ${{ matrix.lib }}-coverage/summary.txt
- name: upload artefact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: check coverage against latest published data from main
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
run: |
# File may not exist if this is the very first time, so don't error.
wget https://cqcl.github.io/tket/${{ matrix.lib }}/test-coverage/summary.txt || true
if [[ -f summary.txt ]] ; then
./.github/workflows/compare-coverage summary.txt ${{ matrix.lib }}-coverage/summary.txt
fi
publish_coverage:
name: Publish coverage
needs: [set_libs_matrix, generate_coverage]
if: ${{ github.event_name == 'push' && needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
strategy:
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
concurrency: gh_pages
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- name: download artefact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: configure git
run: |
git config --global user.email "tket-bot@cambridgequantum.com"
git config --global user.name "«$GITHUB_WORKFLOW» github action"
- name: pull latest
run: git pull
- name: remove old report
run: git rm -r docs/${{ matrix.lib }}/test-coverage
- name: add report to repository
run: |
mkdir -p docs/${{ matrix.lib }}
mv ${{ matrix.lib }}-coverage docs/${{ matrix.lib }}/test-coverage
git add -f docs/${{ matrix.lib }}/test-coverage
git commit --allow-empty -m "Add generated coverage report."
- name: publish report
run: git push origin gh-pages:gh-pages