-
Notifications
You must be signed in to change notification settings - Fork 48
199 lines (198 loc) · 8.31 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: test libraries
on:
push:
branches:
- develop
pull_request:
branches:
- develop
workflow_dispatch: {}
env:
ALL_LIBS: '["tklog", "tkassert", "tkrng", "tktokenswap", "tkwsm"]'
jobs:
changes:
runs-on: ubuntu-22.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@v3
- uses: dorny/[email protected]
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-22.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-22.04', 'macos-12', 'windows-2022']
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: add remote
run: 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 }}
macos-m1:
name: test library (macos-m1)
needs: set_libs_matrix
if: ${{ needs.set_libs_matrix.outputs.libs != '[]' && needs.set_libs_matrix.outputs.libs != '' }}
runs-on: ['self-hosted', 'macOS', 'ARM64']
strategy:
fail-fast: false
matrix:
lib: ${{ fromJson(needs.set_libs_matrix.outputs.libs) }}
steps:
- uses: actions/checkout@v3
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
shell: bash
run: conan profile detect --force
- name: set remotes
run: conan remote add --force tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: conan create -o boost/*:header_only=True libs/${{ matrix.lib }} --build=missing
- name: build ${{ matrix.lib }} tests
run: conan create libs/${{ matrix.lib }}/test --build=missing --format json > test-${{ matrix.lib }}.json
- name: run ${{ matrix.lib }} tests
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-22.04'
steps:
- uses: actions/checkout@v3
- name: Install conan
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
run: |
conan install 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 build libs/${{ matrix.lib }} -s build_type=Debug -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 install 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
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@v3
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: check coverage against latest published data from develop
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' && github.ref == 'refs/heads/develop' && 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-22.04
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- name: download artefact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.lib }}_coverage
path: ${{ matrix.lib }}-coverage/
- name: configure git
run: |
git config --global user.email "[email protected]"
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