diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcc2c0f2..0abfaaf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,6 +61,17 @@ jobs: - name: Tests run: pytest + micropython: + name: Tests (MicroPython 1.11) + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v6 + + - name: Build MicroPython and run tests + run: tools/micropython_tests.sh + package: name: Build and verify artifacts runs-on: ubuntu-latest @@ -68,6 +79,7 @@ jobs: - actionlint - action-pin-policy - tests + - micropython permissions: contents: read steps: diff --git a/README.md b/README.md index e9811121..4811e30a 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,13 @@ Run tests with desktop python: pytest ``` -Run tests with micropython: +Run tests with micropython (builds MicroPython 1.11 with the `hashlib` and `secp256k1` modules on first run, needs `git`, `make`, `python3` and a C compiler): + +```sh +tools/micropython_tests.sh +``` + +With your own build: ```sh cd tests diff --git a/tools/micropython_tests.sh b/tools/micropython_tests.sh new file mode 100755 index 00000000..4c0d1717 --- /dev/null +++ b/tools/micropython_tests.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# Build the MicroPython 1.11 unix port with the hashlib and secp256k1 usermods +# embit needs, then run tests/run_tests.py on it. +# 1.11 is the oldest core embit runs on in the wild (Krux devices). +# +# The build is kept in $MP_BUILD_DIR and reused until one of the pins changes. +set -euo pipefail + +MICROPYTHON_SHA=6f75c4f3cd393131579db70cdf0b35d1fe5b95ab # v1.11 +F469_DISCO_SHA=989654e7bbffa255384c052fc5e4f387a2d8862a # usermods/uhashlib +SECP256K1_EMBEDDED_SHA=036f4656335fcbce978d38a7d1ea369c6d39d051 +SECP256K1_SHA=be8d9c262f46309d9b4165b0498b71d704aba8fe # submodule of secp256k1-embedded + +REPO="$(cd "$(dirname "$0")/.." && pwd)" +WORK="${MP_BUILD_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/embit-micropython-1.11}" +MP="$WORK/micropython/ports/unix/micropython" +PINS="$MICROPYTHON_SHA $F469_DISCO_SHA $SECP256K1_EMBEDDED_SHA $SECP256K1_SHA" + +fetch() { #