-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
315 lines (283 loc) · 9.27 KB
/
.gitlab-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
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
stages:
- pre-check
- host_test
- build
- target_test
- report
variables:
# System environment
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
.install_custom_tool_powershell: &install_custom_tool_powershell |
if ($env:CI_PYTHON_TOOL_REPO) {
git clone --quiet --depth=1 -b $env:CI_PYTHON_TOOL_BRANCH "https://gitlab-ci-token:${env:ESPCI_TOKEN}@${env:GITLAB_HTTPS_HOST}/espressif/${env:CI_PYTHON_TOOL_REPO}.git"
pip install ./${env:CI_PYTHON_TOOL_REPO}
Remove-Item -Recurse -Force ${env:CI_PYTHON_TOOL_REPO}
}
.install_host_test:
before_script:
- pip install -e .[dev,host_test] --prefer-binary
- *install_custom_tool
.install_target_test:
before_script:
- pip install -e .[dev,ide,target_test] --prefer-binary
- *install_custom_tool
.base_template:
image: python:3.7-bullseye
tags:
- build
- internet
before_script:
- pip install -e .[dev] --prefer-binary
- *install_custom_tool
.idf_template_latest:
image: espressif/idf:latest
variables:
IDF_BRANCH: "latest"
.idf_template_oldest:
image: espressif/idf:release-v5.1
variables:
IDF_BRANCH: "v5_1"
.build_template:
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
.build_pytest_template:
stage: build
extends:
- .build_template
- .install_target_test
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*/bootloader/*.elf"
- "**/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_${IDF_BRANCH}_@t_@w"
--check-warnings
--collect-size-info size_info.txt
--manifest-rootpath .
--manifest-file .build-test-rules.yml
variables:
TEST_TARGETS: "esp32"
.target_test_template:
stage: target_test
extends:
- .install_target_test
tags:
- generic
- esp32
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
variables:
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
IDF_TARGET: "esp32"
script:
# setting PYTHONPATH before running activate script on newest IDF will cause an error because of missing coverage
- PYTHONPATH="$PYTHONPATH:${TEST_DIR}"
- cd ${TEST_DIR}/test_apps
- pytest --junit-xml=${TEST_DIR}/results_${IDF_TARGET}_${IDF_BRANCH}.xml --target=${IDF_TARGET}
# ------------------------------------------------------------------------------------------------------
# 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
# ------------------------------------------------------------------------------------------------------
# Host test jobs
host_test:
extends:
- .idf_template_latest
- .install_host_test
stage: host_test
tags:
- build
- internet
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:
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
script:
# setting PYTHONPATH before running activate script on newest IDF will cause an error because of missing coverage
- PYTHONPATH="$PYTHONPATH:${TEST_DIR}"
- cd ${TEST_DIR}
- coverage run -m pytest -sv host_test/test_monitor.py
windows_host_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
- *install_custom_tool_powershell
script:
- cd ${TEST_DIR}\host_test
- coverage run -m pytest -sv test_monitor.py
# Build test jobs for target tests
build_idf_latest:
extends:
- .idf_template_latest
- .build_pytest_template
build_idf_v5.1:
extends:
- .idf_template_oldest
- .build_pytest_template
# Target test jobs
test_target_apps_latest:
extends:
- .idf_template_latest
- .target_test_template
test_target_apps_v5.1:
extends:
- .idf_template_oldest
- .target_test_template
test_linux_apps:
stage: target_test
extends:
- .build_template
- .install_target_test
image: espressif/idf:latest
variables:
IDF_TARGET: "linux"
COVERAGE_PROCESS_START: "${CI_PROJECT_DIR}/pyproject.toml"
IDF_BRANCH: "latest"
script:
- cd ${TEST_DIR}
- python -m idf_build_apps build -v -p .
--recursive
--target linux
--config "sdkconfig.ci.*=" --build-dir "build_${IDF_BRANCH}_@t_@w"
--check-warnings
--collect-size-info size_info.txt
--manifest-rootpath .
--manifest-file .build-test-rules.yml
# setting PYTHONPATH before running build will break the build process
- cd test_apps
- PYTHONPATH=$PYTHONPATH:${TEST_DIR}
- pytest --junit-xml=${TEST_DIR}/results_${IDF_TARGET}_${IDF_BRANCH}.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
# ------------------------------------------------------------------------------------------------------