forked from espressif/esp-rainmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
247 lines (234 loc) · 7.95 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
stages:
- build
- deploy
variables:
V: "0"
MAKEFLAGS: "-j8 --no-keep-going"
IDF_PATH: "$CI_PROJECT_DIR/esp-idf"
APP_BUILD: "all"
before_script:
# 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
# Create esp-rainmaker-bins-${CI_JOB_ID}/ dir (to copy binaries into for artifacts)
- mkdir -p $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}
.setup_idf: &setup_idf
# Checking git version
- echo Checking git version
- git --version
# Cloning esp-idf - Started
- echo Cloning esp-idf - Started
- git clone --recursive --branch master --depth 1 ${IDF_GIT_PATH}/esp-idf.git
- cd esp-idf
- echo Cloning esp-idf - Done
# Cloning esp-idf - Done
# Running install.sh - Started
- echo Running install.sh - Started
- ./install.sh
- echo Running install.sh - Done
# Running install.sh - Done
# Running export.sh - Started
- echo Running export.sh - Started
- . export.sh
- echo Running export.sh - Done
# Running export.sh - Done
.build_switch: &build_switch
# Building switch app - Started
- echo Building switch app - Started
- ls
- cd $CI_PROJECT_DIR/examples/switch
- echo Running idf.py
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building switch app - Done
# Building switch app - Done
# Copying switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/switch/build/switch.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_led_light: &build_led_light
# Building led_light app - Started
- echo Building led_light app - Started
- echo Running idf.py
- cd $CI_PROJECT_DIR/examples/led_light
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building led_light app - Done
# Building led_light app - Done
# Copying led_light.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy led_light.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/led_light/build/led_light.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_fan: &build_fan
# Building fan app - Started
- echo Building fan app - Started
- echo Running idf.py
- cd $CI_PROJECT_DIR/examples/fan
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building fan app - Done
# Building fan app - Done
# Copying fan.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy fan.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/fan/build/fan.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_temperature_sensor: &build_temperature_sensor
# Building temperature_sensor app - Started
- echo Building temperature_sensor app - Started
- echo Running idf.py
- cd $CI_PROJECT_DIR/examples/temperature_sensor
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building temperature_sensor app - Done
# Building temperature_sensor app - Done
# Copying temperature_sensor.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy temperature_sensor.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/temperature_sensor/build/temperature_sensor.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_multi_device: &build_multi_device
# Building multi_device app - Started
- echo Building multi_device app - Started
- echo Running idf.py
- cd $CI_PROJECT_DIR/examples/multi_device
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building multi_device app - Done
# Building multi_device app - Done
# Copying multi_device.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy multi_device.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/multi_device/build/multi_device.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_gpio: &build_gpio
# Building gpio app - Started
- echo Building gpio app - Started
- echo Running idf.py
- cd $CI_PROJECT_DIR/examples/gpio
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building gpio app - Done
# Building gpio app - Done
# Copying gpio.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy gpio.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/gpio/build/gpio.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
.build_homekit_switch: &build_homekit_switch
# Building homekit_switch app - Started
- cd $CI_PROJECT_DIR/examples/homekit_switch
- mkdir components
- cd components
- echo Cloning esp-homekit-sdk
- git clone --recursive --branch master --depth 1 https://github.com/espressif/esp-homekit-sdk.git
- cd ..
- export HOMEKIT_PATH=$PWD/components/esp-homekit-sdk
- echo Building homekit_switch app - Started
- echo Running idf.py
- idf.py build
- echo Running make
- rm -rf build/ sdkconfig
- make defconfig
- make $MAKEFLAGS
- echo Building homekit_switch app - Done
# Building homekit_switch app - Done
# Copying homekit_switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- echo Copy homekit_switch.bin to esp-rainmaker-bins-${CI_JOB_ID}/
- cp $CI_PROJECT_DIR/examples/homekit_switch/build/homekit_switch.bin $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}/
build_app:
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env
tags:
- build
artifacts:
paths:
- $CI_PROJECT_DIR/esp-rainmaker-bins-${CI_JOB_ID}.zip
expire_in: 6 mos
script:
- *setup_idf
- for APP in $APP_BUILD; do
- if [[ "$APP_BUILD" == "all" || "$APP" == "switch" ]]; then
- *build_switch
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "led_light" ]]; then
- *build_led_light
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "fan" ]]; then
- *build_fan
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "temperature_sensor" ]]; then
- *build_temperature_sensor
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "multi_device" ]]; then
- *build_multi_device
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "gpio" ]]; then
- *build_gpio
- fi
- if [[ "$APP_BUILD" == "all" || "$APP" == "homekit_switch" ]]; then
- *build_homekit_switch
- fi
- done
- echo Build Complete for $APP_BUILD
# Generating zip file for binaries generated
- cd $CI_PROJECT_DIR
- echo Generating zip file for binaries generated
- tar -zcvf esp-rainmaker-bins-${CI_JOB_ID}.zip esp-rainmaker-bins-${CI_JOB_ID}/
build_docs:
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env
tags:
- build
artifacts:
paths:
- $CI_PROJECT_DIR/esp-rainmaker-docs-${CI_JOB_ID}.zip
script:
# Building sphinx docs
- echo Building sphinx docs
- cd docs
# unset IDF_PATH
- echo Unset IDF_PATH
- unset IDF_PATH
# Run requirements.txt
- echo Run requirements.txt
- python3 -m pip install -r requirements.txt
# Run make html
- echo Run make html
- make html
- cd $CI_PROJECT_DIR
- echo Generating tar files
- mkdir -p esp-rainmaker-docs-${CI_JOB_ID}/html
- cp -rf $CI_PROJECT_DIR/docs/_build/html/ esp-rainmaker-docs-${CI_JOB_ID}/html/
- tar -zcvf esp-rainmaker-docs-${CI_JOB_ID}.zip esp-rainmaker-docs-${CI_JOB_ID}
push_master_to_github:
stage: deploy
image: $CI_DOCKER_REGISTRY/esp32-ci-env
tags:
- build
when: on_success
dependencies: []
only:
- master
script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git remote remove github &>/dev/null || true
- git remote add github [email protected]:espressif/esp-rainmaker.git
- git push github "${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"