Skip to content

Commit a2a8f8f

Browse files
Add build and test of ethereum application in CI
1 parent da99751 commit a2a8f8f

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Build the application for all devices and upload the artifact
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
app_repository:
8+
description: 'The GIT repository to build (defaults to `github.repository`)'
9+
required: false
10+
default: ${{ github.repository }}
11+
type: string
12+
app_branch_name:
13+
description: 'The GIT branch to build (defaults to `github.ref`)'
14+
required: false
15+
default: ${{ github.ref }}
16+
type: string
17+
flags:
18+
description: "Additional compilation flags (default to none)"
19+
required: false
20+
default: ''
21+
type: string
22+
upload_app_binaries_artifact:
23+
description: "The name of the artifact containing the built application binary file(s) to be tested"
24+
required: false
25+
default: ''
26+
type: string
27+
28+
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+
compatible_devices: 'None'
39+
40+
build:
41+
name: Build application for NanoS, X, S+, and Stax
42+
needs: call_get_app_metadata
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
device: ${{ fromJSON(needs.call_get_app_metadata.outputs.compatible_devices) }}
47+
runs-on: ubuntu-latest
48+
container:
49+
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest
50+
51+
steps:
52+
- name: Clone
53+
uses: actions/checkout@v4
54+
with:
55+
repository: ${{ inputs.app_repository }}
56+
ref: ${{ inputs.app_branch_name }}
57+
submodules: recursive
58+
59+
- name: Use this version of the ethereum SDK
60+
run: |
61+
rm -rf ./ethereum-plugin-sdk
62+
63+
- name: Checkout SDK PR branch
64+
uses: actions/checkout@v4
65+
with:
66+
path: ethereum-plugin-sdk/
67+
ref: ${{ github.ref }}
68+
repository: ${{ github.repository }}
69+
70+
- name: Build application
71+
id: "build"
72+
shell: bash
73+
run: |
74+
if [[ "${{ needs.call_get_app_metadata.outputs.is_rust }}" == "true" ]];
75+
then
76+
BUILD_DEVICE_NAME="$(echo ${{ matrix.device }} | sed 's/nanosp/nanosplus/')" && \
77+
cd ${{ needs.call_get_app_metadata.outputs.build_directory }} && \
78+
cargo +$RUST_NIGHTLY update ledger_device_sdk && \
79+
cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys && \
80+
cargo ledger build ${BUILD_DEVICE_NAME} && \
81+
echo "binary_path=${{ needs.call_get_app_metadata.outputs.build_directory }}/target/*" >> $GITHUB_OUTPUT && \
82+
echo "Build complete"
83+
else
84+
eval "BOLOS_SDK=\$$(echo ${{ matrix.device }} | tr [:lower:] [:upper:])_SDK" && \
85+
echo "BOLOS_SDK value will be: ${BOLOS_SDK}" && \
86+
make -C ${{ needs.call_get_app_metadata.outputs.build_directory }} -j ${{ inputs.flags }} BOLOS_SDK=${BOLOS_SDK} && \
87+
echo "binary_path=${{ needs.call_get_app_metadata.outputs.build_directory }}/build/*" >> $GITHUB_OUTPUT
88+
echo "Build complete"
89+
fi
90+
91+
- name: Remove build artifacts before upload
92+
run: |
93+
if [[ "${{ needs.call_get_app_metadata.outputs.is_rust }}" == "true" ]];
94+
then
95+
find ${{ needs.call_get_app_metadata.outputs.build_directory }}/target -mindepth 3 -maxdepth 3 -type d -exec rm -rf {} +
96+
else
97+
find ${{ needs.call_get_app_metadata.outputs.build_directory }}/build/ -mindepth 2 -maxdepth 2 -type d ! -name 'bin' -exec rm -r {} +
98+
fi
99+
100+
- name: Upload app binary
101+
if: ${{ inputs.upload_app_binaries_artifact != '' }}
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: ${{ inputs.upload_app_binaries_artifact }}
105+
path: ${{ steps.build.outputs.binary_path }}
106+
if-no-files-found: error
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Build and run tests using the SDK
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- master
9+
- main
10+
- develop
11+
pull_request:
12+
13+
jobs:
14+
build_ethereum_application:
15+
name: Build application using the reusable workflow
16+
uses: ./.github/workflows/_reusable_build_with_submodule_injection.yml
17+
with:
18+
app_repository: LedgerHQ/app-ethereum
19+
app_branch_name: develop
20+
upload_app_binaries_artifact: "ethereum_binaries"
21+
flags: "CAL_TEST_KEY=1 DOMAIN_NAME_TEST_KEY=1 SET_PLUGIN_TEST_KEY=1 NFT_TEST_KEY=1"
22+
23+
ragger_ethereum_tests:
24+
name: Run ragger tests using the reusable workflow
25+
needs: build_ethereum_application
26+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
27+
with:
28+
app_repository: LedgerHQ/app-ethereum
29+
app_branch_name: develop
30+
download_app_binaries_artifact: "ethereum_binaries"
31+
32+
build_plugin_boilerplate_application:
33+
name: Build application using the reusable workflow
34+
uses: ./.github/workflows/_reusable_build_with_submodule_injection.yml
35+
with:
36+
app_repository: LedgerHQ/app-plugin-boilerplate
37+
app_branch_name: develop
38+
upload_app_binaries_artifact: "plugin_boilerplate_binaries"
39+
40+
ragger_plugin_boilerplate_tests:
41+
name: Run ragger tests using the reusable workflow
42+
needs: build_plugin_boilerplate_application
43+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
44+
with:
45+
app_repository: LedgerHQ/app-plugin-boilerplate
46+
app_branch_name: develop
47+
download_app_binaries_artifact: "plugin_boilerplate_binaries"
48+
additional_app_binaries_artifact: "ethereum_binaries"
49+
additional_app_binaries_artifact_dir: ./tests/.test_dependencies/ethereum/build

0 commit comments

Comments
 (0)