Skip to content

Commit

Permalink
[draft] Fetching & compiling all apps on all devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lpascal-ledger committed Jan 15, 2025
1 parent e411418 commit 754905f
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Build apps on given SDK ref

on:
schedule:
- cron: '32 5 * * 1,2,3,4,5'
# schedule:
# - cron: '32 5 * * 1,2,3,4,5'

pull_request:
# pull_request:

workflow_dispatch:
inputs:
Expand Down
113 changes: 113 additions & 0 deletions .github/workflows/build_for_sdks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: APP-TESTER TESTS

on:
workflow_dispatch:
push:
pull_request:

jobs:

define_matrix:
runs-on: ubuntu-latest
outputs:
app_url_by_device: ${{ steps.process_devices.outputs.app_url_by_device }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pip install ledgered
- name: Define the list of application to build by device
id: process_devices
run: |
devices=$(python script.py -d all -t ${{ secrets.GITHUB_TOKEN }})
echo "app_url_by_device=$devices" >> $GITHUB_OUTPUT
run_builds_nanos:
runs-on: ubuntu-latest
needs: define_matrix
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
fail-fast: false
matrix:
app_name: ${{ fromJSON(needs.define_matrix.outputs.app_url_by_device)['nanos'] }}
steps:
- uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app_name }}
- name: Build the app
run: |
make BOLOS_SDK=$NANOS_SDK
run_builds_nanos_plus:
runs-on: ubuntu-latest
needs: define_matrix
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
fail-fast: false
matrix:
app_name: ${{ fromJSON(needs.define_matrix.outputs.app_url_by_device)['nanos+'] }}
steps:
- uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app_name }}
- name: Build the app
run: |
make BOLOS_SDK=$NANOSP_SDK
run_builds_nanox:
runs-on: ubuntu-latest
needs: define_matrix
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
fail-fast: false
matrix:
app_name: ${{ fromJSON(needs.define_matrix.outputs.app_url_by_device)['nanox'] }}
steps:
- uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app_name }}
- name: Build the app
run: |
make BOLOS_SDK=$NANOX_SDK
run_builds_flex:
runs-on: ubuntu-latest
needs: define_matrix
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
fail-fast: false
matrix:
app_name: ${{ fromJSON(needs.define_matrix.outputs.app_url_by_device)['flex'] }}
steps:
- uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app_name }}
- name: Build the app
run: |
make BOLOS_SDK=$FLEX_SDK
run_builds_staxx:
runs-on: ubuntu-latest
needs: define_matrix
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
strategy:
fail-fast: false
matrix:
app_name: ${{ fromJSON(needs.define_matrix.outputs.app_url_by_device)['stax'] }}
steps:
- uses: actions/checkout@v4
with:
repository: LedgerHQ/${{ matrix.app_name }}
- name: Build the app
run: |
make BOLOS_SDK=$STAX_SDK
6 changes: 3 additions & 3 deletions .github/workflows/refresh_inputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ on:
type: boolean
required: false
default: false
schedule:
- cron: '32 5 * * 3'
pull_request:
# schedule:
# - cron: '32 5 * * 3'
# pull_request:


jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scan_all.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Scan apps on given SDK ref

on:
schedule:
- cron: '32 5 * * 1,2,3,4,5'
# schedule:
# - cron: '32 5 * * 1,2,3,4,5'

pull_request:
# pull_request:

workflow_dispatch:
inputs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_all.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Test apps on given SDK ref

on:
schedule:
- cron: '32 5 * * 1'
# schedule:
# - cron: '32 5 * * 1'

pull_request:
# pull_request:

workflow_dispatch:
inputs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*~

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
69 changes: 69 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import logging
from argparse import ArgumentParser
from collections import defaultdict
from ledgered.github import Condition, GitHubLedgerHQ, GitHubApps, NoManifestException

LOGGER_FORMAT = "[%(asctime)s][%(levelname)s] %(name)s - %(message)s"
logging.root.handlers.clear()
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(LOGGER_FORMAT))
logging.root.addHandler(handler)
logging.root.setLevel(logging.INFO)

devices = ["nanos", "nanos+", "nanox", "flex", "stax"]


def arg_parse():
parser = ArgumentParser()
parser.add_argument("-d", "--devices", nargs="+", required=True,
help="Devices to filter on. Accepts several successive values (seperated with space). "
"Valid values are 'nanos', 'nanosp', 'nanos+', 'nanox', 'stax', 'flex', 'all'.")
parser.add_argument("-t", "--github_token", required=False, default="", type=str,
help="A GitHub token to avoid GH API limitation")

args = parser.parse_args()

selected_devices = list()
for d in args.devices:
if d.lower() == "nanosp":
d = "nanos+"
if d.lower() in devices:
selected_devices.append(d)
continue
if d.lower() == "all":
selected_devices = devices
break
logging.warning(f"Unkown device target '{d}'. Ignoring.")
args.devices = selected_devices

return args


def main():
args = arg_parse()

selected_devices = set(args.devices)

logging.info("Fetching application repositories from GitHub")
if args.github_token:
gh = GitHubLedgerHQ(args.github_token)
else:
gh = GitHubLedgerHQ()
apps = gh.apps.filter(archived=Condition.WITHOUT, private=Condition.WITHOUT)

selected_apps = defaultdict(list)
for app in apps:
logging.info(f"Managing app '{app.name}'")
try:
compatible_devices = set(app.manifest.app.devices)
except NoManifestException:
logging.warning(f"Application '{app.name}' has no manifest! Ignoring.")

for device in selected_devices.intersection(compatible_devices):
selected_apps[device].append(app.name)

print(dict(selected_apps))


if __name__ == "__main__":
main()

0 comments on commit 754905f

Please sign in to comment.