forked from espressif/esp-idf-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
322 lines (295 loc) · 10.2 KB
/
.gitlab-ci.yml
File metadata and controls
322 lines (295 loc) · 10.2 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
stages:
- pre-check
- host_test
- build
- target_test
- report
variables:
# System environment
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.3:1"
TEST_DIR: "$CI_PROJECT_DIR/test"
# Install dependency from custom branch, for details see wiki.
# e.g. CI_PYTHON_TOOL_REPO: "esp-idf-panic-decoder"
# CI_PYTHON_TOOL_BRANCH: "mybranch"
CI_PYTHON_TOOL_REPO: ""
CI_PYTHON_TOOL_BRANCH: ""
include:
- project: espressif/shared-ci-dangerjs
ref: master
file: danger.yaml
run-danger-mr-linter:
stage: pre-check
variables:
ENABLE_CHECK_UPDATED_CHANGELOG: 'false'
# WORKFLOW RULES
# ------------------------------------------------------------------------------------------------------
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"'
when: never
- if: '$CI_COMMIT_BRANCH'
# ------------------------------------------------------------------------------------------------------
# TEMPLATES
# ------------------------------------------------------------------------------------------------------
.install_custom_tool: &install_custom_tool |
if [[ -n "$CI_PYTHON_TOOL_REPO" ]]; then
git clone --quiet --depth=1 -b ${CI_PYTHON_TOOL_BRANCH} https://gitlab-ci-token:${ESPCI_TOKEN}@${GITLAB_HTTPS_HOST}/espressif/${CI_PYTHON_TOOL_REPO}.git
pip install ./${CI_PYTHON_TOOL_REPO}
rm -rf ${CI_PYTHON_TOOL_REPO}
fi
.base_template:
image: python:3.7-bullseye
tags:
- build
- internet
before_script:
- pip install -e .[dev] --prefer-binary
- *install_custom_tool
.idf_template:
image: "espressif/idf:latest"
tags:
- build
- internet
before_script:
- pip install -e .[dev,host_test] --prefer-binary
- *install_custom_tool
.build_template:
stage: build
tags:
- build
variables:
IDF_CCACHE_ENABLE: "1"
after_script:
# Show ccache statistics if enabled globally
- test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats || true
# BUILD TEST APPS
# This template gets expanded multiple times, once for every IDF version.
# IDF version is specified by setting the espressif/idf image tag.
#
# TEST_TARGETS sets the list of IDF_TARGET values to build the test for.
# It should contain only the targets with optimized assembly implementations.
#
.before_script_build_jobs:
before_script:
- pip install -e .[dev,target_test] --prefer-binary
- *install_custom_tool
.build_pytest_template:
stage: build
extends:
- .build_template
- .before_script_build_jobs
artifacts:
paths:
- "**/build*/size.json"
- "**/build*/build.log"
- "**/build*/build_log.txt"
- "**/build*/*.bin"
- "**/build*/*.elf"
- "**/build*/*.map"
- "**/build*/flasher_args.json"
- "**/build*/flash_project_args"
- "**/build*/config/sdkconfig.json"
- "**/build*/bootloader/*.bin"
- "**/build*/partition_table/*.bin"
- size_info.txt
when: always
expire_in: 3 days
script:
# CI specific options start from "--collect-size-info xxx". could ignore when running locally
# The script below will build all test applications defined in environment variable $TEST_TARGETS
- cd ${TEST_DIR}
- python -m idf_build_apps build -v -p .
--recursive
--target ${TEST_TARGETS}
--default-build-targets ${TEST_TARGETS}
--config "sdkconfig.ci.*=" --build-dir "build_@t_@w"
--check-warnings
--ignore-warning-file ignore_build_warnings.txt
--collect-size-info size_info.txt
--manifest-rootpath .
--manifest-file .build-test-rules.yml
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
variables:
TEST_TARGETS: "esp32"
build_idf_latest:
extends: .build_pytest_template
variables:
IDF_BRANCH: "master" # for filtering tests in .build-test-rules.yml
image: espressif/idf:latest
build_idf_v5.2:
extends: .build_pytest_template
variables:
IDF_BRANCH: "release/v5.2" # for filtering tests in .build-test-rules.yml
image: espressif/idf:release-v5.2
build_idf_v5.1:
extends: .build_pytest_template
variables:
IDF_BRANCH: "release/v5.1" # for filtering tests in .build-test-rules.yml
image: espressif/idf:release-v5.1
# ------------------------------------------------------------------------------------------------------
# JOBS
# ------------------------------------------------------------------------------------------------------
# CODE CHECK BY PRE-COMMIT HOOKS
pre-commit-mr:
stage: pre-check
needs: []
image: python:3.11-alpine3.18
before_script:
- apk add git
- pip install pre-commit
script:
- echo "Merge request is from ${CI_COMMIT_REF_NAME} into ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
- git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} ${CI_COMMIT_REF_NAME}
- export from_sha=$(git merge-base HEAD origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})
- echo "Checking changes from ${from_sha} to ${CI_COMMIT_SHA}:"
- git log --oneline ${from_sha}..${CI_COMMIT_SHA}
- echo "Modified files:"
- git diff-tree --no-commit-id --name-only -r ${from_sha} ${CI_COMMIT_SHA}
- echo "Running pre-commit:"
- pre-commit run --from ${from_sha} --to ${CI_COMMIT_SHA}
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
tags:
- build
# ------------------------------------------------------------------------------------------------------
# TESTS
# ------------------------------------------------------------------------------------------------------
test_idf_monitor:
extends: .idf_template
stage: host_test
artifacts:
# save artifacts always in order to access results which were retried without consequent failure
when: always
paths:
- test/host_test/outputs/*
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
variables:
PYTHONPATH: "$PYTHONPATH:${TEST_DIR}"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
script:
- cd ${TEST_DIR}
- coverage run -m pytest -sv host_test/test_monitor.py
windows_test:
stage: host_test
tags:
- windows-build
artifacts:
# save artifacts always in order to access results which were retried without consequent failure
when: always
paths:
- test/host_test/outputs/*
- "**/.coverage*"
- ".coverage*"
expire_in: 1 week
variables:
PYTHONPATH: "${CI_PROJECT_DIR}\\test"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}\\pyproject.toml"
before_script:
- python -m pip install --upgrade pip
- pip install -e .[dev,host_test] --prefer-binary
script:
- cd ${TEST_DIR}\host_test
- coverage run -m pytest -sv test_monitor.py
.before_script_pytest_jobs:
before_script:
- pip install -e .[dev,target_test] --prefer-binary
- *install_custom_tool
# Get ESP-IDF and install the tools (such as addr2line). We don't need the whole ESP-IDF, but it is easier for downloading required tools.
# Dowloading just the tools would require recreating the directory structure and downloading dependencies one by one.
- cd /opt/
- git clone --depth 1 -b ${IDF_BRANCH} https://gitlab-ci-token:${ESPCI_TOKEN}@${GITLAB_HTTPS_HOST}/espressif/esp-idf.git
- cd esp-idf
- echo "Using ESP-IDF branch ${IDF_BRANCH} on commit $(git rev-parse --short HEAD)"
- export IDF_PATH=${PWD}
- tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
.test_template:
stage: target_test
image: ${TARGET_TEST_ENV_IMAGE}
extends:
- .before_script_pytest_jobs
artifacts:
paths:
- "${TEST_DIR}/results_*.xml"
- "${TEST_DIR}/*.txt"
- "${TEST_DIR}/test_apps/pytest_embedded_log/"
- "**/.coverage*"
- ".coverage*"
reports:
junit: ${TEST_DIR}/results_${IDF_TARGET}_*.xml
when: always
expire_in: 1 week
script:
- cd ${TEST_DIR}/test_apps
- IDF_VERSION=$(echo $IDF_BRANCH | tr / _)
- pytest --junit-xml=${TEST_DIR}/results_${IDF_TARGET}_${IDF_VERSION}.xml --target=${IDF_TARGET}
test_target_apps:
extends: .test_template
tags:
- generic
- esp32
variables:
PYTHONPATH: "$PYTHONPATH:${TEST_DIR}"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
parallel:
matrix:
- IDF_BRANCH: ["release/v5.1", "release/v5.2", "master"]
IDF_TARGET: ["esp32"]
test_linux_apps:
extends:
- .build_template
- .test_template
image: espressif/idf:latest
variables:
IDF_TARGET: "linux"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
parallel:
matrix:
- IDF_BRANCH: ["master"]
script:
- cd ${TEST_DIR}
- python -m idf_build_apps build -v -p .
--recursive
--target linux
--config "sdkconfig.ci.*=" --build-dir "build_@t_@w"
--check-warnings
--ignore-warning-file ignore_build_warnings.txt
--collect-size-info size_info.txt
--manifest-rootpath .
--manifest-file .build-test-rules.yml
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
- IDF_VERSION=$(echo $IDF_BRANCH | tr / _)
# setting path before running build will break the build process
- cd test_apps
- PYTHONPATH=$PYTHONPATH:${TEST_DIR}
- pytest --junit-xml=${TEST_DIR}/results_${IDF_TARGET}_${IDF_VERSION}.xml --target=linux
combine_reports:
stage: report
extends: .base_template
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura_report.xml
when: always
paths:
- ".coverage*"
- cobertura_report.xml
- ./html_report/
expire_in: 1 week
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
variables:
LC_ALL: C.UTF-8
COVERAGE_RCFILE: "${CI_PROJECT_DIR}/pyproject.toml"
script:
# all .coverage files in sub-directories are moved to the parent dir first
- find . -mindepth 2 -type f -name ".coverage*" -print -exec mv --backup=numbered {} . \;
- coverage combine
- coverage report --precision=2
- coverage html -d html_report --precision=2
- coverage xml -o cobertura_report.xml
# ------------------------------------------------------------------------------------------------------