Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using reusable workflows to trigger all C apps build #844

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 10 additions & 131 deletions .github/workflows/build_all_apps.yml
Original file line number Diff line number Diff line change
@@ -1,142 +1,21 @@
name: Build all apps on latest SDK
name: Build all C apps on latest SDK

on:
workflow_dispatch:
inputs:
sdk_branch:
type: string
required: false
default: ''
default: origin/master
pull_request:


env:
BLACKLIST: "app-avalanche" # Add the names of the repositories to exclude here, separated by commas


jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install tomlq
run: |
python -m pip install tomlq

- 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&type=public")

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)) | .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

((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" ]]; 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]
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

steps:
- name: Clone App
uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.repo_info.repo_name }}
ref: ${{ matrix.repo_info.default_branch }}
submodules: true

- name: Clone SDK
uses: actions/checkout@v4
with:
path: sdk
ref: ${{ inputs.sdk_branch }}

- 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: 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: 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: Build Flex
if: "contains(matrix.repo_info.devices, 'flex')"
run: |
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }}
TARGET=flex BOLOS_SDK=$GITHUB_WORKSPACE/sdk make
build_all_applications:
name: Build all the C applications on all the devices
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build_several.yml@add/reusable_workflow_to_build_all_apps
with:
sdk: c
sdk_reference: ${{ inputs.sdk_branch }}
devices: all
exclude_apps: app-avalanche
Loading