Skip to content

Restore Native backend CI and purge obsolete Actions history #606

Restore Native backend CI and purge obsolete Actions history

Restore Native backend CI and purge obsolete Actions history #606

name: Native backend CI
on:
pull_request:
push:
permissions:
contents: read
actions: write
jobs:
cleanup-obsolete-workflows:
name: Purge obsolete Actions history
if: github.event_name == 'push' && github.event.head_commit.message == 'Restore Native backend CI and purge obsolete Actions history'
runs-on: ubuntu-latest
steps:
- name: Delete obsolete workflow runs
shell: bash
env:
GH_TOKEN: ${{ github.token }}
CURRENT_RUN_ID: ${{ github.run_id }}
run: |
set -euo pipefail
keep_path() {
case "$1" in
".github/workflows/native-backend-ci.yml"|\
".github/workflows/inspect-r-api-update.yml"|\
".github/workflows/docs.yml"|\
".github/workflows/release.yml") return 0 ;;
*) return 1 ;;
esac
}
gh api --paginate \
-H "Accept: application/vnd.github+json" \
"/repos/${GITHUB_REPOSITORY}/actions/runs?per_page=100" \
--jq '.workflow_runs[] | [.id, .path] | @tsv' > workflow-runs.tsv
deleted=0
while IFS=$'\t' read -r run_id workflow_path; do
[ -n "${run_id}" ] || continue
[ "${run_id}" != "${CURRENT_RUN_ID}" ] || continue
if ! keep_path "${workflow_path}"; then
echo "Deleting run ${run_id} from ${workflow_path}"
gh api --method DELETE "/repos/${GITHUB_REPOSITORY}/actions/runs/${run_id}"
deleted=$((deleted + 1))
fi
done < workflow-runs.tsv
echo "Deleted ${deleted} obsolete workflow runs."
native-backend:
name: Python ${{ matrix.python-version }}
if: github.event.head_commit.message != 'Restore Native backend CI and purge obsolete Actions history'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install build tools
run: |
python -m pip install -U pip
python -m pip install build scikit-build-core nanobind pytest ruff mypy "numpy<2.5" scipy
python -m pip install hypothesis pytest-benchmark pytest-xdist
- name: Install package editable
run: python -m pip install -e .
- name: Run native import smoke test
run: python -c "import nns._nnscore as c; print(c.lpm(2.0, 0.0, [-2.0, -1.0, 0.5, 3.0]))"
- name: Run invariants without Rscript
run: python -m pytest -q tests/invariants
- name: Run parity from committed R cache
run: NNS_R_CACHE_ONLY=1 python -m pytest -q tests/parity
- name: Run property tests
run: python -m pytest -q tests/property
- name: Run plotting color-fidelity tests
run: python -m pytest -q tests/plotting
- name: Run vignette examples
run: |
if [ -f tests/docs/test_vignette_examples.py ]; then
python -m pytest -q tests/docs/test_vignette_examples.py
else
echo "No docs vignette test present; skipping."
fi
- name: Run ruff
run: ruff check .
- name: Run mypy
run: mypy
- name: Build distributions
run: python -m build