-
Notifications
You must be signed in to change notification settings - Fork 31
278 lines (253 loc) · 9.36 KB
/
build.yml
File metadata and controls
278 lines (253 loc) · 9.36 KB
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
name: Build
on: [push, pull_request, workflow_dispatch]
env:
ZEPHYR_SDK_INSTALL_PATH: /opt/toolchains
ZSDK_VERSION: 0.17.4
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
UV_CACHE_DIR: /tmp/.uv-cache
CI_IMAGE_VERSION: v0.28.6
jobs:
cache-check:
runs-on: ubuntu-latest
outputs:
caches_ready: ${{ steps.vars.outputs.caches_ready }}
head_ref: ${{ steps.vars.outputs.head_ref }}
sha_short: ${{ steps.vars.outputs.sha_short }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v5
# Using actions/cache@v4 with lookup-only: true often returns false negatives
- name: Check Zephyr SDK Cache
id: sdk-cache
run: |
CACHE_KEY="${{ runner.os }}-zephyr-sdk-${{ env.ZSDK_VERSION }}"
res=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/caches?key=${CACHE_KEY}" \
| jq .total_count)
echo "Zephyr SDK cache hit count: $res" >> $GITHUB_STEP_SUMMARY
if [ "$res" -gt 0 ]; then
echo "cache-hit='true'" >> "$GITHUB_OUTPUT"
else
echo "cache-hit='false'" >> "$GITHUB_OUTPUT"
fi
- name: Check west cache
id: west-cache
run: |
CACHE_KEY="west-${{ runner.os }}-${{ env.CI_IMAGE_VERSION }}-${{ hashFiles('west.yml') }}"
res=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/caches?key=${CACHE_KEY}" \
| jq .total_count)
echo "West cache hit count: $res" >> $GITHUB_STEP_SUMMARY
if [ "$res" -gt 0 ]; then
echo "cache-hit='true'" >> "$GITHUB_OUTPUT"
else
echo "cache-hit='false'" >> "$GITHUB_OUTPUT"
fi
- name: Set variables
id: vars
run: |
head_ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "head_ref=$head_ref" >> $GITHUB_OUTPUT
echo "head_ref name: $head_ref" >> $GITHUB_STEP_SUMMARY
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
echo "Ref SHA: $sha_short" >> $GITHUB_STEP_SUMMARY
if ${{ steps.sdk-cache.outputs.cache-hit }} && ${{ steps.west-cache.outputs.cache-hit }}; then
caches_ready='true'
else
caches_ready='false'
fi
echo "Cache warmed: $caches_ready" >> $GITHUB_STEP_SUMMARY
echo "caches_ready=$caches_ready" >> "$GITHUB_OUTPUT"
cache-warming:
runs-on: ubuntu-latest
needs: cache-check
if: needs.cache-check.outputs.caches_ready != 'true'
container:
image: ghcr.io/zephyrproject-rtos/ci-base:v0.28.6
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v5
with:
path: nfed
- name: Zephyr SDK Cache
id: sdk-cache
uses: actions/cache@v4
with:
path: ${{ env.ZEPHYR_SDK_INSTALL_PATH }}/zephyr-sdk-${{ env.ZSDK_VERSION }}
key: ${{ runner.os }}-zephyr-sdk-${{ env.ZSDK_VERSION }}
# The ci-base image now takes care of this, but doesn't allow minimal install
- name: Install Zephyr SDK
if: steps.sdk-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${ZEPHYR_SDK_INSTALL_PATH}
wget -nv https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-x86_64_minimal.tar.xz
tar -xf zephyr-sdk-${ZSDK_VERSION}_linux-x86_64_minimal.tar.xz -C ${ZEPHYR_SDK_INSTALL_PATH}/
rm zephyr-sdk-${ZSDK_VERSION}_linux-x86_64_minimal.tar.xz
- name: Install arm-zephyr-eabi toolchain
if: steps.sdk-cache.outputs.cache-hit != 'true'
run: |
wget -nv ${WGET_ARGS} https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz
tar -xf toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz -C ${ZEPHYR_SDK_INSTALL_PATH}/zephyr-sdk-${ZSDK_VERSION}/
rm toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz
- name: West cache
uses: actions/cache@v4
with:
path: |
bootloader/
modules/
nrf/
nrfxlib/
pcf85063a/
tools/
zephyr/
key: west-${{ runner.os }}-${{ env.CI_IMAGE_VERSION }}-${{ hashFiles('nfed/west.yml') }}
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: false
version: latest
- name: West update
working-directory: nfed
run: |
west init -l .
west update
- name: Install Python dependencies
run: |
uv pip install -r zephyr/scripts/requirements-base.txt
uv pip install -r nrf/scripts/requirements.txt
uv pip install -r bootloader/mcuboot/scripts/requirements.txt
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/zephyrproject-rtos/ci-base:v0.28.6
needs: [cache-check, cache-warming]
if: |
!cancelled() &&
(needs.cache-warming.result == 'skipped' || needs.cache-warming.result == 'success')
&& needs.cache-check.result == 'success'
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
sample:
[
accelerometer,
accelerometer_zbus,
active_sleep,
at_client,
battery,
blinky,
bme280,
button,
deep_sleep,
external_flash,
external_rtc,
external_rtc_time_sync,
https,
led_pwm,
mfw_update,
sms,
serial_lte_modem,
usb_detect
]
target:
[
circuitdojo_feather_nrf9160/nrf9160/ns,
circuitdojo_feather_nrf9151/nrf9151/ns,
]
exclude:
# List of target-app combinations to exclude
- target: circuitdojo_feather_nrf9160/nrf9160/ns
sample: deep_sleep
- target: circuitdojo_feather_nrf9160/nrf9160/ns
sample: usb_detect
- target: circuitdojo_feather_nrf9151/nrf9151/ns
sample: external_rtc
- target: circuitdojo_feather_nrf9151/nrf9151/ns
sample: external_rtc_time_sync
- target: circuitdojo_feather_nrf9151/nrf9151/ns
sample: led_pwm
- target: circuitdojo_feather_nrf9151/nrf9151/ns
sample: mfw_update
- target: circuitdojo_feather_nrf9160/nrf9160/ns
sample: serial_lte_modem
steps:
- uses: actions/checkout@v5
with:
path: nfed
- name: Restore Zephyr SDK Cache
id: sdk-cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: ${{ env.ZEPHYR_SDK_INSTALL_PATH }}/zephyr-sdk-${{ env.ZSDK_VERSION }}
key: ${{ runner.os }}-zephyr-sdk-${{ env.ZSDK_VERSION }}
- name: Run Zephyr SDK setup script
run: |
${ZEPHYR_SDK_INSTALL_PATH}/zephyr-sdk-${ZSDK_VERSION}/setup.sh -h -c
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: false
version: latest
- name: Restore west cache
id: west-cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: |
bootloader/
modules/
nrf/
nrfxlib/
pcf85063a/
tools/
zephyr/
key: west-${{ runner.os }}-${{ env.CI_IMAGE_VERSION }}-${{ hashFiles('nfed/west.yml') }}
- name: West init
working-directory: nfed
run: west init -l .
- name: West update
working-directory: nfed
run: west update
- name: Install Python dependencies
run: |
uv pip install -r zephyr/scripts/requirements-base.txt
uv pip install -r nrf/scripts/requirements.txt
uv pip install -r bootloader/mcuboot/scripts/requirements.txt
- name: Extract target base name
working-directory: nfed
id: target_base
run: |
target_base=$(echo "${{ matrix.target }}" | cut -d'/' -f1)
echo "target_base=$target_base" >> $GITHUB_OUTPUT
- name: Build ${{ matrix.sample }} for ${{ matrix.target }}
working-directory: nfed
run: |
west build -b ${{ matrix.target }} -s samples/${{ matrix.sample }} -p --sysbuild
mkdir -p archive
cp build/merged.hex archive/merged.hex
cp build/dfu_application.zip archive/dfu_application.zip
cp build/dfu_application.zip_manifest.json archive/dfu_application.zip_manifest.json
- name: Archive firmware
uses: actions/upload-artifact@v4
if: success()
with:
name: nfed_${{ needs.cache-check.outputs.head_ref }}_${{ needs.cache-check.outputs.sha_short }}_${{ matrix.sample }}_${{ steps.target_base.outputs.target_base }}
path: nfed/archive/
if-no-files-found: warn