forked from LedgerHQ/app-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc80d19
commit b095e15
Showing
1 changed file
with
68 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,88 @@ | ||
name: Build all apps on latest SDK | ||
name: Build, test and deploy Ragger | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
run_stax: | ||
type: boolean | ||
required: false | ||
default: false | ||
|
||
sdk_branch: | ||
type: string | ||
required: false | ||
default: '' | ||
push: | ||
tags: | ||
- '*' | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
|
||
env: | ||
BLACKLIST: "app-avalanche" # Add the names of the repositories to exclude here, separated by commas | ||
|
||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
prepare-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install tomlq | ||
run: | | ||
python -m pip install tomlq | ||
build_boilerplate_application: | ||
name: Build boilerplate application using the reusable workflow | ||
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1 | ||
with: | ||
app_repository: LedgerHQ/app-boilerplate | ||
app_branch_name: tdj/remove_nanoS_support | ||
upload_app_binaries_artifact: boilerplate_binaries | ||
|
||
- name: Get C apps repos | ||
run: | | ||
page=1 | ||
result=() | ||
while true; do | ||
repos=$(curl -s "https://api.github.com/orgs/LedgerHQ/repos?page=$page&per_page=200") | ||
if ! echo "$repos" | jq -e '.[].name' >/dev/null; then | ||
# all repos have been listed | ||
echo "all repos have been listed" | ||
break | ||
fi | ||
# add filtered repos to the list | ||
for repo in $(echo "$repos" | jq -r '.[] | select((.name | startswith("app-")) and (.archived == false) and (.private == false)) | .name'); do | ||
default_branch=$(echo "$repos" | jq -r --arg repo "$repo" '.[] | select(.name == $repo) | .default_branch') | ||
if [[ ! " ${BLACKLIST//,/ } " =~ " $repo " ]]; then | ||
result+=("$repo,$default_branch") | ||
else | ||
echo "Skipping blacklisted repository: $repo" | ||
fi | ||
done | ||
build_boilerplate_application_nanos: | ||
name: Build boilerplate application using the reusable workflow | ||
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1 | ||
with: | ||
app_repository: LedgerHQ/app-boilerplate | ||
app_branch_name: nanos_baseline | ||
run_for_devices: '["nanos"]' | ||
upload_app_binaries_artifact: boilerplate_binaries | ||
|
||
((page++)) | ||
done | ||
echo "repo_list=${result[@]}" >> $GITHUB_ENV | ||
- name: Extract metadata | ||
id: set-matrix | ||
run: | | ||
repo_info="[" | ||
for repo in ${{ env.repo_list }}; do | ||
repo_name=$(echo "$repo" | cut -d ',' -f 1) | ||
default_branch=$(echo "$repo" | cut -d ',' -f 2) | ||
toml_content=$(curl -s "https://raw.githubusercontent.com/LedgerHQ/$repo_name/$default_branch/ledger_app.toml") | ||
# check if the toml file is present in the repo and if the repo is not for a rust app | ||
if [[ ! $toml_content =~ "404: Not Found" ]] && [[ ! $toml_content =~ "rust-app" ]]; then | ||
# read toml file attributes | ||
build_directory=$(echo "$toml_content" | tomlq -r '.app.build_directory') | ||
sdk=$(echo "$toml_content" | tomlq -r '.app.sdk') | ||
devices=$(echo "$toml_content" | tomlq -r '.app.devices | join(", ")') | ||
# select only C apps | ||
if [[ $sdk == "C" ]]; then | ||
repo_info+="{\"repo_name\": \"$repo_name\",\"default_branch\": \"$default_branch\", \"build_directory\": \"$build_directory\", \"sdk\": \"$sdk\", \"devices\": \"$devices\"}," | ||
fi | ||
else | ||
echo "$repo does not contain ledger_app.toml" | ||
fi | ||
done | ||
# remove the last "," in json | ||
repo_info_json="${repo_info%,}" | ||
repo_info_json+="]" | ||
echo "matrix=$repo_info_json" >> $GITHUB_OUTPUT | ||
|
||
print-matrix: | ||
needs: [prepare-matrix] | ||
build_install_test: | ||
name: Install and test the library | ||
needs: [build_boilerplate_application] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Print matrix | ||
run: | | ||
echo "Matrix content: ${{ needs.prepare-matrix.outputs.matrix }}" | ||
test-build: | ||
name: Build for all targets | ||
needs: [prepare-matrix] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
repo_info: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest | ||
python_version: ['3.8', '3.9', '3.10', '3.11'] | ||
|
||
steps: | ||
- name: Clone App | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: LedgerHQ/${{ matrix.repo_info.repo_name }} | ||
ref: ${{ matrix.repo_info.default_branch }} | ||
submodules: true | ||
- name: Clone | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python version | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
|
||
- name: Speculos dependencies | ||
run: sudo apt-get update && sudo apt-get install -y qemu-user-static tesseract-ocr libtesseract-dev | ||
|
||
- name: Build & install | ||
run: | | ||
pip install -U .[tests,all_backends] | ||
pip install -U "click>=8" | ||
- name: Download app binaries | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: boilerplate_binaries | ||
path: ./build/ | ||
|
||
- name: Clone SDK | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: LedgerHQ/ledger-secure-sdk | ||
path: sdk | ||
ref: ${{ inputs.sdk_branch }} | ||
- name: Create boilerplate manifest | ||
run: | | ||
echo """[app] | ||
build_directory = \"./\" | ||
sdk = \"C\" | ||
devices = [\"nanos\", \"nanos+\", \"nanox\", \"stax\", \"flex\"]""" > ledger_app.toml | ||
- name: Build NanoS | ||
run: | | ||
if [[ "${{ matrix.repo_info.devices }}" =~ \bnanos\b ]]; then | ||
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }} | ||
TARGET=nanos BOLOS_SDK=$GITHUB_WORKSPACE/sdk make | ||
fi | ||
echo "matrice : ${{ matrix.repo_info.devices }}" | ||
- name: Build NanoX | ||
if: "contains(matrix.repo_info.devices, 'nanox')" | ||
run: | | ||
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }} | ||
TARGET=nanox BOLOS_SDK=$GITHUB_WORKSPACE/sdk make | ||
- name: Check the downloaded files | ||
run: tree . | ||
|
||
- name: Build NanoS2 | ||
if: "contains(matrix.repo_info.devices, 'nanos+')" | ||
run: | | ||
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }} | ||
TARGET=nanos2 BOLOS_SDK=$GITHUB_WORKSPACE/sdk make | ||
- name: Run unit tests and generate coverage | ||
run: pytest -v --tb=short tests/unit --cov ragger --cov-report xml | ||
|
||
- name: Build Stax | ||
if: "contains(matrix.repo_info.devices, 'stax')" | ||
run: | | ||
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }} | ||
TARGET=stax BOLOS_SDK=$GITHUB_WORKSPACE/sdk make | ||
- name: Run functional tests and generate coverage | ||
run: pytest -v --tb=short tests/functional --cov ragger --cov-report xml --cov-append --device all | ||
|
||
- name: Build Europa | ||
if: "contains(matrix.repo_info.devices, 'europa')" | ||
run: | | ||
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }} | ||
TARGET=europa BOLOS_SDK=$GITHUB_WORKSPACE/sdk make | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
name: codecov-ragger |