-
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.
[draft] Fetching & compiling all apps on all devices
- Loading branch information
1 parent
e411418
commit 754905f
Showing
7 changed files
with
195 additions
and
12 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
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 |
---|---|---|
@@ -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 |
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
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
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
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
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 |
---|---|---|
@@ -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() |