Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches:
- main
- master
tags:
- "*"
pull_request:
workflow_dispatch:
workflow_run:
workflows: ["Deploy Release"]
types:
- completed

permissions:
contents: read

jobs:
check-commit:
runs-on: ubuntu-latest
if: >
(
(
(github.event_name == 'push')
|| (github.event_name == 'pull_request' && github.event.pull_request.user.login == 'lmmx')
)
&&
(
startsWith(github.event.head_commit.message, 'chore(release)') ||
contains(github.event.head_commit.message, 'cibuildwheel')
)
)
|| (github.event_name == 'workflow_dispatch')
|| (github.event_name == 'workflow_run')
steps:
- name: Confirm commit message matched
run: echo "Commit message matched the condition."

build:
needs: [check-commit]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Build package
run: uv build

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist

release:
name: Release
environment: pypi
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_run' }}
needs: [build]
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/download-artifact@v4

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: "wheels-*/*"

- name: Publish to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_run' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheels-sdist/
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy Release

on:
workflow_dispatch:

jobs:
deploy-release:
name: Run just release
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install just
uses: taiki-e/install-action@64adfd9e935fa438859b9e080fd026720b2ba070 # tag=just
with:
tool: just@1.38.0,echo-comment@0.2.0

- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Bump version, commit changes, tag as the version, and push both
# commit and tag (pushing the latter triggers package release)
- name: Run just release
run: just release
126 changes: 0 additions & 126 deletions .github/workflows/master.yml

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Test

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
get-python-versions:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
python-versions: ${{ steps.get-versions.outputs.python-versions }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Get Python versions from pyproject.toml
id: get-versions
run: |
set -euo pipefail
MIN_VERSION=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.requires-python | sed 's/>=//;s/"//g')

LIST=$(uv python list --all-versions --output-format json)

CPYTHON_VERSIONS=$(echo "$LIST" | jq -c --arg min "$MIN_VERSION" '
($min | split(".") | {major: .[0]|tonumber, minor: .[1]|tonumber}) as $minv |
[.[] | {v:.version_parts, t:.variant, impl:.implementation}]
| unique_by([.v.minor,.t])
| map(select(
(.impl == "cpython") and
(.v.major == 3) and
(.v.minor >= $minv.minor)
))
| map(select(.t != "freethreaded")) # Delete this line to include FT variants
| map("\(.v.major).\(.v.minor)\(if .t=="freethreaded" then "t" else "" end)")')

# PYPY_VERSIONS=$(echo "$LIST" | jq -c --arg min "$MIN_VERSION" '
# ($min | split(".") | {major: .[0]|tonumber, minor: .[1]|tonumber}) as $minv |
# [.[] | {v:.version_parts, t:.variant, impl:.implementation}]
# | unique_by([.v.minor,.impl])
# | map(select(
# (.impl == "pypy") and
# (.v.major == 3) and
# (.v.minor >= $minv.minor)
# ))
# | map("pypy-\(.v.major).\(.v.minor)")')

# versions=$(jq -nc --argjson a "$CPYTHON_VERSIONS" --argjson b "$PYPY_VERSIONS" '$a + $b')
versions=$(jq -nc --argjson a "$CPYTHON_VERSIONS" '$a')

echo "python-versions=$versions" >> $GITHUB_OUTPUT

test:
needs: get-python-versions
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --group test

- name: Run tests
run: |
for attempt in {1..5}; do
if timeout --kill-after=6s 12s $(uv python find) -m pytest; then
exit 0
fi
echo "Attempt $attempt failed/timed out, retrying..."
sleep 5
done
exit 1
Loading
Loading