Skip to content

Commit 5c56ca2

Browse files
SjorsGPT-5 (Preview)
andcommitted
ci: clone coldcard repo only once
Co-Authored-By: GPT-5 (Preview) <[email protected]>
1 parent 7f06228 commit 5c56ca2

File tree

5 files changed

+78
-18
lines changed

5 files changed

+78
-18
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,25 @@ runs:
1818
apt-get install -y libsdl2-image-2.0-0 libusb-1.0-0
1919
tar -xvf trezor-firmware.tar.gz
2020
21+
# Coldcard: download seeded firmware (seed job must run earlier)
22+
- name: Download seeded Coldcard firmware
23+
if: inputs.device == 'coldcard'
24+
uses: actions/download-artifact@v4
25+
with:
26+
name: coldcard-firmware-src
27+
path: test/work/firmware
28+
2129
- if: inputs.device == 'coldcard'
2230
shell: bash
2331
run: |
2432
apt-get update
2533
apt-get install -y libpcsclite-dev libusb-1.0-0 swig
2634
git config --global user.email "[email protected]"
2735
git config --global user.name "ci"
28-
pushd test/work; git clone --recursive https://github.com/Coldcard/firmware.git; popd
36+
pushd test/work
37+
if [ ! -d "firmware" ]; then
38+
git clone --recursive https://github.com/Coldcard/firmware.git
39+
popd
2940
tar -xvf coldcard-mpy.tar.gz
3041
pushd test/work/firmware; git am ../../data/coldcard-multisig.patch; popd
3142
poetry run pip install -r test/work/firmware/requirements.txt

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,23 @@ jobs:
118118
# binaries compatible with Debian Bookworm (glibc 2.36) Python containers.
119119
# Trezor T binaries don't need this.
120120
runs-on: ubuntu-22.04
121+
ref: ${{ github.sha }}
121122

123+
coldcard-firmware-seed:
124+
uses: ./.github/workflows/coldcard-firmware-seed.yml
125+
with:
126+
ref: ${{ github.sha }}
127+
128+
# Use the generic sim-builder with a Coldcard seed dependency
122129
sim-builder-coldcard:
123130
name: Coldcard sim builder
124-
needs: prepare-sim-matrices
131+
needs: [prepare-sim-matrices, coldcard-firmware-seed]
125132
uses: ./.github/workflows/sim-builder.yml
126133
with:
127134
sim: coldcard
128135
include: ${{ needs.prepare-sim-matrices.outputs.coldcard }}
129136
runs-on: ubuntu-22.04
137+
ref: ${{ github.sha }}
130138

131139
sim-builder-bitbox:
132140
name: Bitbox sim builder
@@ -136,6 +144,7 @@ jobs:
136144
sim: bitbox
137145
include: ${{ needs.prepare-sim-matrices.outputs.bitbox }}
138146
runs-on: ubuntu-latest
147+
ref: ${{ github.sha }}
139148

140149
sim-builder-jade:
141150
name: Jade sim builder
@@ -145,6 +154,7 @@ jobs:
145154
sim: jade
146155
include: ${{ needs.prepare-sim-matrices.outputs.jade }}
147156
runs-on: ubuntu-latest
157+
ref: ${{ github.sha }}
148158

149159
sim-builder-ledger:
150160
name: Ledger sim builder
@@ -154,6 +164,7 @@ jobs:
154164
sim: ledger
155165
include: ${{ needs.prepare-sim-matrices.outputs.ledger }}
156166
runs-on: ubuntu-latest
167+
ref: ${{ github.sha }}
157168

158169
sim-builder-keepkey:
159170
name: Keepkey sim builder
@@ -163,6 +174,7 @@ jobs:
163174
sim: keepkey
164175
include: ${{ needs.prepare-sim-matrices.outputs.keepkey }}
165176
runs-on: ubuntu-22.04
177+
ref: ${{ github.sha }}
166178

167179
ledger-s-app-builder:
168180
name: Ledger Nano S Bitcoin App builder
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Coldcard Firmware Seed
2+
on:
3+
workflow_call:
4+
inputs:
5+
ref:
6+
required: false
7+
type: string
8+
9+
jobs:
10+
seed:
11+
name: Seed Coldcard firmware (once per run)
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ inputs.ref || github.sha }}
17+
fetch-depth: 0
18+
19+
- name: Clone Coldcard firmware (with submodules)
20+
shell: bash
21+
run: |
22+
set -euo pipefail
23+
mkdir -p test/work
24+
git clone --recursive https://github.com/Coldcard/firmware.git test/work/firmware
25+
26+
- name: Upload seeded repo as artifact
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: coldcard-firmware-src
30+
path: test/work/firmware

.github/workflows/sim-builder.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
required: false
1313
type: string
1414
default: ubuntu-latest
15+
ref: # Ref from caller so we check out the PR commit
16+
required: false
17+
type: string
1518

1619
jobs:
1720
build-simulator:
@@ -23,6 +26,18 @@ jobs:
2326
include: ${{ fromJSON(inputs.include) }}
2427
steps:
2528
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ inputs.ref || github.sha }}
31+
fetch-depth: 0
32+
33+
# Coldcard: download seeded firmware (seed job must run earlier)
34+
- name: Download seeded Coldcard firmware
35+
if: ${{ inputs.sim == 'coldcard' }}
36+
uses: actions/download-artifact@v4
37+
with:
38+
name: coldcard-firmware-src
39+
path: test/work/firmware
40+
2641
- uses: ./.github/actions/build-sim
2742
with:
2843
name: ${{ matrix.name }}

test/setup_environment.sh

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,30 +133,22 @@ if [[ -n ${build_coldcard} ]]; then
133133
coldcard_setup_needed=true
134134
else
135135
cd firmware
136-
git reset --hard HEAD~3 # Undo git-am for checking and updating
137-
git fetch
138-
139-
# Determine if we need to pull. From https://stackoverflow.com/a/3278427
140-
UPSTREAM=${1:-'@{u}'}
141-
LOCAL=$(git rev-parse @)
142-
REMOTE=$(git rev-parse "$UPSTREAM")
143-
BASE=$(git merge-base @ "$UPSTREAM")
136+
# Ensure repo matches upstream (handles seeded artifact without local commits)
137+
git fetch origin
138+
git reset --hard origin/master
139+
coldcard_setup_needed=true
144140

145-
if [ $LOCAL = $REMOTE ]; then
146-
echo "Up-to-date"
147-
elif [ $LOCAL = $BASE ]; then
148-
git pull
149-
coldcard_setup_needed=true
150-
fi
141+
# No additional pull needed; hard-reset above already synced to upstream
151142
fi
152-
# Apply patch to make simulator work in linux environments
153-
git am ../../data/coldcard-multisig.patch
154143

155144
# Build the simulator. This is cached, but it is also fast
156145
poetry run pip install -r requirements.txt
157146
pip install -r requirements.txt
158147
cd unix
159148
if [ "$coldcard_setup_needed" == true ] ; then
149+
# Apply patch to make simulator work in linux environments
150+
git am ../../../data/coldcard-multisig.patch
151+
160152
pushd ../external/micropython/mpy-cross/
161153
make
162154
popd

0 commit comments

Comments
 (0)