-
Notifications
You must be signed in to change notification settings - Fork 117
264 lines (221 loc) · 8.69 KB
/
test_unit.yaml
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
258
259
260
261
262
263
264
name: Unit Tests
on:
push:
branches:
- main
- "releases/**"
pull_request:
branches:
- main
- "releases/**"
# Restrict tests to the most recent commit.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
linux-unit-tests:
runs-on: ubuntu-22.04
name: Run Unit tests on Linux
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install dependences
run: |
sudo apt-get update
sudo apt-get install -y $(./scripts/linux/getdeps.py -a linux/debian/control)
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Cache grcov
id: cache-grcov
uses: actions/cache@v3
with:
path: grcov-build/
key: ${{runner.os}}-grcov-v0.8.13
- name: Install Grcov
if: steps.cache-grcov.outputs.cache-hit != 'true'
shell: bash
run: |
cargo install grcov --root ${{github.workspace}}/grcov-build --version 0.8.13
- name: Building tests
shell: bash
run: |
mkdir -p build
cmake -S . -B $(pwd)/build \
-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage
cmake --build $(pwd)/build --target build_tests -j$(nproc)
- name: Running native messaging tests
shell: bash
working-directory: ./build/tests/nativemessaging
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
grcov $(pwd)/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/nativemessaging_lcov.info
- name: Running QML tests
shell: bash
working-directory: ./build/tests/qml
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
grcov $(pwd)/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/qml_lcov.info
- name: Running unit tests
shell: bash
working-directory: ./build/tests
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --test-dir unit --output-on-failure
ctest --test-dir unit_tests --output-on-failure
grcov $(pwd)/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info
grcov $(pwd)/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/unitapp_lcov.info
- name: Upload coverage for linux unit tests to Codecov
uses: codecov/codecov-action@v3
with:
directory: .
flags: linux_unit_tests
name: codecov-poc
files: nativemessaging_lcov.info,qml_lcov.info,unit_lcov.info,unitapp_lcov.info
verbose: true
macos-unit-tests:
runs-on: macos-latest
defaults:
run:
shell: bash -el {0}
name: Run Unit tests on MacOS
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: "recursive"
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
environment-file: env.yml
activate-environment: vpn
- name: Install dependencies
run: |
./scripts/macos/conda_install_extras.sh
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
brew install ninja
- name: Install Qt6
run: |
wget https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/mozillavpn.v2.mozillavpn.cache.level-3.toolchains.v3.qt-mac.latest/artifacts/public%2Fbuild%2Fqt6_mac.zip -O mac.zip
unzip -a mac.zip
sudo mv qt_dist /opt
cd ..
- name: Cache grcov
id: cache-grcov
uses: actions/cache@v3
with:
path: grcov-build/
key: ${{runner.os}}-grcov-v0.8.13
- name: Install Grcov
if: steps.cache-grcov.outputs.cache-hit != 'true'
run: |
cargo install grcov --root ${{github.workspace}}/grcov-build --version 0.8.13
- name: Building tests
run: |
export PATH=/opt/qt_dist/bin:${{github.workspace}}/grcov-build/bin:$PATH
mkdir -p build
cmake -S . -B $(pwd)/build -GNinja \
-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage
cmake --build $(pwd)/build --target build_tests
- name: Running native messaging tests
working-directory: ./build/tests/nativemessaging
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
grcov $(pwd)/CMakeFiles/nativemessaging_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/nativemessaging_lcov.info
- name: Running QML tests
working-directory: ./build/tests/qml
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
grcov $(pwd)/CMakeFiles/qml_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/qml_lcov.info
- name: Running unit tests
working-directory: ./build/tests
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --test-dir unit --output-on-failure
ctest --test-dir unit_tests --output-on-failure
grcov $(pwd)/unit/CMakeFiles/unit_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/unit_lcov.info
grcov $(pwd)/unit_tests/CMakeFiles/app_unit_tests.dir -s ${{github.workspace}} \
-t lcov --branch --ignore-not-existing > ${{github.workspace}}/unitapp_lcov.info
- name: Upload coverage for macos unit tests to Codecov
uses: codecov/codecov-action@v3
with:
directory: .
flags: macos_unit_tests
name: codecov-poc
files: auth_lcov.info,nativemessaging_lcov.info,qml_lcov.info,unit_lcov.info,unitapp_lcov.info
verbose: true
windows-unit-tests:
name: Run Unit tests on Windows
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install Qt
shell: pwsh
run: |
Invoke-WebRequest -Uri https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/mozillavpn.v2.mozillavpn.cache.level-3.toolchains.v3.qt-win.latest/artifacts/public%2Fbuild%2Fqt6_win.zip -OutFile win.zip
Expand-Archive win.zip
mv win\QT_OUT "C:\\MozillaVPNBuild"
- name: Add msvc dev commands to PATH
uses: ilammy/msvc-dev-cmd@v1
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Building tests
run: |
mkdir ./build
cmake -S . -B ./build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="C:\MozillaVPNBuild\lib\cmake" -DWINTUN_FOLDER="not-existing"
cmake --build ./build --target build_tests
- name: Running native messaging tests
shell: bash
working-directory: ./build/tests/nativemessaging
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
- name: Running QML tests
shell: bash
working-directory: ./build/tests/qml
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --output-on-failure
- name: Running unit tests
shell: bash
working-directory: ./build/tests
run: |
export PATH=${{github.workspace}}/grcov-build/bin:$PATH
ctest --test-dir unit --output-on-failure
ctest --test-dir unit_tests --output-on-failure
rust-unit-tests:
strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
name: Run Unit tests for Rust (${{ matrix.os }})
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Signature library tests
shell: bash
working-directory: ./signature
run: cargo test -- --nocapture