diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f45449..c2581fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: ./test.sh +name: ci on: push: @@ -6,20 +6,45 @@ on: pull_request: jobs: - test: - name: ${{ matrix.image || matrix.os }} + build: + name: build (${{ matrix.platform }}) runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: include: - # native (no docker) - - os: macos-latest + - platform: macos runs-on: macos-latest + - platform: linux-x86_64 + runs-on: ubuntu-latest + - platform: linux-arm64 + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 + with: + python-version: "3.14" + - name: Build wheels + run: | + for pkg in */pyproject.toml; do + pip wheel "./$(dirname "$pkg")" --no-deps --wheel-dir dist/ + done + - name: Smoketest locally + run: bash smoketest.sh dist/ + - uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.platform }} + path: dist/*.whl - # the provided github actions runner images - # have tons of pre-installed packages. the - # goal here is to test across many vanilla setups + test: + name: test (${{ matrix.image }}) + needs: build + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + include: + # test on vanilla linux images - image: debian:bookworm-slim runs-on: ubuntu-latest - image: ubuntu:24.04 @@ -28,8 +53,9 @@ jobs: runs-on: ubuntu-latest - image: archlinux:latest runs-on: ubuntu-latest - - image: alpine:3.21 # musl libc - runs-on: ubuntu-latest + # TODO: make musl work + #- image: alpine:3.21 + # runs-on: ubuntu-latest - image: opensuse/tumbleweed:latest runs-on: ubuntu-latest - image: ghcr.io/void-linux/void-glibc:latest @@ -38,36 +64,27 @@ jobs: runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v6 - - # native (macOS) - - if: ${{ !matrix.image }} - uses: actions/setup-python@v6 + - uses: actions/download-artifact@v4 with: - python-version: "3.14" - - if: ${{ !matrix.image }} - name: ./test.sh - run: ./test.sh - - # docker (vanilla Linux) - - if: ${{ matrix.image }} - name: install python3 + name: wheels-${{ contains(matrix.runs-on, 'arm') && 'linux-arm64' || 'linux-x86_64' }} + path: wheels + - name: build docker run: | - docker build -t test -f - . <<'DOCKERFILE' + docker build -t smoketest -f - . <<'DOCKERFILE' FROM ${{ matrix.image }} RUN if command -v apk >/dev/null; then \ - apk add --no-cache python3 py3-pip bash curl; \ + apk add --no-cache python3 py3-pip bash; \ elif command -v apt-get >/dev/null; then \ - apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-venv curl ca-certificates; \ + apt-get update && apt-get install -y --no-install-recommends python3 python3-pip python3-venv; \ elif command -v dnf >/dev/null; then \ - dnf install -y python3 python3-pip curl; \ + dnf install -y python3 python3-pip; \ elif command -v pacman >/dev/null; then \ - pacman -Sy --noconfirm python python-pip curl; \ + pacman -Sy --noconfirm python python-pip; \ elif command -v zypper >/dev/null; then \ - zypper install -y python3 python3-pip curl; \ + zypper install -y python3 python3-pip; \ elif command -v xbps-install >/dev/null; then \ - xbps-install -Sy python3 python3-pip bash curl; \ + xbps-install -Sy python3 python3-pip bash; \ fi DOCKERFILE - - if: ${{ matrix.image }} - name: ./test.sh - run: docker run --rm -v "$PWD:/work" -w /work test bash ./test.sh + - name: ./smoketest.sh + run: docker run --rm -v "$PWD:/work" -w /work smoketest bash smoketest.sh wheels/ diff --git a/gcc-arm-none-eabi/gcc_arm_none_eabi/__init__.py b/gcc-arm-none-eabi/gcc_arm_none_eabi/__init__.py index 08a237d..c4626bc 100644 --- a/gcc-arm-none-eabi/gcc_arm_none_eabi/__init__.py +++ b/gcc-arm-none-eabi/gcc_arm_none_eabi/__init__.py @@ -19,3 +19,9 @@ def _run_objcopy(): def _run_size(): _run("arm-none-eabi-size") + + +def smoketest(): + import subprocess + gcc = os.path.join(TOOLCHAIN_DIR, "bin", "arm-none-eabi-gcc") + subprocess.run([gcc, "--version"], check=True) diff --git a/smoketest.sh b/smoketest.sh new file mode 100755 index 0000000..f209927 --- /dev/null +++ b/smoketest.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +WHEEL_DIR="${1:?Usage: smoketest.sh }" +WHEEL_DIR="$(cd "$WHEEL_DIR" && pwd)" + +VENV_DIR="$(mktemp -d)" +trap 'rm -rf "$VENV_DIR"' EXIT +python3 -m venv "$VENV_DIR" +source "$VENV_DIR/bin/activate" +pip install --upgrade pip >/dev/null +pip install "$WHEEL_DIR"/*.whl + +for toml in "$REPO_DIR"/*/pyproject.toml; do + module="$(basename "$(dirname "$toml")" | tr '-' '_')" + python3 -c "import $module; $module.smoketest()" && echo "$module: OK" +done