-
Notifications
You must be signed in to change notification settings - Fork 4
257 lines (219 loc) · 9.14 KB
/
ci.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: Build and test
# The main C++ CI is split into three steps: lint, build, and system tests. The
# linting and building are independent but we make the build wait so as not to
# waste resources compiling and testing a commit which doesn't pass the linter.
#
# System tests are slow and need input data. To save caching, network, and job
# time we only run the full system tests on Ubuntu (although this can easily be
# changed).
on:
push:
branches: ["main"]
pull_request:
merge_group:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: always.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
linting:
name: Linting checks with pre-commit
runs-on: ubuntu-latest
steps:
- uses: ucl/composite-actions/pre-commit@v1
build:
name: ${{ matrix.build_type }} build on ${{ matrix.os }} with build testing ${{ matrix.build_testing }}
needs: linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-20.04, windows-latest, macos-latest]
build_type: [Debug, Release]
build_testing: [ON, OFF]
exclude:
# Currently our tests don't compile, and nor do we have a coverage
# build in Windows so skip this.
- os: windows-latest
build_testing: ON
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/[email protected]
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
# -------------------------------------------------------------------------------
# Ubuntu
- name: Install dependencies for Ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libfftw3-dev libhdf5-dev libgomp1 python3 lcov
# -------------------------------------------------------------------------------
# Windows
- name: Install miniconda for Windows
if: ${{ contains(matrix.os, 'windows') }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.9
- name: Install dependencies for Windows
if: ${{ contains(matrix.os, 'windows') }}
shell: pwsh
run: |
conda install fftw --yes
echo "FFTWDIR=C:\Miniconda\envs\test\Library" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
conda install hdf5
echo "HDF5_DIR=C:\Miniconda\envs\test\Library" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
# -------------------------------------------------------------------------------
# MacOS
- name: Install dependencies for MacOS
if: ${{ contains(matrix.os, 'macos') }}
run: brew install fftw hdf5
- name: Fix omp headers not linked on MacOS
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew unlink libomp
brew link --force libomp
export DOMP_ROOT_MAC=-DOMP_ROOT=$(brew --prefix libomp)
echo "DOMP_ROOT_MAC=${DOMP_ROOT_MAC}" >> $GITHUB_ENV
# -------------------------------------------------------------------------------
- name: Create build environment
run: |
cmake -E make_directory ${{ runner.workspace }}/build
- name: Compile with Werror on Ubuntu and MacOS (not Windows)
if: ${{ !contains(matrix.os, 'windows') }}
run: echo "CXXFLAGS=-Werror" >> $GITHUB_ENV
- name: Configure TDMS
shell: bash
working-directory: ${{ runner.workspace }}/build
run: |
cmake ${GITHUB_WORKSPACE}/tdms -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DBUILD_TESTING=${{ matrix.build_testing }} \
-DCODE_COVERAGE=${{ matrix.build_testing }} \
${DOMP_ROOT_MAC}
# This 👆 env variable only exists on MacOS builds to fix the OMP
# homebrew/PATH problem.
- name: Build TDMS
working-directory: ${{ runner.workspace }}/build
shell: bash
run: |
cmake --build . --config ${{ matrix.build_type }}
- name: Smoke test the build on MacOS and Ubuntu
if: ${{ !contains(matrix.os, 'windows') }}
working-directory: ${{ runner.workspace }}/build
shell: bash
run: |
./tdms -h
./tdms --version
- name: Smoke test the build on Windows
if: ${{ contains(matrix.os, 'windows') }}
working-directory: ${{ runner.workspace }}/build/${{ matrix.build_type }}
shell: bash
run: |
export PATH=$(dirname "$(which MATLAB)")/win64/:$PATH
export PATH=/c/Miniconda/envs/test/Library/bin/:$PATH
./tdms.exe -h
./tdms.exe --version
# -------------------------------------------------------------------------------
# Unit tests
- name: Produce MATLAB unit test data
if: matrix.build_testing == 'ON'
uses: matlab-actions/run-command@v1
with:
command: cd('tdms/tests/unit/benchmark_scripts/'), setup_unit_tests
- name: Produce hdf5 unit test data
if: matrix.build_testing == 'ON'
run: |
pip install -r ${{ github.workspace }}/tdms/tests/requirements.txt
python ${{ github.workspace }}/tdms/tests/unit/benchmark_scripts/create_hdf5_test_file.py
- name: Run TDMS unit tests
if: matrix.build_testing == 'ON'
working-directory: ${{ runner.workspace }}/build
shell: bash
run: |
export OMP_NUM_THREADS=1
ctest -C ${{ matrix.build_type }} --output-on-failure --extra-verbose
- name: Run coverage analysis with lcov
if: matrix.build_testing == 'ON' && contains(matrix.os, 'ubuntu')
shell: bash
# Create the coverage summary, filter out dependencies' coverage then
# print human-readable summary in the build logs.
run: |
lcov --capture --directory ${{ runner.workspace }}/build/CMakeFiles/tdms_tests.dir/src --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --remove coverage.info '*/_deps/*' --output-file coverage.info
lcov --remove coverage.info '/Library/*' --output-file coverage.info
lcov --remove coverage.info '/Applications/*' --output-file coverage.info
lcov --list coverage.info
- name: Upload coverage reports to Codecov
if: matrix.build_testing == 'ON' && contains(matrix.os, 'ubuntu')
uses: codecov/codecov-action@v3
# -------------------------------------------------------------------------------
# Upload build artefact for system tests
- name: Tar the build result to maintain permissions
# https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
# https://github.com/actions/upload-artifact/issues/38
if: ${{ !contains(matrix.os, 'windows') }}
working-directory: ${{ runner.workspace }}/build
run: tar -cvf tdms_build.tar tdms
- name: Upload build results
if: matrix.build_testing == 'OFF' && matrix.build_type == 'Debug'
# If we use the build with testing ON, we'd also need to copy over (and
# install) the libtdms.so so use the OFF build for simplicity.
uses: actions/upload-artifact@v4
with:
name: tdms_build_${{ matrix.os }}
path: ${{ runner.workspace }}/build/tdms_build.tar
retention-days: 1
# Only run the slow system tests on Ubuntu.
# Cache the input data to save network usage.
system-tests:
name: System tests ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] #, macos-latest]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up MATLAB
uses: matlab-actions/[email protected]
- name: Install HDF5 libraries for Ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update
sudo apt-get install libhdf5-dev
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install -r ${GITHUB_WORKSPACE}/tdms/tests/requirements.txt
- name: Download build result
uses: actions/download-artifact@v4
with:
name: tdms_build_${{ matrix.os }}
path: ${{ runner.workspace }}
- name: Untar
working-directory: ${{ runner.workspace }}
run: |
tar -xvf tdms_build.tar
- name: Setup cache of test data
id: cache-test-data
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/tdms/tests/system/data
key: test_data
- name: Run TDMS system tests
working-directory: ${{ runner.workspace }}
shell: bash
run: |
export OMP_NUM_THREADS=2
pytest ${GITHUB_WORKSPACE}/tdms/tests/system/ --ignore=${GITHUB_WORKSPACE}/tdms/tests/system/test_regen.py -s -x