Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 103 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- master
schedule:
- cron: '15 0 * * *' # every day at 00:15 UTC
- cron: "15 0 * * *" # every day at 00:15 UTC

env:
CARGO_TERM_COLOR: always
Expand All @@ -28,14 +28,14 @@ jobs:
- name: Install rust
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)
- name: Build
run: cargo build --release --locked --features trezor
run: cargo build --release --locked --features trezor,ledger
- name: Run tests
run: cargo test --release --workspace --features trezor
run: cargo test --release --workspace --features trezor,ledger
- name: Run doc tests
run: cargo test --release --doc --features trezor
run: cargo test --release --doc --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run mixed_sighash_types test
run: cargo test --release mixed_sighash_types --features trezor
run: cargo test --release mixed_sighash_types --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run test_4opc_sequences test
run: cargo test --release test_4opc_sequences -- --ignored
Expand All @@ -59,18 +59,18 @@ jobs:
- name: Update local dependency repositories
run: sudo apt-get update
- name: Install build dependencies
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml podman pkg-config libssl-dev
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml podman pkg-config libssl-dev libdbus-1-dev libusb-1.0-0-dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for ledger tests? I don't think you run them yet though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for compilation

- name: Install rust
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)
- name: Build
run: cargo build --release --locked --features trezor
run: cargo build --release --locked --features trezor,ledger
- name: Run tests
run: cargo test --release --workspace --features trezor
run: cargo test --release --workspace --features trezor,ledger
- name: Run doc tests
run: cargo test --release --doc --features trezor
run: cargo test --release --doc --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run mixed_sighash_types test
run: cargo test --release mixed_sighash_types --features trezor
run: cargo test --release mixed_sighash_types --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run test_4opc_sequences test
run: cargo test --release test_4opc_sequences
Expand All @@ -94,14 +94,14 @@ jobs:
- name: Install rust
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)
- name: Build
run: cargo build --release --locked --features trezor
run: cargo build --release --locked --features trezor,ledger
- name: Run tests
run: cargo test --release --workspace --features trezor
run: cargo test --release --workspace --features trezor,ledger
- name: Run doc tests
run: cargo test --release --doc --features trezor
run: cargo test --release --doc --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run mixed_sighash_types test
run: cargo test --release mixed_sighash_types --features trezor
run: cargo test --release mixed_sighash_types --features trezor,ledger
# This test is ignored, so it needs to run separately.
- name: Run test_4opc_sequences test
run: cargo test --release test_4opc_sequences
Expand All @@ -117,9 +117,9 @@ jobs:
run_tests_on_trezor_preparation:
runs-on: ubuntu-latest
steps:
# Note: we need to mimic the directory structure of the run_tests_on_trezor job, otherwise nextest
# will fail to execute archived tests. So we checkout the source code to "./mintlayer-core".
# (Also note that because of this the resulting path of the source dir will be "/.../mintlayer-core/mintlayer-core/mintlayer-core")
# Note: we need to mimic the directory structure of the run_tests_on_trezor job, otherwise nextest
# will fail to execute archived tests. So we checkout the source code to "./mintlayer-core".
# (Also note that because of this the resulting path of the source dir will be "/.../mintlayer-core/mintlayer-core/mintlayer-core")
- name: Checkout the core repository
uses: actions/checkout@v4
with:
Expand All @@ -130,7 +130,7 @@ jobs:
run: sudo apt-get update

- name: Install build dependencies
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml pkg-config libssl-dev
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml pkg-config libssl-dev libdbus-1-dev libusb-1.0-0-dev

Comment on lines +133 to 134
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We don't even run any tests in this job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for compilation purposes

- name: Extract required info from Cargo.toml
id: extract_cargo_info
Expand Down Expand Up @@ -227,13 +227,91 @@ jobs:
# Note: since we haven't installed Cargo in this job, we have to execute "cargo-nextest nextest"
# instead of "cargo nextest".
- name: Run tests in the emulator
run:
nix-shell --run "
poetry run core/emu.py
--headless --quiet --temporary-profile
--mnemonic \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"
--command env --chdir ../mintlayer-core
cargo-nextest nextest run --archive-file tests.tar.zst -j1 trezor_signer
run: nix-shell --run "
poetry run core/emu.py
--headless --quiet --temporary-profile
--mnemonic \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"
--command env --chdir ../mintlayer-core
cargo-nextest nextest run --archive-file tests.tar.zst -j1 trezor_signer
"
working-directory: ./mintlayer-trezor-firmware
timeout-minutes: 10

# Build Ledger-specific tests and archive them
run_tests_on_ledger_preparation:
runs-on: ubuntu-latest
steps:
- name: Checkout the core repository
uses: actions/checkout@v4
with:
submodules: recursive
path: ./mintlayer-core
- name: Update local dependency repositories
run: sudo apt-get update
- name: Install build dependencies
run: sudo apt-get install -yqq --no-install-recommends build-essential pkg-config libdbus-1-dev libusb-1.0-0-dev
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Build and archive the tests
run: cargo nextest archive --release --locked -p wallet --features enable-ledger-device-tests --archive-file ledger-tests.tar.zst
working-directory: ./mintlayer-core
- name: Upload archived tests
uses: actions/upload-artifact@v4
with:
name: archived-ledger-tests
path: ./mintlayer-core/ledger-tests.tar.zst
retention-days: 1

# Run Ledger-specific tests on an emulator
run_tests_on_ledger:
needs: run_tests_on_ledger_preparation
runs-on: ubuntu-latest
steps:
- name: Checkout the core repository
uses: actions/checkout@v4
with:
submodules: recursive
path: ./mintlayer-core
- name: Checkout mintlayer-ledger-app repository
uses: actions/checkout@v4
with:
repository: mintlayer/mintlayer-ledger-app
ref: feature/mintlayer-app
path: ./mintlayer-ledger-app
- name: Download archived tests
uses: actions/download-artifact@v4
with:
name: archived-ledger-tests
path: ./mintlayer-core
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Build Ledger app in container
run: |
sudo docker run --rm \
-v "$(realpath ./mintlayer-ledger-app):/app" \
ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest \
sh -c 'cd /app && cargo ledger build nanosplus'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to run the tests for all possible models.

(This is the whole reason of having run_tests_on_trezor_preparation as a separate job - so that the tests are not built over and over again.)

To run a job multiple times with different parameters you use strategy.matrix - the job will be run once for each combination of variables inside it. E.g. in run_tests_on_trezor there is one variable called model, which is then referenced as ${{ matrix.model }} inside the job's body.

Something similar should be done for Ledger.

- name: Run Ledger emulator and execute tests
run: |
set -e

sudo docker run -d --rm --name ledger-emulator \
-v "$(realpath ./mintlayer-ledger-app):/app" \
--publish 5001:5001 --publish 9999:9999 \
ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest \
sh -c 'cd /app && speculos --apdu-port 9999 --api-port 5001 --display headless --model nanosp -s "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" target/nanosplus/release/mintlayer-app'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think /app is the starting workdir inside the container anyway, so no need to cd into it explicitly. Same for the step above, where you build the app.
  2. I believe the --model parameter is redundant, because the emulator can deduce it from the app binary.


echo "--- Waiting for emulator to initialize ---"
sleep 15

# Set up a trap to ensure the container is stopped even if tests fail or the job is cancelled
trap "echo '--- Dumping Ledger emulator logs ---'; sudo docker logs ledger-emulator; echo '--- Stopping Ledger emulator ---'; sudo docker stop ledger-emulator" EXIT

echo "--- Running Ledger device tests on the host ---"
cd ./mintlayer-core
cargo-nextest nextest run --archive-file ledger-tests.tar.zst -j1 ledger_signer || test_exit_code=$?

exit $test_exit_code
timeout-minutes: 15
2 changes: 1 addition & 1 deletion .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Update local dependency repositories
run: sudo apt-get update
- name: Install dependencies
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml
run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml libdbus-1-dev libusb-1.0-0-dev

Comment on lines +28 to 29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed in static_checks_ubuntu?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for compilation

- name: Install rust
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)
Expand Down
Loading
Loading