forked from espressif/esp-matter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
230 lines (211 loc) · 7.53 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
stages:
- build
- docs
variables:
ESP_MATTER_PATH: "$CI_PROJECT_DIR"
IDF_PATH: "$CI_PROJECT_DIR/esp-idf"
IDF_GITHUB_ASSETS: "dl.espressif.com/github_assets"
GIT_STRATEGY: fetch
GIT_SUBMODULE_STRATEGY: none
IDF_SKIP_CHECK_SUBMODULES: 1
# This folder was on the runner host
MATTER_CACHE_DIR: /cache/matter_build
.add_gitlab_ssh_key: &add_gitlab_ssh_key |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo -n $GITLAB_KEY >> ~/.ssh/id_rsa_base64
base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
.get_build_caches: &get_build_caches
- |
if [ -d ${MATTER_CACHE_DIR}/ ]; then
echo "get matter_build cache ..."
mkdir -p .git/modules/
mkdir -p ~/.cache/pip/
mkdir -p ~/.cipd-cache-dir/
mkdir -p ~/.espressif/dist/
time rsync -a ${MATTER_CACHE_DIR}/git_modules/ .git/modules/ || true
time rsync -a ${MATTER_CACHE_DIR}/cache_pip/ ~/.cache/pip/ || true
time rsync -a ${MATTER_CACHE_DIR}/cipd_cache_dir/ ~/.cipd-cache-dir/ || true
time rsync -a ${MATTER_CACHE_DIR}/espressif_dist/ ~/.espressif/dist/ || true
fi
.update_build_caches: &update_build_caches
- |
if [ -d ${MATTER_CACHE_DIR}/ ]; then
echo "update matter_build cache ..."
time rsync -a .git/modules/ ${MATTER_CACHE_DIR}/git_modules/ || true
time rsync -a ~/.cache/pip/ ${MATTER_CACHE_DIR}/cache_pip/ || true
time rsync -a ~/.cipd-cache-dir/ ${MATTER_CACHE_DIR}/cipd_cache_dir/ || true
time rsync -a ~/.espressif/dist/ ${MATTER_CACHE_DIR}/espressif_dist/ || true
fi
.chip_submodule_update: &chip_submodule_update
- sed -i "s%https://github.com/espressif%${GITLAB_SSH_SERVER}/espressif%" .gitmodules
- git submodule sync --recursive
- git submodule update -f --init --recursive --depth 1
.setup_idf: &setup_idf
# TODO: IDF_VERSION maybe a commit id, use `git fetch` rather than `git clone -b`
# - git clone -b ${IDF_VERSION} ${IDF_GIT_REPO_URL} --depth=1
- mkdir -p esp-idf
- cd esp-idf
- git init
- git remote add origin ${IDF_GIT_REPO_URL}
- git fetch origin ${IDF_VERSION}:refs/head --depth=1 -f
- git checkout ${IDF_VERSION}
- ./install.sh
- . ./export.sh
# fetch submodules
- export PYTHONPATH=${IDF_PATH}/tools/ci/python_packages/:${PYTHONPATH}
- pip install python-gitlab
- python tools/ci/ci_fetch_submodule.py
.setup_matter: &setup_matter
- cd ${CI_PROJECT_DIR}
# Setting up Python environment still spend a pretty long time (15mins -> 5mins).
- ./install.sh
- . ./export.sh
.build_matter_examples: &build_matter_examples
- export MATTER_EXAMPLES_PATH=$ESP_MATTER_PATH/connectedhomeip/connectedhomeip/examples
- cd $MATTER_EXAMPLES_PATH/all-clusters-app/esp32
- idf.py build
- cd $MATTER_EXAMPLES_PATH/temperature-measurement-app/esp32
- idf.py build
- cd $MATTER_EXAMPLES_PATH/lock-app/esp32
- idf.py build
- cd $MATTER_EXAMPLES_PATH/pigweed-app/esp32
- idf.py build
- cd $MATTER_EXAMPLES_PATH/persistent-storage/esp32
- idf.py build
.build_examples: &build_examples
- cd $ESP_MATTER_PATH/examples/blemesh_bridge
- idf.py set-target esp32
- idf.py build
- idf.py set-target esp32c3
- idf.py build
- cd $ESP_MATTER_PATH/examples/zap_light
- idf.py set-target esp32
- idf.py build
- cd $ESP_MATTER_PATH/examples/light_switch
- idf.py set-target esp32
- idf.py build
- cd $ESP_MATTER_PATH/examples/light
- idf.py set-target esp32
- idf.py build
- idf.py set-target esp32c3
- idf.py build
.build_external_platform_example: &build_external_platform_example
- rm -rf $ESP_MATTER_PATH/../platform
- mkdir $ESP_MATTER_PATH/../platform
- cp -r $ESP_MATTER_PATH/connectedhomeip/connectedhomeip/src/platform/ESP32 $ESP_MATTER_PATH/../platform/ESP32_custom
- cp $ESP_MATTER_PATH/examples/common/external_platform/BUILD.gn $ESP_MATTER_PATH/../platform/ESP32_custom
- cd $ESP_MATTER_PATH/examples/light
- cp sdkconfig.defaults sdkconfig.defaults.backup
- cp sdkconfig.defaults.ext_plat_ci sdkconfig.defaults
- idf.py set-target esp32
- idf.py build
- cp sdkconfig.defaults.backup sdkconfig.defaults
.build_examples_idf_v5_0: &build_examples_idf_v5_0
- cd $ESP_MATTER_PATH/examples/zap_light
- idf.py --preview set-target esp32h2
- idf.py build
- cd $ESP_MATTER_PATH/examples/light_switch
- idf.py --preview set-target esp32h2
- idf.py build
- cd $ESP_MATTER_PATH/examples/light
- idf.py --preview set-target esp32h2
- idf.py build
- cd $ESP_MATTER_PATH/examples/zigbee_bridge
- idf.py set-target esp32
- idf.py build
.build_examples_template:
stage: build
image: gitlab.espressif.cn:5050/app-frameworks/esp-matter/build-env:latest
tags:
- build
# runner: `sudo mkdir -p /cache/matter_build/`
# gitlab-runner config: `volumes = ["/cache:/cache:rw"]`
- matter_cache
before_script:
- *add_gitlab_ssh_key
- *get_build_caches
- *chip_submodule_update
- *setup_matter
- *setup_idf
- cd ${ESP_MATTER_PATH}
- mkdir -p ${REPOS_PATH}
# update caches only when setup succeed
- *update_build_caches
variables:
IDF_VERSION: "v4.4.1"
REPOS_PATH: "$CI_PROJECT_DIR/repos"
IDF_CCACHE_ENABLE: 1
build_esp_matter_examples:
extends:
- .build_examples_template
script:
- *build_examples
- *build_external_platform_example
build_esp_matter_examples_idf_v5_0:
extends:
- .build_examples_template
variables:
IDF_VERSION: "ccdeb43cc7274a49e8dfa331de95ab06dea25183"
script:
- *build_examples_idf_v5_0
build_upstream_examples:
extends:
- .build_examples_template
when: manual
script:
- *build_matter_examples
build_docs:
stage: build
image: $CI_DOCKER_REGISTRY/esp-idf-doc-env:v4.4-1-v4
tags:
- build
artifacts:
when: always
paths:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 1 days
script:
- cd docs
- pip install -r requirements.txt
- build-docs -t esp32 esp32c3 esp32h2 -l en
.deploy_docs_template:
stage: docs
image: $CI_DOCKER_REGISTRY/esp-idf-doc-env:v4.4-1-v4
tags:
- docs
needs:
- build_docs
script:
- source ${CI_PROJECT_DIR}/docs/utils.sh
- add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
- export GIT_VER=$(git describe --always)
- pip install -r ${CI_PROJECT_DIR}/docs/requirements.txt
- deploy-docs
deploy_docs_preview:
extends:
- .deploy_docs_template
when: manual
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PREVIEW_DEPLOY_KEY"
DOCS_DEPLOY_SERVER: "$DOCS_PREVIEW_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PREVIEW_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PREVIEW_PATH"
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PREVIEW_SERVER_URL/docs/esp-matter"
deploy_docs_production:
extends:
- .deploy_docs_template
when: manual
variables:
TYPE: "preview"
DOCS_BUILD_DIR: "${CI_PROJECT_DIR}/docs/_build/"
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_DEPLOY_KEY"
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esp-matter"