Skip to content

Commit 7f06228

Browse files
SjorsClaudeGPT-5 (Preview)
committed
ci: move type check and simbuilds to own file
Co-authored-by: Claude <[email protected]> Co-authored-by: GPT-5 (Preview) <[email protected]>
1 parent 570bfdf commit 7f06228

File tree

8 files changed

+253
-145
lines changed

8 files changed

+253
-145
lines changed

.github/actions/build-sim/action.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
name: Build sim
22
description: Build device simulator(s)
3+
inputs:
4+
name:
5+
description: Device name from matrix (e.g. trezor-1, coldcard, jade)
6+
required: true
7+
archive:
8+
description: Archive base name (e.g. trezor-firmware)
9+
required: true
10+
paths:
11+
description: Space-separated paths to include in the archive
12+
required: true
313
runs:
414
using: composite
515
steps:
@@ -16,13 +26,17 @@ runs:
1626
- name: Build simulator
1727
shell: bash
1828
run: |
19-
git config --global user.email "[email protected]"
20-
git config --global user.name "ci"
21-
cd test; ./setup_environment.sh --${{ matrix.device.name }}; cd ..
22-
tar -czf ${{ matrix.device.archive }}.tar.gz ${{ matrix.device.paths }}
29+
set -euxo pipefail
30+
git config --global user.email '[email protected]'
31+
git config --global user.name 'ci'
32+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
33+
cd test
34+
./setup_environment.sh --"${{ inputs.name }}"
35+
cd ..
36+
tar -czf "${{ inputs.archive }}.tar.gz" ${{ inputs.paths }}
2337
2438
- uses: actions/upload-artifact@v4
2539
with:
26-
name: ${{ matrix.device.name }}-sim
27-
path: ${{ matrix.device.archive }}.tar.gz
40+
name: ${{ inputs.name }}-sim
41+
path: ${{ inputs.archive }}.tar.gz
2842

.github/sim-build-map.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"trezor": [
3+
{ "name": "trezor-1", "archive": "trezor-firmware", "paths": "test/work/trezor-firmware" },
4+
{ "name": "trezor-t", "archive": "trezor-firmware", "paths": "test/work/trezor-firmware" }
5+
],
6+
"coldcard": [
7+
{ "name": "coldcard", "archive": "coldcard-mpy", "paths": "test/work/firmware/external/micropython/ports/unix/coldcard-mpy test/work/firmware/unix/coldcard-mpy test/work/firmware/unix/l-mpy test/work/firmware/unix/l-port" }
8+
],
9+
"bitbox": [
10+
{ "name": "bitbox01", "archive": "mcu", "paths": "test/work/mcu" },
11+
{ "name": "bitbox02", "archive": "bitbox02", "paths": "test/work/bitbox02-firmware/build-build-noasan/bin/simulator" }
12+
],
13+
"jade": [
14+
{ "name": "jade", "archive": "jade", "paths": "test/work/jade/simulator" }
15+
],
16+
"ledger": [
17+
{ "name": "ledger", "archive": "speculos", "paths": "test/work/speculos" }
18+
],
19+
"keepkey": [
20+
{ "name": "keepkey", "archive": "keepkey-firmware", "paths": "test/work/keepkey-firmware/bin" }
21+
]
22+
}

.github/workflows/ci.yml

Lines changed: 60 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,6 @@ env:
1919
LANGUAGE: 'C.UTF-8'
2020

2121
jobs:
22-
type-check:
23-
name: Type check
24-
runs-on: ubuntu-latest
25-
container: python:3.12
26-
steps:
27-
- uses: actions/checkout@v4
28-
29-
- run: |
30-
pip install poetry
31-
poetry install
32-
33-
- name: Run check
34-
run: >
35-
poetry run
36-
mypy
37-
hwi.py
38-
hwilib/_base58.py
39-
hwilib/_bech32.py
40-
hwilib/_cli.py
41-
hwilib/commands.py
42-
hwilib/common.py
43-
hwilib/descriptor.py
44-
hwilib/devices/bitbox02.py
45-
hwilib/devices/coldcard.py
46-
hwilib/devices/digitalbitbox.py
47-
hwilib/devices/jade.py
48-
hwilib/devices/__init__.py
49-
hwilib/devices/keepkey.py
50-
hwilib/devices/ledger.py
51-
hwilib/devices/trezor.py
52-
hwilib/errors.py
53-
hwilib/_script.py
54-
hwilib/_serialize.py
55-
hwilib/tx.py
56-
hwilib/hwwclient.py
57-
hwilib/__init__.py
58-
hwilib/key.py
59-
hwilib/udevinstaller.py
60-
6122
non-device-tests:
6223
name: Non-device tests
6324
runs-on: ubuntu-latest
@@ -142,126 +103,80 @@ jobs:
142103
name: dist
143104
path: dist/
144105

106+
prepare-sim-matrices:
107+
name: Prepare sim matrices
108+
uses: ./.github/workflows/prepare-sim-matrices.yml
109+
145110
sim-builder-trezor:
146111
name: Trezor sim builder
147-
# Ubuntu 22.04 ships with glibc 2.35, which is needed to keep Trezor 1
148-
# binaries compatible with Debian Bookworm (glibc 2.36) Python containers.
149-
# Trezor T binaries don't need this.
150-
runs-on: ubuntu-22.04
151-
152-
strategy:
153-
fail-fast: false
154-
matrix:
155-
device:
156-
- { name: 'trezor-1', archive: 'trezor-firmware', paths: 'test/work/trezor-firmware' }
157-
- { name: 'trezor-t', archive: 'trezor-firmware', paths: 'test/work/trezor-firmware' }
158-
159-
steps:
160-
- uses: actions/checkout@v4
161-
- uses: ./.github/actions/build-sim
112+
needs: prepare-sim-matrices
113+
uses: ./.github/workflows/sim-builder.yml
114+
with:
115+
sim: trezor
116+
include: ${{ needs.prepare-sim-matrices.outputs.trezor }}
117+
# Ubuntu 22.04 ships with glibc 2.35, which is needed to keep Trezor 1
118+
# binaries compatible with Debian Bookworm (glibc 2.36) Python containers.
119+
# Trezor T binaries don't need this.
120+
runs-on: ubuntu-22.04
162121

163122
sim-builder-coldcard:
164123
name: Coldcard sim builder
165-
runs-on: ubuntu-22.04
166-
167-
strategy:
168-
fail-fast: false
169-
matrix:
170-
device:
171-
- { name: 'coldcard', archive: 'coldcard-mpy', paths: 'test/work/firmware/external/micropython/ports/unix/coldcard-mpy test/work/firmware/unix/coldcard-mpy test/work/firmware/unix/l-mpy test/work/firmware/unix/l-port' }
172-
173-
steps:
174-
- uses: actions/checkout@v4
175-
- uses: ./.github/actions/build-sim
124+
needs: prepare-sim-matrices
125+
uses: ./.github/workflows/sim-builder.yml
126+
with:
127+
sim: coldcard
128+
include: ${{ needs.prepare-sim-matrices.outputs.coldcard }}
129+
runs-on: ubuntu-22.04
176130

177131
sim-builder-bitbox:
178132
name: Bitbox sim builder
179-
runs-on: ubuntu-latest
180-
181-
strategy:
182-
fail-fast: false
183-
matrix:
184-
device:
185-
- { name: 'bitbox01', archive: 'mcu', paths: 'test/work/mcu' }
186-
- { name: 'bitbox02', archive: 'bitbox02', paths: 'test/work/bitbox02-firmware/build-build-noasan/bin/simulator' }
187-
188-
steps:
189-
- uses: actions/checkout@v4
190-
- uses: ./.github/actions/build-sim
133+
needs: prepare-sim-matrices
134+
uses: ./.github/workflows/sim-builder.yml
135+
with:
136+
sim: bitbox
137+
include: ${{ needs.prepare-sim-matrices.outputs.bitbox }}
138+
runs-on: ubuntu-latest
191139

192140
sim-builder-jade:
193141
name: Jade sim builder
194-
runs-on: ubuntu-latest
195-
196-
strategy:
197-
fail-fast: false
198-
matrix:
199-
device:
200-
- { name: 'jade', archive: 'jade', paths: 'test/work/jade/simulator' }
201-
202-
steps:
203-
- uses: actions/checkout@v4
204-
- uses: ./.github/actions/build-sim
142+
needs: prepare-sim-matrices
143+
uses: ./.github/workflows/sim-builder.yml
144+
with:
145+
sim: jade
146+
include: ${{ needs.prepare-sim-matrices.outputs.jade }}
147+
runs-on: ubuntu-latest
205148

206149
sim-builder-ledger:
207150
name: Ledger sim builder
208-
runs-on: ubuntu-latest
209-
210-
strategy:
211-
fail-fast: false
212-
matrix:
213-
device:
214-
- { name: 'ledger', archive: 'speculos', paths: 'test/work/speculos' }
215-
216-
steps:
217-
- uses: actions/checkout@v4
218-
- uses: ./.github/actions/build-sim
151+
needs: prepare-sim-matrices
152+
uses: ./.github/workflows/sim-builder.yml
153+
with:
154+
sim: ledger
155+
include: ${{ needs.prepare-sim-matrices.outputs.ledger }}
156+
runs-on: ubuntu-latest
219157

220158
sim-builder-keepkey:
221159
name: Keepkey sim builder
222-
runs-on: ubuntu-22.04
223-
224-
strategy:
225-
fail-fast: false
226-
matrix:
227-
device:
228-
- { name: 'keepkey', archive: 'keepkey-firmware', paths: 'test/work/keepkey-firmware/bin' }
229-
230-
steps:
231-
- uses: actions/checkout@v4
232-
- uses: ./.github/actions/build-sim
233-
160+
needs: prepare-sim-matrices
161+
uses: ./.github/workflows/sim-builder.yml
162+
with:
163+
sim: keepkey
164+
include: ${{ needs.prepare-sim-matrices.outputs.keepkey }}
165+
runs-on: ubuntu-22.04
234166

235167
ledger-s-app-builder:
236168
name: Ledger Nano S Bitcoin App builder
237-
runs-on: ubuntu-latest
238-
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
239-
steps:
240-
- run: |
241-
git clone https://github.com/LedgerHQ/app-bitcoin-new.git
242-
cd app-bitcoin-new
243-
make DEBUG=1
244-
245-
- uses: actions/upload-artifact@v4
246-
with:
247-
name: ledger_app_nano_s
248-
path: app-bitcoin-new/bin/app.elf
249-
169+
uses: ./.github/workflows/ledger-app-builder.yml
170+
with:
171+
app: nano_s
172+
runs-on: ubuntu-latest
250173

251174
ledger-x-app-builder:
252175
name: Ledger Nano X Bitcoin App builder
253-
runs-on: ubuntu-latest
254-
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
255-
steps:
256-
- run: |
257-
git clone https://github.com/LedgerHQ/app-bitcoin-new.git
258-
cd app-bitcoin-new
259-
make DEBUG=1 BOLOS_SDK=$NANOX_SDK
260-
261-
- uses: actions/upload-artifact@v4
262-
with:
263-
name: ledger_app_nano_x
264-
path: app-bitcoin-new/bin/app.elf
176+
uses: ./.github/workflows/ledger-app-builder.yml
177+
with:
178+
app: nano_x
179+
runs-on: ubuntu-latest
265180

266181
bitcoind-builder:
267182
name: bitcoind builder
@@ -272,11 +187,18 @@ jobs:
272187
- uses: actions/checkout@v4
273188
- uses: ./.github/actions/build-bitcoind
274189

275-
test-trezor:
190+
test-trezor-1:
191+
uses: ./.github/workflows/device-test.yml
192+
needs: [sim-builder-trezor, bitcoind-builder, dist-builder]
193+
with:
194+
device: trezor-1
195+
runs-on: ubuntu-latest
196+
197+
test-trezor-t:
276198
uses: ./.github/workflows/device-test.yml
277199
needs: [sim-builder-trezor, bitcoind-builder, dist-builder]
278200
with:
279-
device: trezor
201+
device: trezor-t
280202
runs-on: ubuntu-latest
281203

282204
test-ledger-s:

.github/workflows/device-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
python-version: ['3.9', '3.10', '3.11', '3.12']
26-
device: ${{ inputs.device }}
26+
device:
27+
- ${{ inputs.device }}
2728
test:
2829
- {interface: 'library'}
2930
- {interface: 'cli'}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Ledger App Builder
2+
on:
3+
workflow_call:
4+
inputs:
5+
app:
6+
required: true # 'nano_s' or 'nano_x'
7+
type: string
8+
runs-on:
9+
required: false
10+
type: string
11+
default: ubuntu-latest
12+
13+
jobs:
14+
build:
15+
name: Build ${{ inputs.app }}
16+
runs-on: ${{ inputs.runs-on }}
17+
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
18+
steps:
19+
- run: |
20+
git clone https://github.com/LedgerHQ/app-bitcoin-new.git
21+
cd app-bitcoin-new
22+
make DEBUG=1 ${{ inputs.app == 'nano_x' && 'BOLOS_SDK=$NANOX_SDK' || '' }}
23+
- uses: actions/upload-artifact@v4
24+
with:
25+
name: ${{ inputs.app == 'nano_x' && 'ledger_app_nano_x' || 'ledger_app_nano_s' }}
26+
path: app-bitcoin-new/bin/app.elf
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Prepare Sim Matrices
2+
on:
3+
workflow_call:
4+
outputs:
5+
trezor:
6+
description: JSON include array for trezor
7+
value: ${{ jobs.prepare.outputs.trezor }}
8+
coldcard:
9+
description: JSON include array for coldcard
10+
value: ${{ jobs.prepare.outputs.coldcard }}
11+
bitbox:
12+
description: JSON include array for bitbox
13+
value: ${{ jobs.prepare.outputs.bitbox }}
14+
jade:
15+
description: JSON include array for jade
16+
value: ${{ jobs.prepare.outputs.jade }}
17+
ledger:
18+
description: JSON include array for ledger
19+
value: ${{ jobs.prepare.outputs.ledger }}
20+
keepkey:
21+
description: JSON include array for keepkey
22+
value: ${{ jobs.prepare.outputs.keepkey }}
23+
24+
jobs:
25+
prepare:
26+
name: Prepare sim matrices
27+
runs-on: ubuntu-latest
28+
outputs:
29+
trezor: ${{ steps.gen.outputs.trezor }}
30+
coldcard: ${{ steps.gen.outputs.coldcard }}
31+
bitbox: ${{ steps.gen.outputs.bitbox }}
32+
jade: ${{ steps.gen.outputs.jade }}
33+
ledger: ${{ steps.gen.outputs.ledger }}
34+
keepkey: ${{ steps.gen.outputs.keepkey }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
- id: gen
38+
shell: bash
39+
run: |
40+
set -euo pipefail
41+
sudo apt-get install -y jq
42+
map_file=".github/sim-build-map.json"
43+
for sim in trezor coldcard bitbox jade ledger keepkey; do
44+
include=$(jq -c --arg s "$sim" '.[$s]' "$map_file")
45+
if [[ -z "$include" || "$include" == "null" ]]; then
46+
echo "Missing entry for $sim in $map_file" >&2
47+
exit 1
48+
fi
49+
echo "$sim=$include" >> "$GITHUB_OUTPUT"
50+
done

0 commit comments

Comments
 (0)