restructure CI into build + smoketest pipeline (#6)

This commit is contained in:
Adeeb Shihadeh
2026-02-22 17:52:42 -08:00
committed by GitHub
parent f78b4d9e85
commit 453518f608
3 changed files with 73 additions and 32 deletions

View File

@@ -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/

View File

@@ -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)

18
smoketest.sh Executable file
View File

@@ -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-directory>}"
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