Skip to content

Commit

Permalink
Merge pull request #353 from LedgerHQ/improve-ci
Browse files Browse the repository at this point in the history
Test boilerplate in CI
  • Loading branch information
sgliner-ledger authored Mar 2, 2023
2 parents 87c534b + a3b884e commit 663e915
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 22 deletions.
28 changes: 6 additions & 22 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,12 @@ jobs:

package_and_test_docker:
name: Build and test the Speculos docker
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
steps:
- name: Clone
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build the Speculos docker
uses: docker/build-push-action@v1
with:
push: false
tags: test
- name: Run and test Speculos docker
uses: addnab/docker-run-action@v3
with:
image: ledgerhq/speculos:test
options: -v ${{ github.workspace }}/apps/:/apps/
run: |
apt-get update && apt-get install -qy netcat
/speculos/speculos.py /apps/btc.elf --model nanos --display=headless --apdu-port 9999 &
until `nc -w5 -z -v 127.0.0.1 9999`; do sleep 1; done;
uses: ./.github/workflows/reusable_ragger_tests_latest_speculos.yml
with:
app_repository: LedgerHQ/app-boilerplate
app_branch_name: master
test_dir: tests
speculos_app_branch_name: ${{ github.ref }}

deploy_docker:
name: Build and Upload the Speculos docker
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/reusable_ragger_tests_latest_speculos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Functional tests using Ragger and latest speculos

on:
workflow_call:
inputs:
app_repository:
required: false
default: ${{ github.repository }}
type: string
app_branch_name:
required: false
default: ${{ github.ref }}
type: string
test_dir:
required: true
type: string
speculos_app_branch_name:
required: false
default: develop
type: string

jobs:
build_application:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
app_repository: ${{ inputs.app_repository }}
app_branch_name: ${{ inputs.app_branch_name }}
upload_app_binaries_artifact: "compiled_app_binaries"

ragger_tests:
name: Functional tests with Ragger
runs-on: ubuntu-latest
container:
image: docker://ghcr.io/ledgerhq/speculos-builder:latest
strategy:
fail-fast: false
matrix:
include:
- device: nanos
- device: nanox
- device: nanosp
- device: stax
steps:
- name: Clone
uses: actions/checkout@v3
with:
repository: ledgerHQ/speculos
ref: ${{ inputs.speculos_app_branch_name }}
submodules: recursive
fetch-depth: 0

- name: Build the Speculos docker
uses: docker/build-push-action@v1
with:
push: false
tags: test

- name: Clone
uses: actions/checkout@v3
with:
repository: ${{ inputs.app_repository }}
ref: ${{ inputs.app_branch_name }}
path: app
submodules: recursive
fetch-depth: 0

- name: Download app binaries
uses: actions/download-artifact@v3
with:
name: "compiled_app_binaries"
path: ${{ github.workspace }}/app/build

- name: Run and test Speculos docker
uses: addnab/docker-run-action@v3
with:
image: ledgerhq/speculos:test
options: -v ${{ github.workspace }}/app:/app
run: |
apt-get update && apt-get install -y gcc
pip install --extra-index-url https://test.pypi.org/simple/ -r /app/${{ inputs.test_dir }}/requirements.txt
pytest /app/${{ inputs.test_dir }}/ --tb=short -v --device ${{ matrix.device }}

0 comments on commit 663e915

Please sign in to comment.