Skip to content

feat: Add const generic address buffer size to Swap params #41

feat: Add const generic address buffer size to Swap params

feat: Add const generic address buffer size to Swap params #41

name: Build all Rust apps
on:
workflow_call:
inputs:
c_sdk_branch:
required: false
default: ''
type: string
workflow_dispatch:
pull_request:
env:
C_SDK_URL: 'https://github.com/LedgerHQ/ledger-secure-sdk.git'
jobs:
how-workflow-is-called:
name: Determine how the workflow is called
runs-on: ubuntu-latest
outputs:
repository: ${{ steps.get_repo_and_branch.outputs.repo }}
branch: ${{ steps.get_repo_and_branch.outputs.branch }}
steps:
- name: Get repository and branch
id: get_repo_and_branch
run: |
if [ -n "${{ inputs.c_sdk_branch }}" ]; then
echo "repo=LedgerHQ/ledger-device-rust-sdk" >> $GITHUB_OUTPUT
echo "branch=master" >> $GITHUB_OUTPUT
else
echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT
echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
retrieve-rust-apps:
name: Retrieve Rust Apps
runs-on: ubuntu-latest
needs: how-workflow-is-called
outputs:
rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ needs.how-workflow-is-called.outputs.repository }}
ref: ${{ needs.how-workflow-is-called.outputs.branch }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install ledgered
run: pip install ledgered
- name: Get all rust apps
id: get_rust_apps
run: |
python .github/workflows/get_rust_apps.py ${{ secrets.GITHUB_TOKEN }}
echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT
display-rust-apps:
name: Display Rust Apps
runs-on: ubuntu-latest
needs: retrieve-rust-apps
steps:
- name: Display Rust Apps
run: |
echo "Rust apps: ${{ needs.retrieve-rust-apps.outputs.rust_apps }}"
test-build:
name: Build for all targets
needs: [retrieve-rust-apps, how-workflow-is-called]
strategy:
fail-fast: false
matrix:
app-name: ["app-boilerplate-rust"]
device: ["nanos+", "nanox", "stax", "flex"]
include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }}
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- name: Install ledgered
run: pip install ledgered --break-system-packages
- name: Clone SDK
uses: actions/checkout@v4
with:
path: sdk
repository: ${{ needs.how-workflow-is-called.outputs.repository }}
ref: ${{ needs.how-workflow-is-called.outputs.branch }}
- name: Clone App
uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app-name }}
submodules: true
path: ${{ matrix.app-name }}
- name: Patch Cargo.toml
continue-on-error: false
run: |
cd ${{ matrix.app-name }}
build_directory=$(ledger-manifest --output-build-directory ledger_app.toml)
cd $build_directory
workspace_root=$(cargo metadata --no-deps --format-version 1 | jq -r '.workspace_root')
cargo_toml_path="$workspace_root/Cargo.toml"
# Patch ledger_device_sdk
echo "" >> $cargo_toml_path
echo "[patch.crates-io.ledger_device_sdk]" >> $cargo_toml_path
path=\"$GITHUB_WORKSPACE/sdk/ledger_device_sdk\"
echo "path=$path" >> $cargo_toml_path
echo "Patch added to Cargo.toml"
# Patch ledger_secure_sdk_sys
echo "" >> $cargo_toml_path
echo "[patch.crates-io.ledger_secure_sdk_sys]" >> $cargo_toml_path
path=\"$GITHUB_WORKSPACE/sdk/ledger_secure_sdk_sys\"
echo "path=$path" >> $cargo_toml_path
echo "Patch added to Cargo.toml"
# Patch include_gif
echo "" >> $cargo_toml_path
echo "[patch.crates-io.include_gif]" >> $cargo_toml_path
path=\"$GITHUB_WORKSPACE/sdk/include_gif\"
echo "path=$path" >> $cargo_toml_path
echo "Patch added to Cargo.toml"
# Print Cargo.toml
echo "Cargo.toml:"
cat $cargo_toml_path
- name: Build
run: |
# Clone C SDK if provided
if [ -n "${{ inputs.c_sdk_branch }}" ]; then
git clone $C_SDK_URL --branch ${{ inputs.c_sdk_branch }} --single-branch c_sdk
echo "setting LEDGER_SDK_PATH to $(realpath c_sdk)"
LEDGER_SDK_PATH=$(realpath c_sdk)
else
echo "using C SDK from ledger-app-builder"
fi
cd ${{ matrix.app-name }}
build_directory=$(ledger-manifest --output-build-directory ledger_app.toml)
cd $build_directory
# Required as patch has a different version from what is locked in Cargo.lock
cargo +$RUST_NIGHTLY update include_gif
cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys
cargo +$RUST_NIGHTLY update ledger_device_sdk
device=$(echo ${{ matrix.device }} | sed 's/+/plus/')
echo "Build for "$device
cargo ledger build $device