Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/actions/build-bitcoind/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runs:
ccache --zero-stats
cd test; ./setup_environment.sh --bitcoind; cd ..
ccache --show-stats --verbose
tar -czf bitcoind.tar.gz test/work/bitcoin/build/src/bitcoind
tar -czf bitcoind.tar.gz test/work/bitcoin/build/bin/bitcoind

- uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
Expand Down
28 changes: 28 additions & 0 deletions .github/actions/build-sim/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build sim
description: Build device simulator(s)
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libsdl2-image-dev libslirp-dev libpcsclite-dev ninja-build
pip install poetry
wget https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-x86_64.zip
sudo unzip protoc-22.0-linux-x86_64.zip -d /usr/local
protoc --version

- name: Build simulator
shell: bash
run: |
git config --global user.email "ci@ci.com"
git config --global user.name "ci"
cd test; ./setup_environment.sh --${{ matrix.device.name }}; cd ..
tar -czf ${{ matrix.device.archive }}.tar.gz ${{ matrix.device.paths }}

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.device.name }}-sim
path: ${{ matrix.device.archive }}.tar.gz

31 changes: 31 additions & 0 deletions .github/actions/test-device/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test device
description: Run tests for one device type.
runs:
using: composite
steps:
- shell: bash
run: |
pip install poetry
poetry install

- uses: actions/download-artifact@v4
with:
name: bitcoind

- shell: bash
run: |
tar -xvf bitcoind.tar.gz

- uses: ./.github/actions/install-sim
with:
device: ${{ matrix.device }}

- name: Run tests
shell: bash
run: |
cd test; poetry run ./run_tests.py --${{ matrix.device }} --interface=${{ matrix.interface }} --device-only; cd ..

- if: failure()
shell: bash
run: |
tail -v -n +1 test/*.std*
323 changes: 0 additions & 323 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,323 +0,0 @@
name: CI
on:
pull_request:
push:
branches: ['**']
tags-ignore: ['**']

concurrency:
group: ${{ github.event_name != 'pull_request' && github.run_id || github.ref }}
cancel-in-progress: true

env:
LC_ALL: 'C.UTF-8'
LANG: 'C.UTF-8'
LANGUAGE: 'C.UTF-8'

jobs:
type-check:
name: Type check
runs-on: ubuntu-latest
container: python:latest
steps:
- uses: actions/checkout@v4

- run: |
pip install poetry
poetry install

- name: Run check
run: >
poetry run
mypy
hwi.py
hwilib/_base58.py
hwilib/_bech32.py
hwilib/_cli.py
hwilib/commands.py
hwilib/common.py
hwilib/descriptor.py
hwilib/devices/bitbox02.py
hwilib/devices/coldcard.py
hwilib/devices/digitalbitbox.py
hwilib/devices/jade.py
hwilib/devices/__init__.py
hwilib/devices/keepkey.py
hwilib/devices/ledger.py
hwilib/devices/trezor.py
hwilib/errors.py
hwilib/_script.py
hwilib/_serialize.py
hwilib/tx.py
hwilib/hwwclient.py
hwilib/__init__.py
hwilib/key.py
hwilib/udevinstaller.py

non-device-tests:
name: Non-device tests
runs-on: ubuntu-latest
container: python:latest
steps:
- uses: actions/checkout@v4

- run: |
pip install poetry
poetry install

- name: Run tests
run: |
cd test; poetry run ./run_tests.py; cd ..

lint:
name: lint
runs-on: ubuntu-latest
container: python:latest
steps:
- uses: actions/checkout@v4

- run: |
pip install poetry
poetry install

- run: |
poetry run flake8


wine-builder:
name: Wine builder
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: docker/build-push-action@v5
with:
context: .
file: contrib/build-wine.Dockerfile
tags: build-wine-container
load: true

- run: >
docker run --rm \
--volume ${{ github.workspace }}:${{ github.workspace }} \
--workdir ${{ github.workspace }} \
build-wine-container bash -c "
git config --global --add safe.directory ${{ github.workspace }}
contrib/build_wine.sh
find dist -type f -exec sha256sum {} \;
"

dist-builder:
name: Dist builder
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: docker/build-push-action@v5
with:
context: .
file: contrib/build.Dockerfile
tags: build-container
load: true

- run: >
docker run --rm \
--volume ${{ github.workspace }}:${{ github.workspace }} \
--workdir ${{ github.workspace }} \
build-container bash -c "
git config --global --add safe.directory ${{ github.workspace }}
contrib/build_bin.sh
contrib/build_dist.sh
find dist -type f -exec sha256sum {} \;
"

- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

sim-builder:
name: Sim builder
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
device:
- { name: 'trezor-1', archive: 'trezor-firmware', paths: 'test/work/trezor-firmware' }
- { name: 'trezor-t', archive: 'trezor-firmware', paths: 'test/work/trezor-firmware' }
- { name: 'coldcard', archive: 'coldcard-mpy', paths: 'test/work/firmware/external/micropython/ports/unix/coldcard-mpy test/work/firmware/unix/coldcard-mpy test/work/firmware/unix/l-mpy test/work/firmware/unix/l-port' }
- { name: 'bitbox01', archive: 'mcu', paths: 'test/work/mcu' }
- { name: 'jade', archive: 'jade', paths: 'test/work/jade/simulator' }
- { name: 'ledger', archive: 'speculos', paths: 'test/work/speculos' }
- { name: 'keepkey', archive: 'keepkey-firmware', paths: 'test/work/keepkey-firmware/bin' }
- { name: 'bitbox02', archive: 'bitbox02', paths: 'test/work/bitbox02-firmware/build-build/bin/simulator' }

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf libsdl2-image-dev libslirp-dev libpcsclite-dev ninja-build
pip install poetry
wget https://github.com/protocolbuffers/protobuf/releases/download/v22.0/protoc-22.0-linux-x86_64.zip
sudo unzip protoc-22.0-linux-x86_64.zip -d /usr/local
protoc --version

- name: Build simulator
run: |
git config --global user.email "ci@ci.com"
git config --global user.name "ci"
cd test; ./setup_environment.sh --${{ matrix.device.name }}; cd ..
tar -czf ${{ matrix.device.archive }}.tar.gz ${{ matrix.device.paths }}

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.device.name }}-sim
path: ${{ matrix.device.archive }}.tar.gz

ledger-app-builder:
name: Ledger App builder
runs-on: ubuntu-latest
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- run: |
git clone https://github.com/LedgerHQ/app-bitcoin-new.git
cd app-bitcoin-new
make DEBUG=1

- uses: actions/upload-artifact@v4
with:
name: ledger_app
path: app-bitcoin-new/bin/app.elf

bitcoind-builder:
name: bitcoind builder
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-bitcoind

test-dist:
name: Python ${{ matrix.python-version }} ${{ matrix.device }} ${{ matrix.script.name }}
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [ dist-builder, sim-builder, ledger-app-builder, bitcoind-builder ]

strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
device:
- 'trezor-1'
- 'trezor-t'
- 'coldcard'
- 'bitbox01'
- 'jade'
- 'ledger'
- 'ledger-legacy'
- 'keepkey'
- 'bitbox02'
script:
- name: 'Wheel'
install: 'pip install dist/*.whl'
test: 'cd test; ./run_tests.py $DEVICE --interface=cli --device-only; cd ..'
- name: 'Sdist'
install: 'pip install $(find dist -name "*.tar.gz" -a -not -name "*linux*")'
test: 'cd test; ./run_tests.py $DEVICE --interface=cli --device-only; cd ..'
- name: 'Bindist'
install: 'poetry install; cd dist; tar -xvf hwi*linux*.tar.gz; cd ..'
test: 'cd test; poetry run ./run_tests.py $DEVICE --interface=bindist --device-only; cd ..'

env:
DEVICE: '--${{ matrix.device }}'

container: python:${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4

- run: |
pip install poetry

- uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- run: |
${{ matrix.script.install }}

- uses: actions/download-artifact@v4
with:
name: bitcoind

- run: |
tar -xvf bitcoind.tar.gz

- uses: ./.github/actions/install-sim
with:
device: ${{ matrix.device }}

- name: Run tests
run: |
${{ matrix.script.test }}

- if: failure()
run: |
tail -v -n +1 test/*.std*


test-all:
name: Python ${{ matrix.python-version }} ${{ matrix.device }} ${{ matrix.interface }}
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [ sim-builder, ledger-app-builder, bitcoind-builder ]
timeout-minutes: 45

strategy:
fail-fast: false
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
device:
- 'trezor-1'
- 'trezor-t'
- 'coldcard'
- 'bitbox01'
- 'jade'
- 'ledger'
- 'ledger-legacy'
- 'keepkey'
- 'bitbox02'
interface: [ 'library', 'cli', 'stdin' ]

container: python:${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4

- run: |
pip install poetry
poetry install

- uses: actions/download-artifact@v4
with:
name: bitcoind

- run: |
tar -xvf bitcoind.tar.gz

- uses: ./.github/actions/install-sim
with:
device: ${{ matrix.device }}

- name: Run tests
run: |
cd test; poetry run ./run_tests.py --${{ matrix.device }} --interface=${{ matrix.interface }} --device-only; cd ..

- if: failure()
run: |
tail -v -n +1 test/*.std*
Loading