Reusable Build and Test an App with last nightly #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Reusable Build and Test an App with last nightly | |
permissions: | |
contents: read | |
on: | |
workflow_call: | |
inputs: | |
app_name: | |
description: 'The name of the application to build and test' | |
required: true | |
type: string | |
app_branch: | |
description: 'The branch of the application to build and test' | |
required: true | |
type: string | |
workflow_dispatch: | |
inputs: | |
app_name: | |
description: 'The name of the application to build and test' | |
required: true | |
app_branch: | |
description: 'The branch of the application to build and test' | |
required: true | |
# schedule: | |
# * is a special character in YAML so you have to quote this string | |
# - cron: '0 12 * * *' | |
jobs: | |
call_get_app_metadata: | |
# This job digests inputs and repository metadata provided by the `ledger_app.toml` manifest | |
# file, in order to output relevant directories, compatible devices, and other variables needed | |
# by following jobs. | |
name: Retrieve application metadata | |
uses: LedgerHQ/ledger-app-workflows/.github/workflows/_get_app_metadata.yml@v1 | |
with: | |
app_repository: LedgerHQ/${{ inputs.app_name }} | |
app_branch_name: ${{ inputs.app_branch }} | |
build_with_last_nightly: | |
needs: call_get_app_metadata | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest | |
strategy: | |
matrix: | |
device: ${{ fromJSON(needs.call_get_app_metadata.outputs.compatible_devices) }} | |
steps: | |
- name: install nightly toolchain | |
run: | | |
rustup toolchain install nightly | |
rustup component add rust-src --toolchain nightly | |
export RUST_NIGHTLY=nightly | |
cargo ledger setup | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
repository: LedgerHQ/${{ inputs.app_name }} | |
ref: ${{ inputs.app_branch }} | |
path: ${{ inputs.app_name }} | |
submodules: true | |
- name: Patch Cargo.toml to use y333/nightly_support for ledger_device_sdk, ledger_secure_sdk_sys, include_gif crates | |
run: | | |
cd ${{ inputs.app_name }}/${{ needs.call_get_app_metadata.outputs.build_directory }} | |
# Patch include_gif | |
echo "" >> Cargo.toml && \ | |
echo "[patch.crates-io.include_gif]" >> Cargo.toml && \ | |
echo "git = \"https://github.com/LedgerHQ/ledger-device-rust-sdk.git\"" >> Cargo.toml && \ | |
echo "branch = \"y333/nightly_support\"" >> Cargo.toml | |
# Patch ledger_secure_sdk_sys | |
echo "" >> Cargo.toml && \ | |
echo "[patch.crates-io.ledger_secure_sdk_sys]" >> Cargo.toml && \ | |
echo "git = \"https://github.com/LedgerHQ/ledger-device-rust-sdk.git\"" >> Cargo.toml && \ | |
echo "branch = \"y333/nightly_support\"" >> Cargo.toml | |
# Patch ledger_device_sdk | |
echo "" >> Cargo.toml && \ | |
echo "[patch.crates-io.ledger_device_sdk]" >> Cargo.toml && \ | |
echo "git = \"https://github.com/LedgerHQ/ledger-device-rust-sdk.git\"" >> Cargo.toml && \ | |
echo "branch = \"y333/nightly_support\"" >> Cargo.toml | |
echo "Display patched Cargo.toml:" | |
cat Cargo.toml | |
- name: Build | |
run: | | |
cd ${{ inputs.app_name }}/${{ needs.call_get_app_metadata.outputs.build_directory }} | |
cargo update include_gif | |
cargo update ledger_secure_sdk_sys | |
cargo update ledger_device_sdk | |
# if ${{matrix.device}} is 'nanosp', transform to 'nanosplus' for cargo ledger build command | |
if [ "${{ matrix.device }}" = "nanosp" ]; then | |
DEVICE="nanosplus" | |
else | |
DEVICE="${{ matrix.device }}" | |
fi | |
echo "Building for device: $DEVICE" | |
cargo ledger build $DEVICE | |
BINARY_PATH=$(cargo metadata --no-deps --format-version 1 | jq -r '.target_directory')/ && \ | |
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV | |
echo "BINARY_PATH is: $BINARY_PATH" | |
- name: Remove useless artifacts from previous build | |
run: | | |
find ${{ env.BINARY_PATH }} -mindepth 3 -maxdepth 3 -type d -exec rm -rf {} + && \ | |
rm -rf ${{ env.BINARY_PATH }}/release | |
- name: Upload binary artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ inputs.app_name }}_binaries-${{ matrix.device }}" | |
path: ${{env.BINARY_PATH}} | |
if-no-files-found: error | |
build_check_signature_starknet: | |
name: Build binary used to check signture during the test | |
if: ${{ inputs.app_name == 'app-starknet' }} | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
repository: LedgerHQ/${{ inputs.app_name }} | |
ref: ${{ inputs.app_branch }} | |
path: ${{ inputs.app_name }} | |
submodules: true | |
- name: Build | |
working-directory: ${{ inputs.app_name }}/tools/check-signature | |
run: | | |
cargo build | |
- name: Upload app binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-signature | |
path: ${{ inputs.app_name }}/tools/check-signature/target/debug/check-signature | |
if-no-files-found: error | |
merge_artifacts: | |
name: Merge build artifacts | |
needs: build_with_last_nightly | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Merge artifacts | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: "${{ inputs.app_name }}_binaries" | |
pattern: "${{ inputs.app_name }}_binaries-*" | |
delete-merged: true | |
ragger_tests: | |
name: Run ragger tests using the reusable workflow | |
if: ${{ inputs.app_name != 'app-starknet' }} | |
needs: merge_artifacts | |
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1 | |
with: | |
app_repository: LedgerHQ/${{ inputs.app_name }} | |
app_branch_name: ${{ inputs.app_branch }} | |
download_app_binaries_artifact: "${{ inputs.app_name }}_binaries" | |
ragger_tests_starknet: | |
name: Run ragger tests using the reusable workflow | |
if: ${{ inputs.app_name == 'app-starknet' }} | |
needs: [merge_artifacts, build_check_signature_starknet] | |
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1 | |
with: | |
app_repository: LedgerHQ/${{ inputs.app_name }} | |
app_branch_name: ${{ inputs.app_branch }} | |
download_app_binaries_artifact: "${{ inputs.app_name }}_binaries" | |
additional_app_binaries_artifact: "check-signature" |