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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[{*.toml,*.yml,*.yaml}]
[{*.cff,*.toml,*.yml,*.yaml}]
indent_style = space
indent_size = 2

Expand Down
24 changes: 23 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
version: 2

updates:
- package-ecosystem: pip
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
groups:
python-dependencies:
patterns: ["*"]

- package-ecosystem: pre-commit
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
groups:
git-hooks:
patterns: ["*"]

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
groups:
github-actions:
patterns: ["*"]
91 changes: 46 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ on:
branches: [main]
workflow_dispatch:

permissions:
contents: read
permissions: {}

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
Expand All @@ -17,67 +16,69 @@ jobs:
quality:
name: Quality
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read

steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
python-version: "3.14"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the project and quality tools
run: |
python -m pip install --upgrade "pip>=25.1"
python -m pip install --editable .
python -m pip install --group quality
- run: ruff check .
- run: ruff format --check .
- run: mypy template_python tests
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/prek
key: prek-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run Git hooks on every file
run: uv run --locked prek run --all-files --show-diff-on-failure
- name: Type check
run: uv run --locked mypy

test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
permissions:
contents: read
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.12", "3.13", "3.14"]
experimental: [false]
include:
- { os: macos-latest, python-version: "3.14", experimental: false }
- { os: windows-latest, python-version: "3.14", experimental: false }
# Early warning for the next Python release; failures do not block.
- { os: ubuntu-latest, python-version: "3.15", experimental: true }

steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the project and test tools
run: |
python -m pip install --upgrade "pip>=25.1"
python -m pip install --editable .
python -m pip install --group test
- run: python -m pytest --cov
- name: Run tests with coverage
run: uv run --locked --no-default-groups --group test pytest --cov

package:
name: Build package
needs: [quality, test]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read

steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
python-version: "3.14"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install packaging tools
run: |
python -m pip install --upgrade "pip>=25.1"
python -m pip install --group build
- name: Build and validate distributions
run: |
python -m build
python -m twine check --strict dist/*
- name: Smoke-test the wheel
run: |
python -m venv /tmp/template-wheel-test
/tmp/template-wheel-test/bin/python -m pip install dist/*.whl
/tmp/template-wheel-test/bin/template-python --points 3
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
- name: Build the sdist and the wheel from it
run: uv build
- name: Validate distribution metadata
run: uv run --locked --only-group build twine check --strict dist/*
- name: Smoke-test the wheel in an isolated environment
run: uv run --isolated --no-project --with dist/*.whl template-python --points 3
38 changes: 37 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=1000]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=lf]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.1
rev: v0.16.10
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.12.24
hooks:
- id: uv-lock

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.25
hooks:
- id: validate-pyproject

- repo: https://github.com/kynan/nbstripout
rev: 0.9.1
hooks:
- id: nbstripout

- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.30.1
hooks:
- id: zizmor
31 changes: 17 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,37 @@ With `uv`:

```bash
uv sync --group analysis
uv run pre-commit install
uv run prek install
```

With standard Python tooling:
With standard Python tooling (`pip` 25.1 or newer):

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install --editable .
python -m pip install --group dev --group analysis
pre-commit install
python -m pip install --editable . --group dev --group analysis
prek install
```

The hooks run Ruff, strip notebook outputs, block large files and private
keys, keep `uv.lock` in sync with `pyproject.toml`, and audit the CI workflow.
`pre-commit` reads the same `.pre-commit-config.yaml` if you prefer it.

## Make a change

1. Add or update a test that describes the intended behaviour.
2. Put reusable logic under `template_python/`, not in a notebook.
3. Update user-facing documentation and provenance notes where relevant.
4. Run the full local check suite:
2. Put reusable logic under `src/template_python/`, not in a notebook.
3. Change dependencies with `uv add` or `uv remove` (or edit `pyproject.toml`
and run `uv lock`), and commit the updated `uv.lock`.
4. Update user-facing documentation and provenance notes where relevant.
5. Run the full local check suite:

```bash
ruff check .
ruff format --check .
mypy template_python tests
python -m pytest --cov
python -m build
python -m twine check --strict dist/*
uv run prek run --all-files
uv run mypy
uv run pytest --cov
uv build
```

Do not commit generated distributions, local environments, credentials, large
Expand Down
Loading
Loading