Skip to content

Commit 59a780b

Browse files
committed
ci: add uv-based main workflow with ty and codecov
Add a composite setup-python-env action (setup-uv + uv sync --frozen) and a main.yml workflow with a quality job (make check) and an 8-leg test matrix (ubuntu 3.10-3.13, macos/windows on 3.10+3.13) running pytest and ty. Coverage goes to codecov via the org-level CODECOV_TOKEN with informational statuses. ci.yml is replaced by on-release-main.yml (interim token publish) so the workflow filename and pypi environment already match the upcoming OIDC trusted publisher configuration
1 parent 39e83f0 commit 59a780b

6 files changed

Lines changed: 179 additions & 120 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Setup Python Environment"
2+
description: "Set up Python and uv, then install the locked dependencies"
3+
4+
inputs:
5+
python-version:
6+
description: "Python version to use"
7+
required: true
8+
default: "3.12"
9+
uv-version:
10+
description: "uv version to use"
11+
required: true
12+
default: "0.9.9"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
version: ${{ inputs.uv-version }}
25+
enable-cache: true
26+
cache-suffix: ${{ matrix.python-version }}
27+
28+
- name: Install Python dependencies
29+
run: uv sync --frozen
30+
shell: bash

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 120 deletions
This file was deleted.

‎.github/workflows/main.yml‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: >-
12+
${{ github.workflow }}-${{ github.ref_type }}-
13+
${{ github.event.pull_request.number || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
quality:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out
21+
uses: actions/checkout@v4
22+
with:
23+
# deep clone incl. tags so hatch-vcs can derive the version
24+
fetch-depth: 0
25+
26+
- uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pre-commit
29+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
30+
31+
- name: Set up the environment
32+
uses: ./.github/actions/setup-python-env
33+
34+
- name: Run checks
35+
run: make check
36+
37+
tests-and-type-check:
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
matrix:
41+
# full python range on ubuntu; boundary versions cross-platform
42+
# (preserves the coverage of the previous CI matrix)
43+
os: [ubuntu-latest]
44+
python-version: ["3.10", "3.11", "3.12", "3.13"]
45+
include:
46+
- os: macos-latest
47+
python-version: "3.10"
48+
- os: macos-latest
49+
python-version: "3.13"
50+
- os: windows-latest
51+
python-version: "3.10"
52+
- os: windows-latest
53+
python-version: "3.13"
54+
fail-fast: false
55+
defaults:
56+
run:
57+
shell: bash
58+
steps:
59+
- name: Check out
60+
uses: actions/checkout@v4
61+
with:
62+
# deep clone incl. tags so hatch-vcs can derive the version
63+
fetch-depth: 0
64+
65+
- name: Set up the environment
66+
uses: ./.github/actions/setup-python-env
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
70+
# no `make` on the windows runners, so invoke the tools directly
71+
- name: Run tests
72+
run: uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml
73+
74+
- name: Check typing
75+
run: uv run ty check
76+
77+
- name: Upload coverage reports to Codecov
78+
uses: codecov/codecov-action@v4
79+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
80+
env:
81+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Release workflow. Filename and environment name are load-bearing:
2+
# the PyPI trusted publisher (OIDC) configuration references
3+
# workflow "on-release-main.yml" and environment "pypi".
4+
#
5+
# INTERIM STATE during the repo migration: publishing still uses the
6+
# PYPI_TOKEN secret via twine. The release phase of the migration
7+
# replaces it with `uv publish --trusted-publishing always` (OIDC)
8+
# and adds the docs deployment job.
9+
10+
name: release-main
11+
12+
on:
13+
push:
14+
tags: ['v[0-9]*']
15+
workflow_dispatch: # Allow manually triggering the workflow
16+
17+
jobs:
18+
publish:
19+
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: pypi
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
# deep clone incl. tags so hatch-vcs can derive the version
27+
fetch-depth: 0
28+
- name: Set up the environment
29+
uses: ./.github/actions/setup-python-env
30+
- name: Build package distribution files
31+
run: uv build
32+
- name: Publish Package
33+
env:
34+
TWINE_REPOSITORY: pypi
35+
TWINE_USERNAME: __token__
36+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
37+
run: |
38+
uvx twine check dist/*
39+
uvx twine upload dist/*
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: validate-codecov-config
2+
3+
on:
4+
pull_request:
5+
paths: [codecov.yaml]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
validate-codecov-config:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Validate codecov configuration
15+
run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate

‎codecov.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Coverage starts at the legacy baseline (~22 %), so statuses are
2+
# informational for now: reports and PR comments without failing CI.
3+
# Tighten targets as coverage grows.
4+
coverage:
5+
range: 20..80
6+
round: down
7+
precision: 1
8+
status:
9+
project:
10+
default:
11+
informational: true
12+
patch:
13+
default:
14+
informational: true

0 commit comments

Comments
 (0)