Skip to content

Commit f13c42b

Browse files
Update CI
- The docker images only start the emulators, the testing is done outside the image - Test both the latest rust version and the MSRV - Add protobuf to the requirements.txt, as it's needed for CI to run properly (I suppose it's needed for most systems as well)
1 parent bb240fe commit f13c42b

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,35 @@ jobs:
2121
with:
2222
token: ${{ secrets.GITHUB_TOKEN }}
2323
args: --all-features -- -D warnings
24-
test_ledger:
24+
test_emulators:
2525
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
rust:
29+
- version: 1.61.0 # STABLE
30+
- version: 1.41.1 # MSRV
31+
emulator:
32+
- name: trezor
33+
- name: ledger
2634
steps:
27-
- uses: actions/checkout@v3
28-
- run: wget "https://github.com/LedgerHQ/speculos/blob/master/apps/nanos%23btc%232.1%231c8db8da.elf?raw=true" -O ci/btc.elf
29-
- run: docker build -t hwi/ledger_emulator ./ci -f ci/Dockerfile.ledger
30-
- run: docker run --rm --name simulator --publish 41000:41000 hwi/ledger_emulator --display headless --vnc-port 41000 btc.elf &
31-
- run: docker cp ./ simulator:/rust-hwi/
32-
- run: docker exec -w /rust-hwi simulator /root/.cargo/bin/cargo test
33-
test_trezor:
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v3
37-
- run: docker build -t hwi/trezor_emulator ./ci -f ci/Dockerfile.trezor
38-
- run: docker run --name simulator hwi/trezor_emulator &
39-
- run: docker cp ./ simulator:/rust-hwi/
40-
- run: docker exec -w /rust-hwi simulator cargo test
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
- name: Build simulator image
38+
run: docker build -t hwi/${{ matrix.emulator.name }}_emulator ./ci -f ci/Dockerfile.${{ matrix.emulator.name }}
39+
- name: Run simulator image
40+
run: docker run --name simulator --network=host hwi/${{ matrix.emulator.name }}_emulator &
41+
- name: Install Python
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.9'
45+
cache: 'pip'
46+
- name: Install python dependencies
47+
run: pip install -r requirements.txt
48+
- name: Set default toolchain
49+
run: rustup default ${{ matrix.rust.version }}
50+
- name: Set profile
51+
run: rustup set profile minimal
52+
- name: Update toolchain
53+
run: rustup update
54+
- name: Test
55+
run: cargo test

ci/Dockerfile.ledger

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
FROM ghcr.io/ledgerhq/speculos
22

3-
ADD btc.elf /speculos/btc.elf
43
RUN apt-get update
5-
RUN apt-get install libusb-1.0-0-dev build-essential curl git -y
6-
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
7-
RUN pip install protobuf==3.20.1 hwi
4+
RUN apt-get install wget -y
5+
RUN wget "https://github.com/LedgerHQ/speculos/blob/master/apps/nanos%23btc%232.1%231c8db8da.elf?raw=true" -O /speculos/btc.elf
86
ADD automation.json /speculos/automation.json
97

10-
ENTRYPOINT ["python", "./speculos.py", "--automation", "file:automation.json"]
8+
ENTRYPOINT ["python", "./speculos.py", "--automation", "file:automation.json", "--display", "headless", "--vnc-port", "41000", "btc.elf"]

ci/Dockerfile.trezor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN apt-get update
44
RUN apt-get install scons libsdl2-dev python3 python3-pip libsdl2-image-dev llvm-dev libclang-dev clang protobuf-compiler libusb-1.0-0-dev -y
55
RUN git clone --recursive https://github.com/trezor/trezor-firmware/ trezor-firmware
66
WORKDIR /trezor-firmware/core
7-
RUN pip install poetry protobuf==3.20.1 hwi
7+
RUN pip install poetry
88
RUN poetry install
99
RUN poetry run make build_unix
1010
CMD ["poetry", "run", "./emu.py", "--headless", "--slip0014", "-q"]

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
hwi>=2.1.1,<3
1+
hwi>=2.1.1,<3
2+
protobuf==3.20.1

0 commit comments

Comments
 (0)