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

API_LEVEL_LNS: Add CI #650

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
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
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Fix [Subject of the issue]'
labels: 'bug'
assignees: ''

---

## Description

Describe your issue in as much detail as possible here.

## Your environment

* OS and version
* branch that causes this issue
* Device (Nano S, Nano X, Nano S+)

## Steps to reproduce

* Tell us how to reproduce this issue <br />
* Where the issue is, if you know <br />
* Which commands triggered the issue, if any

## Expected behaviour

Tell us what should happen

## Actual behaviour

Tell us what happens instead

## Logs

Please paste any logs here that demonstrate the issue, if they exist

## Proposed solution

If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Feature report
about: Suggest an idea for this project
title: 'Add [Subject of the issue]'
labels: 'enhancement'
assignees: ''

---

## Description

Describe your issue in as much detail as possible here.

## Your environment

* OS and version
* branch that causes this issue
* Device (Nano S, Nano X, Nano S+)
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Description

Please provide a detailed description of what was done in this PR.
(And mention any links to an issue [docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue))

## Changes include

- [ ] Bugfix (non-breaking change that solves an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)
- [ ] Tests
- [ ] Documentation
- [ ] Other (for changes that might not fit in any category)

## Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it.

## Additional comments

Please post additional comments in this section if you have them, otherwise delete it.
115 changes: 115 additions & 0 deletions .github/workflows/build_all_apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build all apps on latest SDK

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

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
xchapron-ledger marked this conversation as resolved.
Show resolved Hide resolved

- 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')
result+=("$repo,$default_branch")
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@v3
with:
repository: LedgerHQ/${{ matrix.repo_info.repo_name }}
ref: ${{ matrix.repo_info.default_branch }}
submodules: true

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

- name: Build NanoS
if: "startsWith(matrix.repo_info.devices, 'nanos,')"
run: |
[ -n '${{ matrix.repo_info.build_directory }}' ] && cd ${{ matrix.repo_info.build_directory }}
TARGET=nanos BOLOS_SDK=$GITHUB_WORKSPACE/sdk make
45 changes: 45 additions & 0 deletions .github/workflows/check_clang_static_analyzer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run Clang Static Analyzer

on:
workflow_dispatch:
push:
branches:
- master
pull_request:

jobs:
scan_build:
name: Clang Static Analyzer for all devices
strategy:
fail-fast: false
matrix:
target: [nanos]
debug: [0, 1]
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest

steps:
- name: Clone Boilerplate
uses: actions/checkout@v3
xchapron-ledger marked this conversation as resolved.
Show resolved Hide resolved
with:
repository: LedgerHQ/app-boilerplate
ref: master

- name: Clone SDK
uses: actions/checkout@v3
with:
path: sdk

- name: Build with Clang Static Analyzer
run: |
TARGET=${{ matrix.target }} \
BOLOS_SDK=sdk \
make scan-build -j ENABLE_SDK_WERROR=1 DEBUG=${{ matrix.debug }}

- name: Upload scan result
uses: actions/upload-artifact@v3
if: failure()
with:
name: scan-build
path: scan-build
31 changes: 31 additions & 0 deletions .github/workflows/force-rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Force rebased

on: [pull_request]

jobs:
force-rebase:
runs-on: ubuntu-latest
steps:

- name: 'PR commits + 1'
id: pr_commits
run: echo "pr_fetch_depth=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_OUTPUT}"

- name: 'Checkout PR branch and all PR commits'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ steps.pr_commits.outputs.pr_fetch_depth }}

- name: Check if PR branch is rebased on target branch
shell: bash
run: |
git merge-base --is-ancestor ${{ github.event.pull_request.base.sha }} HEAD

- name: Check if PR branch contains merge commits
shell: bash
run: |
merges=$(git log --oneline HEAD~${{ github.event.pull_request.commits }}...HEAD --merges ); \
echo "--- Merges ---"; \
echo ${merges}; \
[[ -z "${merges}" ]]
13 changes: 13 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: pre-commit

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ exclude: |
lib_stusb/.*|
lib_nbgl/include/.*.json|
lib_bagl/include/.*.json|
lib_cxng/src/.*.c|
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.glyphs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ $(GLYPH_DESTH): $(GLYPH_FILES) $(ICON_SCRIPT)
$(L)if [ ! -z "$(GLYPH_FILES)" ] ; then python3 $(ICON_SCRIPT) --glyphcheader $(GLYPH_FILES) > $(GLYPH_DESTH) ; fi
$(L)if [ ! -z "$(GLYPH_FILES)" ] ; then python3 $(ICON_SCRIPT) --glyphcfile $(GLYPH_FILES) > $(GLYPH_DESTC) ; fi
#add dependency for generation
$(GLYPH_DESTC): $(GLYPH_DESTH)
$(GLYPH_DESTC): $(GLYPH_DESTH)
22 changes: 11 additions & 11 deletions icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
sys.stderr.write("Error: " + filename + " does not exists !\n")
sys.exit(2)
widthmax = int(sys.argv[1])
heightmax = int(sys.argv[2])
heightmax = int(sys.argv[2])
else:
forcedBPP = int(sys.argv[2])
if (sys.argv[3] == "hexbitmaponly"):
Expand All @@ -90,7 +90,7 @@
sys.stderr.write("Error: " + filename + " does not exists !\n")
sys.exit(2)
widthmax = int(sys.argv[1])
heightmax = int(sys.argv[2])
heightmax = int(sys.argv[2])

if (sys.argv[4] == "hexbitmaponly"):
hexbitmaponly = True
Expand All @@ -109,7 +109,7 @@
sys.stderr.write("Error: " + filename + " does not exists !\n")
sys.exit(2)
widthmax = int(sys.argv[1])
heightmax = int(sys.argv[2])
heightmax = int(sys.argv[2])
forcedBPP = int(sys.argv[4])
if (sys.argv[5] == "hexbitmaponly"):
hexbitmaponly = True
Expand Down Expand Up @@ -185,7 +185,7 @@ def hexbyte(b):
i = 0
palette_remapping = {}
new_palette = []
for lum, values in opalette.items():
for lum, values in opalette.items():
# old index to new index
for v in values:
palette_remapping[v[0]] = i
Expand Down Expand Up @@ -221,7 +221,7 @@ def hexbyte(b):
""")
if glyphcheader:
sys.stdout.write("""extern
""")
""")
sys.stdout.write("""unsigned int const C_""" + bname + """_colors[]
""");
if glyphcheader:
Expand All @@ -237,8 +237,8 @@ def hexbyte(b):
sys.stdout.write("""};
""")
if glyphcheader:
sys.stdout.write("""extern""")
sys.stdout.write("""
sys.stdout.write("""extern""")
sys.stdout.write("""
unsigned char const C_""" + bname + """_bitmap[]""");
if glyphcheader:
sys.stdout.write(""";
Expand Down Expand Up @@ -291,7 +291,7 @@ def hexbyte(b):
sys.stdout.write(hexbyte(current_byte))
current_bit = 0
current_byte = 0

# print last byte if any
if (current_bit > 0):
if not hexbitmaponly:
Expand All @@ -317,13 +317,13 @@ def hexbyte(b):
else:
sys.stdout.write("""#ifdef OS_IO_SEPROXYHAL
#include \"os_io_seproxyhal.h\"
""")
""")
if glyphcheader:
sys.stdout.write("""extern
""")
""")
sys.stdout.write("""const bagl_icon_details_t C_""" + bname)

if glyphcheader:
if glyphcheader:
sys.stdout.write(""";
""")
sys.stdout.write("""#endif // GLYPH_""" + bname + """_BPP
Expand Down
Loading
Loading