Skip to content

Commit c0abe38

Browse files
committed
Try to parallelize all builds
1 parent b33292d commit c0abe38

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

.github/workflows/build_all_apps.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616
outputs:
1717
rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }}
18+
exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }}
19+
ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }}
1820
steps:
1921
- name: Checkout repository
2022
uses: actions/checkout@v4
@@ -27,8 +29,10 @@ jobs:
2729
- name: Get all rust apps
2830
id: get_rust_apps
2931
run: |
30-
python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }} > rust_apps.txt
31-
echo "rust_apps=$(cat rust_apps.txt)" >> $GITHUB_OUTPUT
32+
python .github/workflows/get_rust_apps.py ${{ secrets.GH_TOKEN }}
33+
echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT
34+
echo "exclude_apps=$(cat exclude_apps.json)" >> $GITHUB_OUTPUT
35+
echo "ledger_devices=$(cat ledger_devices.json)" >> $GITHUB_OUTPUT
3236
3337
display-rust-apps:
3438
name: Display Rust Apps
@@ -38,6 +42,8 @@ jobs:
3842
- name: Display Rust Apps
3943
run: |
4044
echo "Rust apps: ${{ needs.retrieve-rust-apps.outputs.rust_apps }}"
45+
echo "Exclude apps: ${{ needs.retrieve-rust-apps.outputs.exclude_apps }}"
46+
echo "Ledger devices: ${{ needs.retrieve-rust-apps.outputs.ledger_devices }}"
4147
4248
test-build:
4349
name: Build for all targets
@@ -46,12 +52,8 @@ jobs:
4652
fail-fast: false
4753
matrix:
4854
app-name: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }}
49-
exclude:
50-
- app-name: "app-kadena-legacy"
51-
- app-name: "app-age"
52-
- app-name: "app-provenance"
53-
- app-name: "app-conflux"
54-
- app-name: "app-pocket"
55+
device: ${{ fromJSON(needs.retrieve-rust-apps.outputs.ledger_devices) }}
56+
exclude: ${{ fromJSON(needs.retrieve-rust-apps.outputs.exclude_apps) }}
5557
runs-on: ubuntu-latest
5658
container:
5759
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
@@ -106,13 +108,11 @@ jobs:
106108
run: |
107109
cd ${{ matrix.app-name }}
108110
build_directory=$(ledger-manifest --output-build-directory ledger_app.toml)
109-
devices="$(ledger-manifest --output-devices ledger_app.toml -j | sed 's/+/plus/' | jq -rc '.devices[]')"
110111
cd $build_directory
111112
# Required as patch has a different version from what is locked in Cargo.lock
112113
cargo +$RUST_NIGHTLY update include_gif
113114
cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys
114115
cargo +$RUST_NIGHTLY update ledger_device_sdk
115-
for device in $devices; do
116-
echo "Build for "$device
117-
cargo ledger build $device
118-
done
116+
device=$(echo ${{ matrix.device }} | sed 's/+/plus/')
117+
echo "Build for "$device
118+
cargo ledger build $device

.github/workflows/get_rust_apps.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
from ledgered.github import GitHubLedgerHQ, NoManifestException
22
from github.GithubException import GithubException
3+
34
import sys
5+
import json
46

57
if len(sys.argv) != 2:
68
print("Usage: get_rust_apps.py <github_token>")
79
sys.exit(1)
810

11+
ledger_devices = ["nanos+", "nanox", "stax", "flex"]
12+
filtered_apps = ["app-kadena-legacy", "app-pocket", "app-age", "app-provenance"]
13+
14+
# Retrieve all apps on LedgerHQ GitHub organization
915
token = sys.argv[1]
1016
gh = GitHubLedgerHQ(token)
1117
apps=gh.apps
1218

1319
rust_apps = []
20+
exclude_apps = []
1421
# loop all apps in gh.apps
1522
for app in apps:
1623
try:
@@ -20,9 +27,22 @@
2027
except GithubException as e:
2128
pass
2229
else:
30+
# Filter out apps that are Rust based
2331
if manifest.app.sdk == "rust":
24-
# store app_name in a list
25-
rust_apps.append(app.name)
32+
rust_apps.append(app.name)
33+
# filter out app for specific devices
34+
for d in ledger_devices:
35+
if d not in manifest.app.devices or app.name in filtered_apps:
36+
exclude_apps.append({"app-name": app.name, "device": d})
37+
38+
# save the list of Rust apps in a json format:
39+
with open("rust_apps.json", "w") as f:
40+
f.write(json.dumps(rust_apps))
41+
42+
# save the list of Excluded apps in a json format:
43+
with open("exclude_apps.json", "w") as f:
44+
f.write(json.dumps(exclude_apps))
2645

27-
# print the list of rust apps in between []
28-
print(rust_apps)
46+
# save the list of Ledger devices in a json format:
47+
with open("ledger_devices.json", "w") as f:
48+
f.write(json.dumps(ledger_devices))

0 commit comments

Comments
 (0)