-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
281 lines (240 loc) · 8.89 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
# Project: Arancino Library - Serial Manager
# Author: Sergio Tomasello <[email protected]>
# Created: 2018.10.11
# Notes: La pipeline esegue la creazione dell'archivio della libreria compatibile per Aduino IDE
# Internal Vars: Lista delle variabili definete internamente ed usate nella pipeline:
# DATE: data di esecuzione della pipeline
# PKG_NAME: nome del pacchetto
# REPO_NAME: nome del repository di produzione, composto da due parti:
# il nome del progetto -> $CI_PROJECT_NAME
# ambiente di lavoro: -> "staging" o "release"
# $CI_PROJECT_NAME-staging
# $CI_PROJECT_NAME-release
# REPO_DIR: nome della directory di upload del repository, composto da due parti:
# il nome del progetto -> $CI_PROJECT_NAME
# ambiente di lavoro: -> "staging" o "release"
# $CI_PROJECT_NAME/staging
# $CI_PROJECT_NAME/release
#
# External Vars: Lista delle variabili definite estarnamente ed usate nella pipeline:
# REPO_USR: nome utente del associato a dev ops per effettuare upload dell'artefatto
# REPO_PWD: password associata all'utente dev ops
# REPO_BASE_URL: url di base del repository: https://download.smartme.io
#
image: smartmeio/arancino-library-build:0.18.3-2
stages:
- start
- test
- package
- upload
- cleanup
#################################
####### START #######
#################################
####### START
start:
stage: start
only: ['tags']
except: ['master', 'branches']
variables:
GIT_STRATEGY: none
script:
- mkdir -p tmp
- echo `date +%Y-%m-%d` > tmp/date.tmp
- echo `date +%H-%M-%S` > tmp/time.tmp
artifacts:
paths:
- tmp/
expire_in: 1d
######## PUSH
push:
stage: start
only: ['tags']
when: manual
except: ['master', 'branches']
allow_failure: true
variables:
GIT_STRATEGY: clone
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
#- apk add git
- git remote add github https://$GITHUB_BOT_USERNAME:[email protected]/$GITHUB_DEST_REPO
#- git remote show github
#- git remote show origin
#- git branch -a
- git checkout $CI_COMMIT_TAG
- git fetch github
#- git push github $CI_COMMIT_REF_NAME --force
- >
if [[ ${PRE_RELEASE} == "test" ]]; then
echo "not performing TAG push";
else
git push github ${CI_COMMIT_TAG}
fi
- git push --all --force github
#################################
####### TEST #######
#################################
####### CLI Sketch Test Job for SAMD platform #######
cli-test-samd:
stage: test
only: ['tags']
except: ['master', 'branches']
# copying the Library source to the Arduino libraries folder
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- mkdir -p ${HOME}/Arduino/libraries
- cp -r ${CI_PROJECT_DIR} ${HOME}/Arduino/libraries/Arancino
- chmod +x ./test/arduino-cli-test.sh
- arduino-cli update
- >
if [ -z ${CORE_SAMD_VERSION} ]; then
arduino-cli core install smartme.IO:samd
else
arduino-cli core install smartme.IO:samd@${CORE_SAMD_VERSION}
fi
- arduino-cli lib install "SparkFun ADXL345 Arduino Library"
# we feed the test scripts the simple board to complete the FQBN entry
script:
- ./test/arduino-cli-test.sh arancino
- ./test/arduino-cli-test.sh arancino_mignon
####### CLI Sketch Test Job for NRF52 platform #######
cli-test-nrf52:
stage: test
only: ['tags']
except: ['master', 'branches']
# copying the Library source to the Arduino libraries folder
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- mkdir -p ${HOME}/Arduino/libraries
- cp -r ${CI_PROJECT_DIR} ${HOME}/Arduino/libraries/Arancino
- chmod +x ./test/arduino-cli-test-nrf52.sh
- arduino-cli update
- >
if [ -z ${CORE_NRF52_VERSION} ]; then
arduino-cli core install smartme.IO:nrf52
else
arduino-cli core install smartme.IO:nrf52@${CORE_NRF52_VERSION}
fi
- arduino-cli lib install "SparkFun ADXL345 Arduino Library"
# we feed the test scripts the simple board to complete the FQBN entry
script:
- ./test/arduino-cli-test-nrf52.sh arancinoVolante
####### CLI Sketch Test Job for STM32 platform #######
cli-test-stm32:
stage: test
only: ['tags']
except: ['master', 'branches']
# copying the Library source to the Arduino libraries folder
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- mkdir -p ${HOME}/Arduino/libraries
- cp -r ${CI_PROJECT_DIR} ${HOME}/Arduino/libraries/Arancino
- chmod +x ./test/arduino-cli-test-stm32.sh
- arduino-cli update
- >
if [ -z ${CORE_STM32_VERSION} ]; then
arduino-cli core install smartme.IO:stm32
else
arduino-cli core install smartme.IO:stm32@${CORE_STM32_VERSION}
fi
- arduino-cli lib install "SparkFun ADXL345 Arduino Library"
# we feed the test scripts the simple board to complete the FQBN entry
script:
- ./test/arduino-cli-test-stm32.sh ArancinoV
####### CLI Sketch Test Job for RP2040 platform #######
cli-test-rp2040:
stage: test
only: ['tags']
except: ['master', 'branches']
# copying the Library source to the Arduino libraries folder
before_script:
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- mkdir -p ${HOME}/Arduino/libraries
- cp -r ${CI_PROJECT_DIR} ${HOME}/Arduino/libraries/Arancino
- chmod +x ./test/arduino-cli-test-rp2040.sh
- arduino-cli update
- >
if [ -z ${CORE_RP2040_VERSION} ]; then
arduino-cli core install smartme.IO:rp2040
else
arduino-cli core install smartme.IO:rp2040@${CORE_RP2040_VERSION}
fi
- arduino-cli lib install "SparkFun ADXL345 Arduino Library"
# we feed the test scripts the simple board to complete the FQBN entry
script:
- ./test/arduino-cli-test-rp2040.sh arancinopico
####### Package Release #######
#esegue la compressione del pacchetto quando viene creato un tag (ovvero ad ogni release)
package_release:
stage: package
only: ['tags']
except: ['master', 'branches']
script:
#- apk add zip
#- DATE="$(cat tmp/date.tmp)"
# packaging for PlatformIO
- jq --arg tag_ver ${CI_COMMIT_TAG} '.version = $tag_ver' library.json|sponge library.json
- pio package pack -o tmp/
# standard packaging as ZIP archive
- sed -i "s/version=.*/version=${CI_COMMIT_TAG}/g" library.properties
- PKG_NAME=$CI_PROJECT_NAME-$CI_COMMIT_TAG
- echo $PKG_NAME > tmp/pgk_name.tmp
- echo $CI_PROJECT_NAME > tmp/repo_name.tmp
- echo $CI_COMMIT_TAG > tmp/target_path.tmp
- mv tmp/ ../tmp && cd ../
#- tar --exclude='*.git*' --exclude='*.DS_Store*' -zcvf $PKG_NAME.zip $CI_PROJECT_NAME/
- zip -r $PKG_NAME.zip $CI_PROJECT_NAME -x "$CI_PROJECT_NAME/*test*" -x "$CI_PROJECT_NAME/check-version-tag.py" -x "$CI_PROJECT_NAME/*.git*" "$CI_PROJECT_NAME/*.DS_Store*"
- mv tmp/ $CI_PROJECT_NAME/
- mv $PKG_NAME.zip $CI_PROJECT_NAME/tmp/
dependencies:
- start
artifacts:
paths:
- tmp/
#################################
####### UPLOAD #######
#################################
####### Upload Staging and Release #######
#carica sul repository manager
upload:
stage: upload
only: ['tags']
except: ['master', 'branches']
variables:
GIT_STRATEGY: none
before_script:
- eval `python3 check-version-tag.py ${CI_COMMIT_TAG}`
script:
- DATE="$(cat tmp/date.tmp)"
- TIME="$(cat tmp/time.tmp)"
- PKG_NAME="$(cat tmp/pgk_name.tmp)"
- REPO_NAME="$(cat tmp/repo_name.tmp)"
- TARGET_PATH="$(cat tmp/target_path.tmp)"
#- apk add curl
- >
if [[ ${PRE_RELEASE} == "test" ]]; then
REPO_NAME=${REPO_NAME}-snapshot
fi
# Upload to Artifactory
- curl -u $REPO_USR:$REPO_PWD -T tmp/$PKG_NAME.zip "${REPO_BASE_URL}/artifactory/${REPO_NAME}/${TARGET_PATH}/${PKG_NAME}.zip"
# publishing to PlatformIO
- >
if [[ ${PRE_RELEASE} == "" ]]; then
pio package publish --owner smartme-io --type library --no-interactive --notify tmp/Arancino-${CI_COMMIT_TAG}.tar.gz
fi
#################################
####### CLEANUP #######
#################################
####### Cleanup Job #######
cleanup:
stage: cleanup
only: ['tags']
except: ['master', 'branches']
variables:
GIT_STRATEGY: none
script:
- echo "Cleaning up"
- rm -rf tmp/