Skip to content

Simplify AUTOAPPROVE mechanisms on all V-Apps #1286

Simplify AUTOAPPROVE mechanisms on all V-Apps

Simplify AUTOAPPROVE mechanisms on all V-Apps #1286

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
name:
description: 'Manually triggered'
env:
CARGO_TERM_COLOR: always
jobs:
test_app_sdk:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "app-sdk"
test_dirs_json: '["app-sdk"]'
test_client_sdk:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "client-sdk"
test_dirs_json: '["client-sdk"]'
test_common:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "common"
test_dirs_json: '["common"]'
test_riscv_arch:
name: RISC-V architecture tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dirs
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-stable-riscv-arch-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-stable-riscv-arch-
- name: Install RISC-V cross-compiler
run: sudo apt-get update && sudo apt-get install -y gcc-riscv64-unknown-elf
- name: Clone riscv-arch-test suite
run: |
git clone --depth 1 --branch 3.9.1 \
https://github.com/riscv-non-isa/riscv-arch-test \
riscv-arch-tests/vendor/riscv-arch-test
- name: Run RISC-V arch tests
run: cargo test -p vanadium-riscv-arch-tests
# build Vanadium VM app
build_vanadium_app:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "vanadium_binaries"
builder: ledger-app-builder
cargo_ledger_build_args: "--features blind_registration"
# build a custom binary for the Vanadium VM app only for the tests
build_vanadium_app_for_tests:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "vanadium_binaries_for_tests"
builder: ledger-app-builder
cargo_ledger_build_args: "--features run_tests"
# build a custom binary for the Vanadium VM with metrics and blind_registration enabled
# this allows to collect useful metrics during benchmarks
build_vanadium_app_for_benchmarks:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "vanadium_binaries_for_benchmarks"
builder: ledger-app-builder
cargo_ledger_build_args: "--features metrics,blind_registration"
# Build and run benchmark testcases on speculos
# This also collects execution metrics and uploads them as artifacts
build_benchmark_test_cases:
name: Build and run benchmark V-Apps on Speculos, collect metrics
runs-on: ubuntu-latest
needs: [build_vanadium_app_for_benchmarks]
steps:
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32imac-unknown-none-elf
components: rustfmt, clippy
- name: Cache cargo dirs
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bench-
- name: Install Speculos
run: |
pip install speculos
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -y libudev-dev pkg-config && \
sudo apt-get install -y qemu-user-static libvncserver-dev
- name: Clone
uses: actions/checkout@v4
- name: Download Vanadium binaries for benchmarks
uses: actions/download-artifact@v4
with:
name: vanadium_binaries_for_benchmarks
path: ./vanadium_binaries_for_benchmarks
- name: Build app
working-directory: bench
run: |
for case_dir in ./cases/*; do
(cd "$case_dir" && cargo +stable build --release --target=riscv32imac-unknown-none-elf --no-default-features --features target_vanadium_ledger) || exit 1
done
- name: Run Speculos with Vanadium binary
run: |
speculos --display headless vanadium_binaries_for_benchmarks/flex/release/app-vanadium &
sleep 2
- name: Install vnd-bench
working-directory: tools/bench
run: cargo install --path .
- name: Run benchmarks on Speculos with metrics
working-directory: bench
run: vnd-bench --speculos --metrics --path cases
- name: Upload benchmark metrics
uses: actions/upload-artifact@v4
with:
name: benchmark_metrics
path: bench/*.metrics
# VM app tests in speculos
run_vanadium_app_speculos_tests:
name: Vanadium speculos tests ('run_tests' feature)
strategy:
matrix:
include:
- model: flex # not much reasons to run this test on all devices
runs-on: ubuntu-latest
needs: [build_vanadium_app_for_tests]
steps:
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: x86_64-unknown-linux-gnu
components: rustfmt, clippy
- name: Cache cargo dirs
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-speculos-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-speculos-
- name: Install Speculos
run: |
pip install speculos
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -y libudev-dev pkg-config && \
sudo apt-get install -y qemu-user-static libvncserver-dev
- name: Clone
uses: actions/checkout@v4
- name: Download Vanadium binaries for tests
uses: actions/download-artifact@v4
with:
name: vanadium_binaries_for_tests
path: ./vanadium_binaries_for_tests
- name: Run tests
run: |
speculos --display headless vanadium_binaries_for_tests/${{ matrix.model }}/release/app-vanadium
### V-Apps
## vnd-test
# build test V-App
build_vnd_test:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-test"
vapp_dir: "apps/test/app"
artifact_name: "vnd_test_riscv_binary"
binary_name: "vnd-test"
test_vnd_test_app:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "vnd-test-app"
test_dirs_json: '["apps/test/app"]'
test_vnd_test_app_client:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "vnd-test-client"
test_dirs_json: '["apps/test/client"]'
vnd_test_speculos_integration_tests:
needs: [build_vanadium_app, build_vnd_test]
uses: ./.github/workflows/reusable_vapp_integration_tests.yaml
with:
vapp_name: 'vnd-test'
client_dir: 'apps/test/client'
vanadium_artifact_name: 'vanadium_binaries'
vapp_artifact_name: 'vnd_test_riscv_binary'
vapp_binary_name: 'vnd-test.vapp'
models_json: '["nanox","nanosplus","flex","stax","apex_p"]'
cargo_test_features: 'speculos-tests,debug'
## vnd-sadik
# build sadik V-App
build_vnd_sadik:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-sadik"
vapp_dir: "apps/sadik/app"
artifact_name: "vnd_sadik_riscv_binary"
binary_name: "vnd-sadik"
vnd_sadik_integration_tests:
needs: [build_vanadium_app, build_vnd_sadik]
uses: ./.github/workflows/reusable_vapp_integration_tests.yaml
with:
vapp_name: 'vnd-sadik'
client_dir: 'apps/sadik/client'
vanadium_artifact_name: 'vanadium_binaries'
vapp_artifact_name: 'vnd_sadik_riscv_binary'
vapp_binary_name: 'vnd-sadik.vapp'
models_json: '["nanox","nanosplus","flex","stax","apex_p"]'
cargo_test_features: 'speculos-tests,debug'
vnd_sadik_native_integration_tests:
uses: ./.github/workflows/reusable_vapp_native_integration_tests.yaml
with:
vapp_name: 'vnd-sadik'
vapp_dir: 'apps/sadik/app'
client_dir: 'apps/sadik/client'
vapp_binary_name: 'vnd-sadik'
cargo_test_features: 'native-tests'
## vnd-template
# build template V-App
build_vnd_template:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-template"
vapp_dir: "apps/template/app"
artifact_name: "vnd_template_riscv_binary"
binary_name: "vnd-template"
test_vnd_template_app:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "vnd-template"
test_dirs_json: '["apps/template/app"]'
# check that the generated template is up to date
check_vnd_template:
name: Check that the generated template is up to date
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Run update-template.sh --check
working-directory: apps/template
run: |
./update-template.sh --check
## vnd-bitcoin
# build bitcoin V-App
build_vnd_bitcoin:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-bitcoin"
vapp_dir: "apps/bitcoin/app"
artifact_name: "vnd_bitcoin_riscv_binary"
binary_name: "vnd-bitcoin"
# build bitcoin V-App with autoapprove feature
build_vnd_bitcoin_autoapprove:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-bitcoin-autoapprove"
vapp_dir: "apps/bitcoin/app"
artifact_name: "vnd_bitcoin_riscv_autoapprove_binary"
binary_name: "vnd-bitcoin"
extra_build_args: '--features autoapprove'
test_vnd_bitcoin_app:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "vnd-bitcoin"
test_dirs_json: '["apps/bitcoin/common","apps/bitcoin/app"]'
vnd_bitcoin_integration_tests:
needs: [build_vanadium_app, build_vnd_bitcoin_autoapprove]
uses: ./.github/workflows/reusable_vapp_integration_tests.yaml
with:
vapp_name: 'vnd-bitcoin'
client_dir: 'apps/bitcoin/client'
vanadium_artifact_name: 'vanadium_binaries'
vapp_artifact_name: 'vnd_bitcoin_riscv_autoapprove_binary'
vapp_binary_name: 'vnd-bitcoin.vapp'
models_json: '["nanox","nanosplus","flex","stax","apex_p"]'
cargo_test_features: 'speculos-tests,debug'
## vnd-rps
build_vnd_rps:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-rps"
vapp_dir: "apps/rps/app"
artifact_name: "vnd_rps_riscv_binary"
binary_name: "vnd-rps"
test_vnd_rps_app:
uses: ./.github/workflows/reusable_native_tests.yaml
with:
vapp_name: "vnd-rps"
test_dirs_json: '["apps/rps/app"]'
## vnd-async
build_vnd_async:
uses: ./.github/workflows/reusable_vapp_build.yaml
with:
vapp_name: "vnd-async"
vapp_dir: "apps/async/app"
artifact_name: "vnd_async_riscv_binary"
binary_name: "vnd-async"
## cargo-vnd tool test
test_cargo_vnd_new:
name: Test 'cargo vnd new' command
runs-on: ubuntu-latest
steps:
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Add RISC-V target
run: rustup target add riscv32imac-unknown-none-elf
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get install -y libudev-dev pkg-config binutils-riscv64-unknown-elf
- name: Clone
uses: actions/checkout@v4
- name: Install cargo-vnd
working-directory: cargo-vnd
run: cargo install --locked --path .
- name: Create new V-App using cargo vnd new
run: cargo vnd new --name testapp --template-path "$(pwd)/apps/template/generate"
- name: Build the app for RISC-V target
working-directory: testapp/app
run: cargo build --release --target=riscv32imac-unknown-none-elf --no-default-features --features target_vanadium_ledger
- name: Build the client
working-directory: testapp/client
run: cargo build --release