Skip to content

Commit

Permalink
Merge pull request #451 from LedgerHQ/clean/packaging
Browse files Browse the repository at this point in the history
Cleaning packaging / CI config
  • Loading branch information
lpascal-ledger authored Feb 8, 2024
2 parents 439a235 + dff2e59 commit b09b240
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 350 deletions.
52 changes: 44 additions & 8 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,71 @@ on:
- master

jobs:
coverage:
name: Code coverage
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build with code coverage instrumentation
env:
CTEST_OUTPUT_ON_FAILURE: 1
RNG_SEED: 0
run: |
cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 -DCODE_COVERAGE=ON
make -C build clean
make -C build
make -C build test
pip install pytest-cov
pip install .
PYTHONPATH=. pytest --cov=speculos --cov-report=xml
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
name: codecov-speculos

build:
name: Clone, build, test
runs-on: ubuntu-latest
permissions:
packages: write

strategy:
matrix:
python_version: ['3.8', '3.9', '3.10', '3.11']
# Use https://ghcr.io/ledgerhq/speculos-builder which has all the required
# dependencies
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build
- name: Setup Python version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}

- name: Build and install package
run: |
cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1
make -C build
pip install pytest
pip install .
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
make -C build/ test
python3 -m pytest
pytest
package_python:
name: Build and deploy Speculos Python Package
Expand All @@ -51,7 +87,7 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -113,7 +149,7 @@ jobs:
needs: [build]
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build and publish to GitHub Packages
Expand Down
40 changes: 7 additions & 33 deletions .github/workflows/fast-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python dependency
run: pip install flake8
run: pip install flake8 flake8-pyproject
- name: Lint Python code
run: find speculos/ -type f -name '*.py' -exec flake8 --max-line-length=120 '{}' '+'
run: flake8 speculos* setup.py

linter-c:
name: Linter on C code
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Lint C code
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: pip install mypy types-requests types-setuptools PyQt5-stubs
- name: Mypy type checking
run: mypy speculos
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: pip install bandit
- name: Bandit security checking
run: bandit -r speculos -ll || echo 0
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check misspellings
Expand All @@ -72,29 +72,3 @@ jobs:
check_filenames: true
ignore_words_file: .codespell-ignore
skip: ./speculos/api/static/swagger/swagger-ui.css,./speculos/api/static/swagger/swagger-ui-bundle.js,./speculos/api/static/swagger/swagger-ui-standalone-preset.js,./speculos/fonts

coverage:
name: Code coverage
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Rebuild with code coverage instrumentation
env:
CTEST_OUTPUT_ON_FAILURE: 1
RNG_SEED: 0
run: |
cmake -Bbuild -H. -DPRECOMPILED_DEPENDENCIES_DIR=/install -DWITH_VNC=1 -DCODE_COVERAGE=ON
make -C build clean
make -C build
make -C build test
python3 -m pip install pytest-cov
python3 -m pytest --cov=speculos --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: codecov-speculos
6 changes: 3 additions & 3 deletions .github/workflows/reusable_ragger_tests_latest_speculos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fail-fast: false
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.speculos_app_branch_name }}
submodules: recursive
Expand Down Expand Up @@ -71,15 +71,15 @@ jobs:
- device: stax
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ledgerHQ/speculos
ref: ${{ inputs.speculos_app_branch_name }}
submodules: recursive
fetch-depth: 0

- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ inputs.app_repository }}
ref: ${{ inputs.app_branch_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/speculos-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and push speculos-builder to GitHub Packages
uses: docker/build-push-action@v1
Expand Down
18 changes: 9 additions & 9 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ verify_ssl = true
[dev-packages]

[packages]
jsonschema = "*"
pyelftools = "*"
mnemonic = "*"
construct = "*"
flask="*"
flask-restful="*"
pillow="*"
requests = "*"
pytest = "*"
construct = ">=2.10.56,<3.0.0"
flask = ">=2.0.0,<3.0.0"
flask-restful = ">=0.3.9,<1.0"
jsonschema = ">=3.2.0,<4.18.0"
mnemonic = ">=0.19,<1.0"
pillow = ">=8.0.0,<11.0.0"
pyelftools = ">=0.27,<1.0"
pyqt5 = ">=5.15.2,<6.0.0"
requests = ">=2.25.1,<3.0.0"

[requires]
python_version = "3.9"
Loading

0 comments on commit b09b240

Please sign in to comment.