Skip to content

BustAPI CI

BustAPI CI #6

Workflow file for this run

name: BustAPI CI
on:
push:
tags:
- "v*"
workflow_dispatch: {}
jobs:
lint-and-test:
name: Lint and Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Create venv
run: |
uv venv .venv
echo "VENV_PY=./.venv/bin/python" >> $GITHUB_ENV
- name: Install tools
run: |
uv pip install maturin black ruff requests pytest sqlmodel>=0.0.16 --python $VENV_PY
- name: Lint Rust code
if: matrix.python-version == '3.12'
run: |
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
- name: Lint Python code
if: matrix.python-version == '3.12'
run: |
$VENV_PY -m black --check --diff .
$VENV_PY -m ruff check .
- name: Build with maturin
run: |
$VENV_PY -m maturin develop --release
$VENV_PY -c "import bustapi; print(f'BustAPI {bustapi.__version__} installed')"
- name: Run basic tests
run: |
$VENV_PY -m pytest tests
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v3
- name: Set up Python
run: uv python install 3.12
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Create venv and install maturin
run: |
uv venv .venv
uv pip install maturin --python ./.venv/bin/python
- name: Build sdist
run: ./.venv/bin/python -m maturin sdist --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: lint-and-test
strategy:
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
args: --release --out dist --find-interpreter
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
args: --release --out dist --find-interpreter
# Linux ARM64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
args: --release --out dist --find-interpreter --no-default-features
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
args: --release --out dist --find-interpreter --no-default-features
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
args: --release --out dist --find-interpreter
# MacOS
- os: macos-latest
target: x86_64-apple-darwin
args: --release --out dist --find-interpreter
- os: macos-latest
target: aarch64-apple-darwin
args: --release --out dist --find-interpreter
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: ${{ matrix.args }}
manylinux: auto
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.target || 'default' }}
path: dist/*.whl
publish:
name: Publish to PyPI
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/p/bustapi
permissions:
id-token: write
contents: read
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Display collected files
run: |
echo "Files to publish:"
ls -la dist/
- name: Publish to PyPI (Trusted Publishing)
id: trusted-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
skip-existing: true
continue-on-error: true
- name: Publish to PyPI (API Token Fallback)
if: steps.trusted-publish.outcome == 'failure'
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
release:
name: Upload to GitHub Release
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
fail_on_unmatched_files: false