-
Notifications
You must be signed in to change notification settings - Fork 12
142 lines (120 loc) · 4.81 KB
/
build_all_apps.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build all apps on latest SDK
on:
workflow_dispatch:
inputs:
sdk_branch:
type: string
required: false
default: ''
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