From bdb79f6803147468a3a5d34e29f600eb9d633d97 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:00:55 +0100 Subject: [PATCH] ci: Replace Cirrus CI with GitHub Actions --- .cirrus.yml | 350 ---------------------- .github/actions/build-bitcoind/action.yml | 37 +++ .github/actions/install-sim/action.yml | 72 +++++ .github/workflows/ci.yml | 317 ++++++++++++++++++++ 4 files changed, 426 insertions(+), 350 deletions(-) delete mode 100644 .cirrus.yml create mode 100644 .github/actions/build-bitcoind/action.yml create mode 100644 .github/actions/install-sim/action.yml create mode 100644 .github/workflows/ci.yml diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index 4cf6126fd..000000000 --- a/.cirrus.yml +++ /dev/null @@ -1,350 +0,0 @@ -env: - EMAIL: cirrus@cirrus-ci.org - -python_version_matrix_template: &PYTHON_VERSION_MATRIX_TEMPLATE - - container: - dockerfile: ci/py37.Dockerfile - env: - PYTHON: 3.7 - - container: - dockerfile: ci/cirrus.Dockerfile - env: - PYTHON: 3.8 - - container: - dockerfile: ci/py39.Dockerfile - env: - PYTHON: 3.9 - - container: - dockerfile: ci/py310.Dockerfile - env: - PYTHON: 3.10 - - container: - dockerfile: ci/py311.Dockerfile - env: - PYTHON: 3.11 - -device_matrix_template: &DEVICE_MATRIX_TEMPLATE - - env: - DEVICE: --trezor-1 - depends_on: - - Trezor 1 Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Trezor 1 Sim Builder/sim/trezor-firmware.tar.gz" - - tar -xvf "trezor-firmware.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - - env: - DEVICE: --trezor-t - depends_on: - - Trezor T Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Trezor T Sim Builder/sim/trezor-firmware.tar.gz" - - tar -xvf "trezor-firmware.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - - env: - DEVICE: --coldcard - depends_on: - - Coldcard Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Coldcard Sim Builder/sim/coldcard-mpy.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - sim_install_script: - - pushd test/work; git clone --recursive https://github.com/Coldcard/firmware.git; popd - - tar -xvf "coldcard-mpy.tar.gz" - - pushd test/work/firmware; git am ../../data/coldcard-multisig.patch; popd - - poetry run pip install -r test/work/firmware/requirements.txt - - pip install -r test/work/firmware/requirements.txt - - env: - DEVICE: --bitbox01 - depends_on: - - Bitbox01 Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Bitbox01 Sim Builder/sim/mcu.tar.gz" - - tar -xvf "mcu.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - - env: - DEVICE: --jade - depends_on: - - Jade Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Jade Sim Builder/sim/jade.tar.gz" - - tar -xvf "jade.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - - env: - DEVICE: --ledger - depends_on: - - Ledger Sim Builder - - Ledger App Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Ledger Sim Builder/sim/speculos.tar.gz" - - tar -xvf "speculos.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - fetch_ledger_app_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Ledger App Builder/built_ledger_app/app-bitcoin-new/bin/app.elf" - - mv app.elf test/work/speculos/apps/btc-test.elf - sim_install_script: - - poetry run pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract - - pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract - - env: - DEVICE: --ledger-legacy - depends_on: - - Ledger Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Ledger Sim Builder/sim/speculos.tar.gz" - - tar -xvf "speculos.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - sim_install_script: - - poetry run pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract - - pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract - - env: - DEVICE: --keepkey - depends_on: - - Keepkey Sim Builder - - dist_builder - - bitcoind_builder - fetch_sim_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/Keepkey Sim Builder/sim/keepkey-firmware.tar.gz" - - tar -xvf "keepkey-firmware.tar.gz" - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/bitcoind_builder/bitcoin/bitcoin.tar.gz" - - tar -xvf "bitcoin.tar.gz" - -task: - container: - image: python:latest - install_script: - - pip install poetry - - poetry install - matrix: - - name: Type Check - type_check_script: > - 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 - - name: Non-Device Tests - test_script: cd test; poetry run ./run_tests.py; cd .. - - name: lint - test_script: poetry run flake8 - -wine_builder_task: - container: - dockerfile: contrib/build-wine.Dockerfile - build_script: - - contrib/build_wine.sh - - find dist -type f -exec sha256sum {} \; - -bitcoind_builder_task: - container: - dockerfile: ci/cirrus.Dockerfile - bitcoind_cache: - folder: test/work/bitcoin - ccache_cache: - folder: /root/.ccache - env: - BUILD_BITCOIND: 1 - build_script: - - cd test; ./setup_environment.sh --bitcoind; cd .. - - tar -czf bitcoin.tar.gz test/work/bitcoin - bitcoin_artifacts: - path: "bitcoin.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --trezor-1 - name: Trezor 1 Sim Builder - sim_work_cache: - folder: test/work/trezor-firmware - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf trezor-firmware.tar.gz test/work/trezor-firmware - sim_artifacts: - path: "trezor-firmware.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --trezor-t - name: Trezor T Sim Builder - sim_work_cache: - folder: test/work/trezor-firmware - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf trezor-firmware.tar.gz test/work/trezor-firmware - sim_artifacts: - path: "trezor-firmware.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --coldcard - name: Coldcard Sim Builder - sim_work_cache: - folder: test/work/firmware - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf coldcard-mpy.tar.gz 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 - sim_artifacts: - path: "coldcard-mpy.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --bitbox01 - name: Bitbox01 Sim Builder - sim_work_cache: - folder: test/work/mcu - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf mcu.tar.gz test/work/mcu - sim_artifacts: - path: "mcu.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --jade - name: Jade Sim Builder - sim_work_cache: - folder: test/work/jade - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf jade.tar.gz test/work/jade/simulator - sim_artifacts: - path: "jade.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --ledger - name: Ledger Sim Builder - sim_work_cache: - folder: test/work/speculos - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf speculos.tar.gz test/work/speculos - sim_artifacts: - path: "speculos.tar.gz" - -task: - container: - dockerfile: ci/cirrus.Dockerfile - env: - DEVICE: --keepkey - name: Keepkey Sim Builder - sim_work_cache: - folder: test/work/keepkey-firmware - build_script: - - cd test; ./setup_environment.sh $DEVICE; cd .. - - tar -czf keepkey-firmware.tar.gz test/work/keepkey-firmware/bin - sim_artifacts: - path: "keepkey-firmware.tar.gz" - - -dist_builder_task: - container: - dockerfile: contrib/build.Dockerfile - build_script: - - contrib/build_bin.sh - - contrib/build_dist.sh - - find dist -type f -exec sha256sum {} \; - built_dist_artifacts: - path: "dist/*" - -ledger_app_builder_task: - name: Ledger App Builder - container: - image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest - build_script: - - git clone https://github.com/LedgerHQ/app-bitcoin-new.git - - cd app-bitcoin-new - - make DEBUG=1 - built_ledger_app_artifacts: - path: app-bitcoin-new/bin/app.elf - -task: - matrix: - << : *PYTHON_VERSION_MATRIX_TEMPLATE - matrix: - << : *DEVICE_MATRIX_TEMPLATE - fetch_dist_script: - - wget -nv "https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/dist_builder/built_dist.zip" - - unzip built_dist.zip - matrix: - - name: Python $PYTHON $DEVICE Wheel - install_script: pip install dist/*.whl - test_script: cd test; ./run_tests.py $DEVICE --interface=cli --device-only; cd .. - - name: Python $PYTHON $DEVICE Sdist - install_script: pip install $(find dist -name "*.tar.gz" -a -not -name "*linux*") - test_script: cd test; ./run_tests.py $DEVICE --interface=cli --device-only; cd .. - - name: Python $PYTHON $DEVICE Bindist - install_script: poetry install - untar_bindist_script: cd dist; tar -xvf hwi*linux*.tar.gz; cd .. - test_script: cd test; poetry run ./run_tests.py $DEVICE --interface=bindist --device-only; cd .. - on_failure: - failed_script: tail -v -n +1 test/*.std* - -task: - matrix: - << : *PYTHON_VERSION_MATRIX_TEMPLATE - install_script: poetry install - matrix: - << : *DEVICE_MATRIX_TEMPLATE - matrix: - - env: - INTERFACE: library - - env: - INTERFACE: cli - - env: - INTERFACE: stdin - name: Python $PYTHON $DEVICE $INTERFACE - test_script: cd test; poetry run ./run_tests.py $DEVICE --interface=$INTERFACE --device-only; cd .. - on_failure: - failed_script: tail -v -n +1 test/*.std* diff --git a/.github/actions/build-bitcoind/action.yml b/.github/actions/build-bitcoind/action.yml new file mode 100644 index 000000000..49f9c724b --- /dev/null +++ b/.github/actions/build-bitcoind/action.yml @@ -0,0 +1,37 @@ +name: Build bitcoind +description: Build bitcoind with depends. +runs: + using: composite + steps: + - shell: bash + run: | + sudo apt-get update + sudo apt-get install -y ccache + echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV" + + - uses: actions/cache/restore@v3 + id: ccache-cache + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ github.job }}-ccache-${{ github.run_id }} + restore-keys: ${{ github.job }}-ccache- + + - shell: bash + env: + CCACHE_MAXSIZE: '20M' + run: | + ccache --zero-stats + cd test; ./setup_environment.sh --bitcoind; cd .. + ccache --show-stats --verbose + tar -czf bitcoind.tar.gz test/work/bitcoin/src/bitcoind + + - uses: actions/cache/save@v3 + if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ github.job }}-ccache-${{ github.run_id }} + + - uses: actions/upload-artifact@v3 + with: + name: bitcoind + path: bitcoind.tar.gz diff --git a/.github/actions/install-sim/action.yml b/.github/actions/install-sim/action.yml new file mode 100644 index 000000000..1a85e3590 --- /dev/null +++ b/.github/actions/install-sim/action.yml @@ -0,0 +1,72 @@ +name: Install Sim +description: Fetch and install simulator. +inputs: + device: + description: A tested device name + required: true +runs: + using: composite + steps: + - uses: actions/download-artifact@v3 + with: + name: ${{ inputs.device == 'ledger-legacy' && 'ledger' || inputs.device }}-sim + + - if: startsWith(inputs.device, 'trezor-') + shell: bash + run: | + apt-get update + apt-get install -y libsdl2-image-2.0-0 libusb-1.0-0 + tar -xvf trezor-firmware.tar.gz + + - if: inputs.device == 'coldcard' + shell: bash + run: | + apt-get update + apt-get install -y libpcsclite-dev libusb-1.0-0 swig + git config --global user.email "ci@ci.com" + git config --global user.name "ci" + pushd test/work; git clone --recursive https://github.com/Coldcard/firmware.git; popd + tar -xvf coldcard-mpy.tar.gz + pushd test/work/firmware; git am ../../data/coldcard-multisig.patch; popd + poetry run pip install -r test/work/firmware/requirements.txt + pip install -r test/work/firmware/requirements.txt + + - if: inputs.device == 'bitbox01' + shell: bash + run: | + apt-get update + apt-get install -y libusb-1.0-0 + tar -xvf mcu.tar.gz + + - if: inputs.device == 'jade' + shell: bash + run: | + apt-get update + apt-get install -y libgcrypt20 libsdl2-dev libslirp0 libusb-1.0-0 + tar -xvf jade.tar.gz + + - if: startsWith(inputs.device, 'ledger') + shell: bash + run: | + apt-get update + apt-get install -y libusb-1.0-0 qemu-user-static + tar -xvf speculos.tar.gz + poetry run pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract + pip install construct flask-restful jsonschema mnemonic pyelftools pillow requests pytesseract + + - if: inputs.device == 'ledger' + uses: actions/download-artifact@v3 + with: + name: ledger_app + + - if: inputs.device == 'ledger' + shell: bash + run: | + mv app.elf test/work/speculos/apps/btc-test.elf + + - if: inputs.device == 'keepkey' + shell: bash + run: | + apt-get update + apt-get install -y libusb-1.0-0 + tar -xvf keepkey-firmware.tar.gz diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..669dd0137 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,317 @@ +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@v3 + 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' } + + 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@v3 + 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@v3 + 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 + needs: [ dist-builder, sim-builder, ledger-app-builder, bitcoind-builder ] + + strategy: + fail-fast: false + matrix: + python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] + device: + - 'trezor-1' + - 'trezor-t' + - 'coldcard' + - 'bitbox01' + - 'jade' + - 'ledger' + - 'ledger-legacy' + - 'keepkey' + 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@v3 + with: + name: dist + path: dist/ + + - run: | + ${{ matrix.script.install }} + + - uses: actions/download-artifact@v3 + 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 + needs: [ sim-builder, ledger-app-builder, bitcoind-builder ] + + strategy: + fail-fast: false + matrix: + python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] + device: + - 'trezor-1' + - 'trezor-t' + - 'coldcard' + - 'bitbox01' + - 'jade' + - 'ledger' + - 'ledger-legacy' + - 'keepkey' + interface: [ 'library', 'cli', 'stdin' ] + + container: python:${{ matrix.python-version }} + + steps: + - uses: actions/checkout@v4 + + - run: | + pip install poetry + poetry install + + - uses: actions/download-artifact@v3 + 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*