This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
314 lines (247 loc) · 10.1 KB
/
build-and-release.yaml
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
name: Build and Release
on:
push:
paths:
- "**.c"
- "**.h"
- "**.feature"
- Kconfig
- .github/workflows/build-and-release.yaml
- Dockerfile
- ci/schedule.ts
- west.yml
- "*.conf"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CR_PAT: ${{ secrets.CR_PAT }}
jobs:
version:
name: Determine next release version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14.x"
- name: Determine next release version
run: |
npm ci
NEXT_VERSION=`node .github/workflows/get-next-version.js`
echo ${NEXT_VERSION}
echo ${NEXT_VERSION} > version.conf
- uses: actions/upload-artifact@v2
with:
name: version
path: version.conf
broker:
name: Determine broker hostname
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
steps:
- uses: actions/setup-node@v2
with:
node-version: "14.x"
- name: Determine the AWS IoT broker hostname
run: |
BROKER_HOSTNAME=`AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION=${{ env.AWS_REGION }} aws iot describe-endpoint --endpoint-type iot:Data-ATS | jq '.endpointAddress' -r | tr -d '\n'`
echo ${BROKER_HOSTNAME}
if [ -z "$BROKER_HOSTNAME" ]; then echo "Failed to discover broker hostname."; exit 1; fi
echo ${BROKER_HOSTNAME} > broker.conf
- uses: actions/upload-artifact@v2
with:
name: broker
path: broker.conf
docker:
name: Prepare Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine checksum for Docker image
run: |
DOCKER_CHECKSUM=`cat Dockerfile west.yml | sha256sum | awk '{ print $1 }' | tr -d '\n'`
echo "DOCKER_CHECKSUM=${DOCKER_CHECKSUM}" >> $GITHUB_ENV
- name: Sign in to the GitHub Container Registry
run: echo ${CR_PAT} | docker login ghcr.io -u USERNAME --password-stdin
- name: Check if Docker image exists
id: check-docker-image
continue-on-error: true
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run:
docker manifest inspect ghcr.io/bifravst/firmware-builder:${{
env.DOCKER_CHECKSUM }}
- name: Build Docker image
if: steps.check-docker-image.outcome == 'failure'
run: docker build -t bifravst-firmware-docker .
- name: Tag Docker image
if: steps.check-docker-image.outcome == 'failure'
run: |
CHECKSUM=`cat Dockerfile west.yml | sha256sum | awk '{ print $1 }' | tr -d '\n'`
docker tag bifravst-firmware-docker ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM }}
- name: Publish Docker image
if: steps.check-docker-image.outcome == 'failure'
run: |
docker images
docker push ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM }}
build:
runs-on: ubuntu-latest
needs: [version, broker, docker]
strategy:
matrix:
board: [thingy91_nrf9160ns, nrf9160dk_nrf9160ns]
network: [nbiot, ltem]
loglevel: [debug, nodebug]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: version
- name: Configure Version
run: |
CAT_TRACKER_APP_VERSION=`cat version.conf`-${{ matrix.board }}-${{ matrix.network }}-${{ matrix.loglevel }}
echo "CONFIG_CAT_TRACKER_APP_VERSION=\"${CAT_TRACKER_APP_VERSION}\"" >> prj_${{ matrix.board }}.conf
- name: Enable debug logs
if: matrix.loglevel == 'debug'
run: echo "CONFIG_LOG_MAX_LEVEL=4" >> prj_${{ matrix.board }}.conf
- name: Set network mode to LTE-m
if: matrix.network == 'ltem'
run: |
sed -i s/CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y/CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y/ prj_${{ matrix.board }}.conf
- uses: actions/download-artifact@v2
with:
name: broker
- name: Configure the AWS IoT broker hostname
run: |
BROKER_HOSTNAME=`cat broker.conf`
echo "CONFIG_AWS_IOT_BROKER_HOST_NAME=\"${BROKER_HOSTNAME}\"" >> prj_${{ matrix.board }}.conf
- run: cat prj_${{ matrix.board }}.conf
- name: Determine checksum for Docker image
run: |
DOCKER_CHECKSUM=`cat Dockerfile west.yml | sha256sum | awk '{ print $1 }' | tr -d '\n'`
echo "DOCKER_CHECKSUM=${DOCKER_CHECKSUM}" >> $GITHUB_ENV
- name: Sign in to the GitHub Container Registry
run: echo ${CR_PAT} | docker login ghcr.io -u USERNAME --password-stdin
- run:
docker pull ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM
}}
- name: Build
run: |
docker run --rm -v ${PWD}:/workdir/ncs/firmware ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM }} /bin/bash -c 'cd ncs/firmware && west build -p always -b ${{ matrix.board }}'
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.board }}-${{ matrix.network }}-${{ matrix.loglevel }}
path: |
build/zephyr/merged.hex
build/zephyr/app_update.bin
e2e-aws:
name: End to End tests (AWS)
runs-on: ubuntu-latest
needs: [version, broker, docker]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
STACK_NAME: ${{ secrets.STACK_NAME }}
DEVICE_ID: ${{ secrets.DEVICE_ID }}
CI: 1
FORCE_COLOR: 3
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@v2
with:
name: version
- name: Generate Job ID
run: |
JOB_ID=`uuidgen`
echo "JOB_ID=${JOB_ID}" >> $GITHUB_ENV
- name: Configure Version
run: |
CAT_TRACKER_APP_VERSION=`cat version.conf`-nrf9160dk_nrf9160ns-ltem-${JOB_ID}
echo "CAT_TRACKER_APP_VERSION=${CAT_TRACKER_APP_VERSION}" >> $GITHUB_ENV
echo "CONFIG_CAT_TRACKER_APP_VERSION=\"${CAT_TRACKER_APP_VERSION}-original\"" >> prj_nrf9160dk_nrf9160ns.conf
- run: echo "# Firmware CI settings" >> prj_nrf9160dk_nrf9160ns.conf
- name: Enable debug logs
run: echo "CONFIG_LOG_MAX_LEVEL=4" >> prj_nrf9160dk_nrf9160ns.conf
- name: Set network mode to LTE-m
run: |
sed -i s/CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y/CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y/ prj_nrf9160dk_nrf9160ns.conf
- uses: actions/download-artifact@v2
with:
name: broker
- name: Configure the AWS IoT broker hostname
run: |
BROKER_HOSTNAME=`cat broker.conf`
echo "BROKER_HOSTNAME=${BROKER_HOSTNAME}" >> $GITHUB_ENV
echo "CONFIG_AWS_IOT_BROKER_HOST_NAME=\"${BROKER_HOSTNAME}\"" >> prj_nrf9160dk_nrf9160ns.conf
- name: Set MQTT client ID to test device
run: |
echo "CONFIG_USE_CUSTOM_MQTT_CLIENT_ID=y" >> prj_nrf9160dk_nrf9160ns.conf
echo "CONFIG_AWS_IOT_CLIENT_ID_MAX_LEN=40" >> prj_nrf9160dk_nrf9160ns.conf
echo "CONFIG_MQTT_CLIENT_ID=\"${JOB_ID}\"" >> prj_nrf9160dk_nrf9160ns.conf
- run: cat prj_nrf9160dk_nrf9160ns.conf
- name: Determine checksum for Docker image
run: |
DOCKER_CHECKSUM=`cat Dockerfile west.yml | sha256sum | awk '{ print $1 }' | tr -d '\n'`
echo "DOCKER_CHECKSUM=${DOCKER_CHECKSUM}" >> $GITHUB_ENV
- name: Sign in to the GitHub Container Registry
run: echo ${CR_PAT} | docker login ghcr.io -u USERNAME --password-stdin
- run:
docker pull ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM
}}
- name: Build
run: |
docker run --rm -v ${PWD}:/workdir/ncs/firmware ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM }} /bin/bash -c 'cd ncs/firmware && west build -p always -b nrf9160dk_nrf9160ns'
cp build/zephyr/merged.hex firmware.hex
cp prj_nrf9160dk_nrf9160ns.conf firmware.conf
- name: Build with changed version for FOTA test
run: |
echo "CONFIG_CAT_TRACKER_APP_VERSION=\"${CAT_TRACKER_APP_VERSION}-upgraded\"" >> prj_nrf9160dk_nrf9160ns.conf
docker run --rm -v ${PWD}:/workdir/ncs/firmware ghcr.io/bifravst/firmware-builder:${{ env.DOCKER_CHECKSUM }} /bin/bash -c 'cd ncs/firmware && west build -p always -b nrf9160dk_nrf9160ns'
cp build/zephyr/app_update.bin fota-upgrade.bin
cp prj_nrf9160dk_nrf9160ns.conf fota-upgrade.conf
- name: Keep certificates around
uses: actions/cache@v2
with:
path: ./certificates
key: certificates-2020-01-20
- uses: actions/setup-node@v2
with:
node-version: "14.x"
- name: Set up test runner
run: |
npm ci
npx tsc
- name: Schedule Firmware CI job
run: node --unhandled-rejections=strict dist/schedule.js
- name: Verify run
run: npm run test:e2e:aws
# For now, ignore test failures until we get more experience running these tests
continue-on-error: true
- uses: actions/upload-artifact@v2
with:
name: end-to-end-test
path: |
firmware.hex
firmware.conf
fota-upgrade.bin
fota-upgrade.conf
certificates/*/device-${JOB_ID}*
fotaJobDocument.json
jobDocument.json
report.json
- name: Remove device certificates
run: rm -v ./certificates/*/device-*
release:
name: Release
runs-on: ubuntu-latest
needs: [build, e2e-aws]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- run: npx semantic-release
continue-on-error: true