Skip to content

Commit e7ae4ba

Browse files
authored
Merge pull request #289 from LedgerHQ/y333/update_build_nightly_worflow
Update nightly build workflow
2 parents 910ecc6 + 1e4fd24 commit e7ae4ba

File tree

1 file changed

+92
-26
lines changed

1 file changed

+92
-26
lines changed
Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,117 @@
1-
name: Build and Test with last nightly everyday @12PM
1+
name: Build and Test with last nightly
2+
permissions:
3+
contents: read
24

35
on:
6+
workflow_call:
7+
inputs:
8+
app_repository:
9+
description: 'The repository of the application to build and test'
10+
required: true
11+
type: string
12+
app_branch_name:
13+
description: 'The branch of the application to build and test'
14+
required: true
15+
type: string
416
workflow_dispatch:
17+
inputs:
18+
app_repository:
19+
description: 'The repository of the application to build and test'
20+
required: true
21+
app_branch_name:
22+
description: 'The branch of the application to build and test'
23+
required: true
524
# schedule:
625
# * is a special character in YAML so you have to quote this string
726
# - cron: '0 12 * * *'
827

928
jobs:
29+
call_get_app_metadata:
30+
# This job digests inputs and repository metadata provided by the `ledger_app.toml` manifest
31+
# file, in order to output relevant directories, compatible devices, and other variables needed
32+
# by following jobs.
33+
name: Retrieve application metadata
34+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/_get_app_metadata.yml@v1
35+
with:
36+
app_repository: ${{ inputs.app_repository }}
37+
app_branch_name: ${{ inputs.app_branch_name }}
38+
1039
build_with_last_nightly:
40+
needs: call_get_app_metadata
1141
runs-on: ubuntu-latest
1242
container:
1343
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
1444
strategy:
1545
matrix:
16-
device: ["nanox", "nanosplus", "stax", "flex"]
46+
device: ${{ fromJSON(needs.call_get_app_metadata.outputs.compatible_devices) }}
1747
steps:
18-
- name: update nightly toolchain
48+
- name: install nightly toolchain
1949
run: |
20-
rustup update nightly
50+
rustup toolchain install nightly
2151
rustup component add rust-src --toolchain nightly
22-
cargo +nightly ledger setup
52+
export RUST_NIGHTLY=nightly
53+
cargo ledger setup
2354
2455
- name: Checkout Code
2556
uses: actions/checkout@v4
2657
with:
27-
repository: LedgerHQ/app-boilerplate-rust
28-
path: app-boilerplate
58+
repository: ${{ inputs.app_repository }}
59+
ref: ${{ inputs.app_branch_name }}
60+
61+
- name: Patch Cargo.toml to use y333/nightly_support for ledger_device_sdk and include_gif crate
62+
run: |
63+
cd ${{ needs.call_get_app_metadata.outputs.build_directory }}
64+
sed -i 's|ledger_device_sdk = ".*"|ledger_device_sdk = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "y333/nightly_support" }|' Cargo.toml
65+
sed -i 's|include_gif = ".*"|include_gif = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "y333/nightly_support" }|' Cargo.toml
66+
echo "Display patched Cargo.toml:"
67+
cat Cargo.toml
2968
3069
- name: Build
3170
run: |
32-
BUILD_DEVICE_NAME="$(echo ${{ matrix.device }})"
33-
BIN_DIR_NAME="$(echo ${{ matrix.device }} | sed 's/nanosplus/nanos2/')"
34-
cd app-boilerplate
35-
cargo ledger build ${{ matrix.device }}
71+
cargo update include_gif
72+
cargo update ledger_secure_sdk_sys
73+
cargo update ledger_device_sdk
74+
# if ${{matrix.device}} is 'nanosp', transform to 'nanosplus' for cargo ledger build command
75+
if [ "${{ matrix.device }}" = "nanosp" ]; then
76+
DEVICE="nanosplus"
77+
else
78+
DEVICE="${{ matrix.device }}"
79+
fi
80+
echo "Building for device: $DEVICE"
81+
cargo ledger build $DEVICE
82+
BINARY_PATH=$(cargo metadata --no-deps --format-version 1 | jq -r '.target_directory')/ && \
83+
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
84+
echo "BINARY_PATH is: $BINARY_PATH"
85+
86+
- name: Remove useless artifacts from previous build
87+
run: |
88+
find ${{ env.BINARY_PATH }} -mindepth 3 -maxdepth 3 -type d -exec rm -rf {} + && \
89+
rm -rf ${{ env.BINARY_PATH }}/release
3690
37-
#- name: Upload binary artifacts
38-
# uses: actions/upload-artifact@v3
39-
# with:
40-
# name: "app_elf_binaries"
41-
# path: app-boilerplate/target/*
42-
# if-no-files-found: error
43-
44-
#ragger_tests:
45-
# name: Run ragger tests using the reusable workflow
46-
# needs: build_with_last_nightly
47-
# uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
48-
# with:
49-
# app_repository: LedgerHQ/app-boilerplate-rust
50-
# app_branch_name: "main"
51-
# download_app_binaries_artifact: "app_elf_binaries"
91+
- name: Upload binary artifacts
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: "app_binaries-${{ matrix.device }}"
95+
path: ${{env.BINARY_PATH}}
96+
if-no-files-found: error
97+
98+
merge_artifacts:
99+
name: Merge build artifacts
100+
needs: build_with_last_nightly
101+
runs-on: ubuntu-22.04
102+
steps:
103+
- name: Merge artifacts
104+
uses: actions/upload-artifact/merge@v4
105+
with:
106+
name: "app_binaries"
107+
pattern: "app_binaries-*"
108+
delete-merged: true
109+
110+
ragger_tests:
111+
name: Run ragger tests using the reusable workflow
112+
needs: merge_artifacts
113+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
114+
with:
115+
app_repository: ${{ inputs.app_repository }}
116+
app_branch_name: ${{ inputs.app_branch_name }}
117+
download_app_binaries_artifact: "app_binaries"

0 commit comments

Comments
 (0)