2525 - name : Install python toml package
2626 run : python3 -m pip install toml
2727 - name : Install rust
28- run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version -extractor/rust-version-extractor.py )
28+ run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/cargo-info -extractor/extract.py -- rust-version)
2929 - name : Build
3030 run : cargo build --release --locked --features trezor
3131 - name : Run tests
@@ -58,12 +58,10 @@ jobs:
5858 submodules : recursive
5959 - name : Update local dependency repositories
6060 run : sudo apt-get update
61- - name : Install dependencies
62- run : sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml podman build-essential pkg-config libssl-dev
63- - name : Install rust deps
64- run : sudo apt-get install -yqq build-essential pkg-config libssl-dev
61+ - name : Install build dependencies
62+ run : sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml podman pkg-config libssl-dev
6563 - name : Install rust
66- run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version -extractor/rust-version-extractor.py )
64+ run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/cargo-info -extractor/extract.py -- rust-version)
6765 - name : Build
6866 run : cargo build --release --locked --features trezor
6967 - name : Run tests
9593 - name : Install python toml package
9694 run : python3 -m pip install toml --break-system-packages --user
9795 - name : Install rust
98- run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version -extractor/rust-version-extractor.py )
96+ run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/cargo-info -extractor/extract.py -- rust-version)
9997 - name : Build
10098 run : cargo build --release --locked --features trezor
10199 - name : Run tests
@@ -115,3 +113,128 @@ jobs:
115113 with :
116114 name : macos-functional-test-artifacts
117115 path : target/tmp
116+
117+ # Build Trezor-specific tests and archive them using cargo-nextest's "archive" feature.
118+ run_tests_on_trezor_preparation :
119+ runs-on : ubuntu-latest
120+ steps :
121+ # Note: we need to mimic the directory structure of the run_tests_on_trezor job, otherwise nextest
122+ # will fail to execute archived tests. So we checkout the source code to "./mintlayer-core".
123+ # (Also note that because of this the resulting path of the source dir will be "/.../mintlayer-core/mintlayer-core/mintlayer-core")
124+ - name : Checkout the core repository
125+ uses : actions/checkout@v4
126+ with :
127+ submodules : recursive
128+ path : ./mintlayer-core
129+
130+ - name : Update local dependency repositories
131+ run : sudo apt-get update
132+
133+ - name : Install build dependencies
134+ run : sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml pkg-config libssl-dev
135+
136+ - name : Extract required info from Cargo.toml
137+ id : extract_cargo_info
138+ run : echo "RUST_VERSION=$(python3 ./build-tools/cargo-info-extractor/extract.py --rust-version)" >> $GITHUB_OUTPUT
139+ working-directory : ./mintlayer-core
140+
141+ - name : Install rust
142+ run : curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ steps.extract_cargo_info.outputs.RUST_VERSION }}
143+
144+ - name : Install cargo-nextest
145+ uses : taiki-e/install-action@nextest
146+
147+ - name : Build and archive the tests
148+ run : cargo nextest archive --release --locked -p wallet --features enable-trezor-device-tests --archive-file tests.tar.zst
149+ working-directory : ./mintlayer-core
150+
151+ - name : Upload archived tests
152+ uses : actions/upload-artifact@v4
153+ with :
154+ name : archived-trezor-tests
155+ path : ./mintlayer-core/tests.tar.zst
156+ retention-days : 1
157+
158+ run_tests_on_trezor :
159+ needs : run_tests_on_trezor_preparation
160+ runs-on : ubuntu-latest
161+ strategy :
162+ matrix :
163+ model : [T2T1, T3B1, T3T1, T3W1]
164+ env :
165+ TREZOR_MODEL : ${{ matrix.model }}
166+ # Note: these are the default values, but it's better to specify them explicitly.
167+ TREZOR_TESTS_USE_REAL_DEVICE : false
168+ TREZOR_TESTS_AUTO_CONFIRM : true
169+ steps :
170+ # Note: cargo-nextest requires the source code to be present when running archived test binaries.
171+ - name : Checkout the core repository
172+ uses : actions/checkout@v4
173+ with :
174+ submodules : recursive
175+ path : ./mintlayer-core
176+
177+ - name : Download archived tests
178+ uses : actions/download-artifact@v4
179+ with :
180+ name : archived-trezor-tests
181+ path : ./mintlayer-core
182+
183+ - name : Install cargo-nextest
184+ uses : taiki-e/install-action@nextest
185+
186+ - name : Update local dependency repositories
187+ run : sudo apt-get update
188+
189+ - name : Install other necessary tools
190+ run : sudo apt-get install -yqq --no-install-recommends python3 python3-toml
191+
192+ - name : Extract required info from Cargo.toml
193+ id : extract_cargo_info
194+ run : |
195+ echo "TREZOR_REPO_REV=$(python3 ./build-tools/cargo-info-extractor/extract.py --trezor-repo-rev)" >> $GITHUB_OUTPUT
196+ working-directory : ./mintlayer-core
197+
198+ - name : Checkout mintlayer-trezor-firmware repository
199+ uses : actions/checkout@v4
200+ with :
201+ repository : mintlayer/mintlayer-trezor-firmware
202+ ref : ${{ steps.extract_cargo_info.outputs.TREZOR_REPO_REV }}
203+ submodules : recursive
204+ path : ./mintlayer-trezor-firmware
205+
206+ # Note: this is basically a copy of ".github/actions/environment" from the trezor repo, with
207+ # the "full-deps" parameter equal to false (which is the default).
208+ # Also note that the original "environment" action could technically be called from here
209+ # via "uses", so in theory the duplication could be avoided. Unfortunately, the "nix-shell"
210+ # calls require the current directory to be the one where the trezor repo has been checked out
211+ # and there is no way of overriding the working dir for another action (unless the action itself
212+ # supports it).
213+ - name : Install nix
214+ uses : cachix/install-nix-action@v23
215+ with :
216+ nix_path : nixpkgs=channel:nixos-unstable
217+ - name : Setup trezor repo build dependencies, part 1
218+ run : nix-shell --arg fullDeps false --run "true"
219+ working-directory : ./mintlayer-trezor-firmware
220+ - name : Setup trezor repo build dependencies, part 2
221+ run : nix-shell --arg fullDeps false --run "poetry install"
222+ working-directory : ./mintlayer-trezor-firmware
223+
224+ - name : Build the firmware
225+ run : nix-shell --run "poetry run make -C core build_unix"
226+ working-directory : ./mintlayer-trezor-firmware
227+
228+ # Note: since we haven't installed Cargo in this job, we have to execute "cargo-nextest nextest"
229+ # instead of "cargo nextest".
230+ - name : Run tests in the emulator
231+ run :
232+ nix-shell --run "
233+ poetry run core/emu.py
234+ --headless --quiet --temporary-profile
235+ --mnemonic \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"
236+ --command env --chdir ../mintlayer-core
237+ cargo-nextest nextest run --archive-file tests.tar.zst -j1 trezor_signer
238+ "
239+ working-directory: ./mintlayer-trezor-firmware
240+ timeout-minutes: 10
0 commit comments