Repository navigation
337 lines (292 loc) · 13 KB
/
Copy pathci.yml
File metadata and controls
337 lines (292 loc) · 13 KB
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
name: CI
# The builds are in build-linux.yml, build-windows.yml and build-macos.yml, called from here, and the tests run on what they built: the
# wheel that a build uploads is the one that its tests install, and the module of Linux is the one that its shards download, so nothing
# is compiled twice. The tests of Linux are in shards, each with its own nodes and wallets, and a last job merges their coverage.
on:
push:
branches:
- main
pull_request:
branches:
- main
# Only on pull requests: the release needs a successful run for every commit on main.
# If CI ever becomes a required check, a skipped run stays Pending and blocks the merge.
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- 'donate.png'
- 'docs/**'
# other workflows, not run by this one
- '.github/workflows/build-deb.yml'
- '.github/workflows/codacy.yml'
- '.github/workflows/release.yml'
- '.github/workflows/lint-workflows.yml'
- '.github/zizmor.yml'
- '.github/dependabot.yml'
workflow_dispatch:
# A new push to a pull request cancels the previous run. Runs that are not
# from a pull request get their own group so they are never cancelled or replaced.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
build-linux:
# the name of the caller is the first part of the name of the checks of its job: "build / linux-x86_64"
name: build
permissions:
contents: read
actions: write # build-linux.yml replaces its ccache entries
uses: ./.github/workflows/build-linux.yml
build-windows:
name: build
permissions:
contents: read
actions: write # build-windows.yml replaces its ccache entries
uses: ./.github/workflows/build-windows.yml
build-macos:
name: build
permissions:
contents: read
actions: write # build-macos.yml replaces its ccache entries
uses: ./.github/workflows/build-macos.yml
test-windows:
name: unit tests / windows
needs: build-windows
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# the version is in one file: the wheel that CI builds is for it, and the job that tests the wheel needs the same
- name: Install Python (the version of .github/python-version)
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version-file: .github/python-version
architecture: 'x64'
- name: Download the Windows wheel
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: wheel-windows-x86_64
path: wheelhouse
- name: Install the test requirements and the wheel
shell: bash
run: |
python -m pip install -r tests/requirements.txt
python -m pip install wheelhouse/*.whl
- name: Run unit tests (pytest)
shell: bash
env:
IN_CONTAINER: "true"
run: |
python -m pytest -m unit
test-macos:
name: unit tests / ${{ matrix.arch }}
needs: build-macos
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: macos-15
arch: mac-arm64
- os: macos-15-intel
arch: mac-x86_64
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download the macOS wheel (${{ matrix.arch }})
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: wheel-${{ matrix.arch }}
path: wheelhouse
# the python that the build used, the wheel is for its version
- name: Install Python (brew)
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install python
brew list --versions python
# a virtual environment, as in the build: the python of brew has packages that pip can not replace, and the
# versions of the requirements file are pinned
- name: Install the test requirements and the wheel in a virtual environment
run: |
python3 -m venv "$RUNNER_TEMP/venv"
echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH"
"$RUNNER_TEMP/venv/bin/pip" install -r tests/requirements.txt wheelhouse/*.whl
- name: Run unit tests (pytest)
run: |
pytest -m unit
# Two jobs cover every test once, by marker: the unit ones, which need nothing, and the integration ones, which run with the nodes and the
# wallet rpc servers of docker. Together they are all the tests. Each one uploads its coverage, and the coverage job merges them.
# The name of an entry is in the names of files and artifacts, so it has no spaces: lcov splits the path of a tracefile at them,
# and the merge of the coverage failed with a name that had one. The title is what the job shows.
test-linux:
name: ${{ matrix.title }} / linux-x86_64
needs: build-linux
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
# what the docker compose commands of the steps work on
COMPOSE_FILE: tests/docker-compose.yml
TEST_SERVICES: node_1 node_2 xmr_wallet_1 xmr_wallet_2 xmr_wallet_3
strategy:
fail-fast: false
matrix:
include:
- name: unit
title: unit tests
pytest: -m unit tests
docker: false
- name: integration
title: integration tests
pytest: -m integration tests
docker: true
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: recursive
- name: Download the Linux build (module and coverage files)
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-linux-x86_64
# at the root of the workspace: the module in build/, and the .gcno where the tests will write the .gcda
- name: Extract the Linux build
run: tar -xzf linux-build.tar.gz
# the module is linked to shared libraries of apt, the ones of the build
- name: Install apt packages
run: bin/install_dependencies_linux.sh
- name: Show the versions of the apt libraries
run: bin/show_versions_linux.sh | bin/job_summary.sh "apt libraries"
- name: Install the Python test requirements (tests/requirements.txt)
run: pip3 install -r tests/requirements.txt --break-system-packages
- name: Start the test environment (2 nodes and 3 wallet rpc servers in docker)
if: ${{ matrix.docker }}
run: |
read -r -a services <<< "$TEST_SERVICES"
docker compose up -d "${services[@]}"
docker compose images
sleep 10
# --durations shows where a shard spends its time, to balance them
- name: Run ${{ matrix.title }} (pytest)
env:
IN_CONTAINER: "true"
PYTHONPATH: ${{ github.workspace }}/build
COVERAGE_FILE: pytest-coverage-${{ matrix.name }}
PYTEST_ARGS: ${{ matrix.pytest }}
run: |
read -r -a args <<< "$PYTEST_ARGS"
pytest --cov=tests --cov-report= --durations=25 "${args[@]}"
- name: Collect the container logs
if: ${{ always() && matrix.docker }}
run: |
mkdir -p container-logs
for svc in $TEST_SERVICES; do
docker compose logs --no-color --timestamps "$svc" > "container-logs/$svc.log" 2>&1 || true
done
- name: Upload container logs
if: ${{ always() && matrix.docker }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: container-logs-${{ matrix.name }}
# to look at a failure, not to keep
retention-days: 14
path: container-logs/
- name: Stop the test environment
if: ${{ always() && matrix.docker }}
run: docker compose down -v
- name: Upload the test logs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-logs-${{ matrix.name }}
retention-days: 14
path: monero_tests_*.log
# the coverage of this shard, as lcov tracefiles. The coverage job merges them
- name: Capture the coverage of the module
if: always()
run: |
lcov --capture --directory build --ignore-errors mismatch,mismatch,inconsistent,source,source,gcov,gcov --output-file coverage_full.info
lcov --ignore-errors unused,unused --remove coverage_full.info '/usr/*' '*/external/*' '*/pybind11/*' '*monero-cpp/*' '*monero-project/*' --output-file coverage.info
sed -i "s|$(pwd)/||g" coverage.info
- name: Capture the coverage of monero-cpp
if: always()
run: |
lcov --capture --directory external/monero-cpp/build --directory build --ignore-errors mismatch,mismatch,inconsistent,source,source,gcov,gcov --output-file coverage_monero_cpp_full.info
lcov --ignore-errors unused,unused --extract coverage_monero_cpp_full.info '*/monero-cpp/src/*' --output-file coverage_monero_cpp.info
sed -i "s|$(pwd)/||g" coverage_monero_cpp.info
- name: Upload the coverage of the shard
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-${{ matrix.name }}
# only for the coverage job, and for its reruns
retention-days: 7
path: |
coverage.info
coverage_monero_cpp.info
pytest-coverage-${{ matrix.name }}
# The coverage of the tests of all the shards, in the same reports that Tests made (the artifact has the same name, and Codacy and the
# release read it). It runs when a shard fails too, with the shards that have it, since a failing test is still reported.
coverage:
name: coverage report
needs: [build-linux, test-linux]
if: ${{ !cancelled() && needs.build-linux.result == 'success' }}
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: recursive
- name: Install lcov and the Python test requirements
run: |
sudo apt-get update
sudo apt-get install -y lcov
pip3 install -r tests/requirements.txt --break-system-packages
lcov --version
# a folder for each shard, named as the artifact
- name: Download the coverage of the shards
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: coverage-*
path: shards
- name: Generate the python bindings coverage report
run: |
args=()
for f in shards/*/coverage.info; do args+=(-a "$f"); done
lcov "${args[@]}" --ignore-errors mismatch,mismatch,inconsistent,source,source,corrupt --output-file coverage.info
genhtml coverage.info --output-directory coverage_monero_python_bindings_html --ignore-errors mismatch,inconsistent,source,corrupt --title "monero-python bindings coverage @ ${GITHUB_SHA::7}"
lcov --summary coverage.info
- name: Generate the python tests coverage report
run: |
coverage combine shards/*/pytest-coverage-*
coverage xml
coverage html -d coverage_monero_python_tests_html --title "monero-python tests coverage @ ${GITHUB_SHA::7}"
- name: Generate the monero-cpp coverage report
run: |
args=()
for f in shards/*/coverage_monero_cpp.info; do args+=(-a "$f"); done
lcov "${args[@]}" --ignore-errors mismatch,mismatch,inconsistent,source,source,corrupt --output-file coverage_monero_cpp.info
genhtml coverage_monero_cpp.info --output-directory coverage_monero_cpp_html --ignore-errors mismatch,inconsistent,source,corrupt --title "monero-cpp coverage @ ${GITHUB_SHA::7}"
lcov --summary coverage_monero_cpp.info
- name: Upload the coverage reports
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-reports-linux
# the default retention: the release downloads it from the run of main, and Codacy reads it when the run ends
path: |
coverage.info
coverage.xml
coverage_monero_cpp.info
coverage_monero_cpp_html/
coverage_monero_python_bindings_html/
coverage_monero_python_tests_html/