-
Notifications
You must be signed in to change notification settings - Fork 252
237 lines (208 loc) · 8.41 KB
/
Copy pathbuild-firmware.yml
File metadata and controls
237 lines (208 loc) · 8.41 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
name: Build Firmware
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
changes-firmware:
runs-on: ubuntu-24.04
permissions:
pull-requests: read
outputs:
should-build: ${{ github.event_name == 'push' || steps.filter.outputs.src == 'true' }}
steps:
- uses: dorny/paths-filter@v4
if: github.event_name == 'pull_request'
id: filter
with:
filters: |
src:
- '.github/actions/**'
- '.github/workflows/build-firmware.yml'
- 'boards/**'
- 'platform/**'
- 'resources/**'
- 'sdk/**'
- 'src/**'
- 'stored_apps/**'
- 'tools/**'
- 'third_party/**'
- 'tools/waf/**'
- 'waf'
- 'wscript'
build-firmware:
needs: changes-firmware
if: needs.changes-firmware.outputs.should-build == 'true'
runs-on: ubuntu-24.04
container:
image: ghcr.io/coredevices/pebbleos-docker:v6
strategy:
matrix:
board:
- asterix
- obelix@dvt
- obelix@pvt
- getafix@evt
- getafix@dvt
- getafix@dvt2
steps:
- name: Mark Github workspace as safe
run: git config --system --add safe.directory "${GITHUB_WORKSPACE}"
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: true
- name: Rebase onto target branch
uses: ./.github/actions/rebase
with:
submodules: true
- name: Install Python dependencies
run: |
pip install -U pip
pip install -r requirements.txt
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Set artifact board name
id: artifact_board
run: echo "NAME=$(printf '%s' "$BOARD" | tr @ _)" >> "$GITHUB_OUTPUT"
env:
BOARD: ${{ matrix.board }}
- name: Configure
run: ./waf configure --board '${{ matrix.board }}'
- name: Build
run: ./waf build
- name: Bundle
run: ./waf bundle
- name: Store
uses: actions/upload-artifact@v6
with:
name: firmware-${{ steps.artifact_board.outputs.NAME }}
path: |
build/**/*.elf
build/**/*.pbz
build/pebbleos_loghash_dict.json
- name: Get Build ID
id: build_id
run: |
echo "BUILD_ID=$(readelf -n build/pebbleos.elf | sed -n -e 's/^.*Build ID: //p')" >> "$GITHUB_OUTPUT"
- name: Upload log hash dictionary
if: ${{ github.event_name == 'push' && github.repository == 'coredevices/PebbleOS' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.LOG_HASH_BUCKET_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.LOG_HASH_BUCKET_SECRET }}
AWS_DEFAULT_REGION: us-east-1
run: |
pip install awscli
aws s3 cp build/pebbleos_loghash_dict.json \
"s3://${{ vars.LOG_HASH_BUCKET_NAME }}/${{ steps.build_id.outputs.BUILD_ID }}-${{ github.sha }}-normal.json" \
--endpoint-url "${{ vars.LOG_HASH_BUCKET_ENDPOINT }}"
# Dual-slot RELEASE PBZ for the hardware-lab release-QA boards. The build-firmware job above is
# single-slot AND a debug build, so it cannot be the "to" of an upgrade test: OTA writes into the
# watch's *inactive* slot (needs both slots), and the watch refuses to apply a debug PBZ over the
# release "from". The release-QA dispatch (coredevices/unicorn) needs a merged dual-slot RELEASE
# PBZ, the same shape as a release asset — so build both slots (release) and merge, in one job per
# board, no cross-job artifact passing. Only the two QA-hardware boards; kept out of
# build-firmware-status so a QA-artifact hiccup never blocks a firmware PR.
build-qa-firmware:
needs: changes-firmware
if: needs.changes-firmware.outputs.should-build == 'true'
runs-on: ubuntu-24.04
container:
image: ghcr.io/coredevices/pebbleos-docker:v6
strategy:
matrix:
board:
- obelix@pvt
- getafix@dvt2
steps:
- name: Mark Github workspace as safe
run: git config --system --add safe.directory "${GITHUB_WORKSPACE}"
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: true
- name: Rebase onto target branch
uses: ./.github/actions/rebase
with:
submodules: true
- name: Install Python dependencies
run: |
pip install -U pip
pip install -r requirements.txt
- name: Set artifact board name
id: artifact_board
run: echo "NAME=$(printf '%s' "$BOARD" | tr @ _)" >> "$GITHUB_OUTPUT"
env:
BOARD: ${{ matrix.board }}
- name: Build both release slots and merge into a dual-slot PBZ
shell: bash
run: |
set -euo pipefail
name='${{ steps.artifact_board.outputs.NAME }}'
mkdir -p out
for slot in 0 1; do
./waf configure --board '${{ matrix.board }}' -DCONFIG_FIRMWARE_SLOT=$slot -DCONFIG_RELEASE=y
./waf build
./waf bundle
cp build/normal_*_slot${slot}.pbz .
done
s0=$(ls normal_*_slot0.pbz | head -1)
s1=$(ls normal_*_slot1.pbz | head -1)
# Version string is embedded in the bundle name (git describe), e.g.
# normal_obelix_pvt_v4.35.0-2-gdeadbee_slot0.pbz -> v4.35.0-2-gdeadbee.
ver=$(basename "$s0" | sed -E "s/^normal_${name}_//; s/_slot0\.pbz$//")
python3 tools/merge_pbz.py --slot0-pbz "$s0" --slot1-pbz "$s1" \
--output "out/normal_${name}_${ver}.pbz"
# Ship the loghash dict alongside so the QA fwlog step can dehash release logs.
cp build/pebbleos_loghash_dict.json out/ 2>/dev/null || true
ls -la out
- name: Store merged QA firmware
uses: actions/upload-artifact@v6
with:
name: qa-firmware-${{ steps.artifact_board.outputs.NAME }}
path: out/**
# Once the dual-slot QA firmware is built, kick off the hardware-lab release-QA in
# coredevices/unicorn against THIS run's qa-firmware artifact (erase -> PRF -> pair -> OTA ->
# functional pass on a real phone + watch), using the most recently tagged coreapp release. The
# unicorn run posts a `unicorn/release-qa` commit status back on this PR's commit. Internal PRs
# only (forks have no secrets); needs UNICORN_DISPATCH_TOKEN — a PAT with actions:write on unicorn.
dispatch-release-qa:
needs: build-qa-firmware
# Org members / collaborators only: author_association is MEMBER for org members, OWNER for the
# repo owner, COLLABORATOR for added collaborators — external contributors (CONTRIBUTOR/NONE) are
# excluded, so an outside PR can't spend the hardware lab.
if: >-
github.event_name == 'pull_request' &&
needs.build-qa-firmware.result == 'success' &&
github.event.pull_request.head.repo.full_name == github.repository &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
runs-on: ubuntu-24.04
# One in-flight QA per PR: a newer push supersedes the older dispatch instead of queueing extras.
concurrency:
group: release-qa-dispatch-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Dispatch the hardware-lab release-QA (coredevices/unicorn)
env:
GH_TOKEN: ${{ secrets.UNICORN_DISPATCH_TOKEN }}
run: |
if [ -z "${GH_TOKEN:-}" ]; then
echo "::warning::UNICORN_DISPATCH_TOKEN not set — add a PAT with actions:write on coredevices/unicorn to run the hardware release-QA automatically"
exit 0
fi
# to_pbz_run_id = this Build Firmware run (its qa-firmware-<board> artifact is the "to").
# coreapp_run_id omitted -> unicorn uses the most recently tagged coreapp release.
gh workflow run one-off-pebbleos-test.yml -R coredevices/unicorn \
-f to_pbz_run_id=${{ github.run_id }}
build-firmware-status:
needs: [changes-firmware, build-firmware]
if: always()
runs-on: ubuntu-24.04
steps:
- if: needs.build-firmware.result == 'failure' || needs.build-firmware.result == 'cancelled'
run: exit 1