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 docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Further style rules may be added under `docs/` over time; this page will link th

Baseline **pre-commit**, **`pyproject.toml`** tooling sections and **`baselines/ruff.toml`** ship as a **Copier template** ([`template/`](../template/), [`copier.yml`](../copier.yml)), described in the [README](../README.md) (**Repository layout**, **What Is Standardized**, **Quick Start**) and [migration-guide.md](migration-guide.md).

**Validation contract:** every repo validates with `bash scripts/check.sh` (managed by Copier, so `copier update` keeps it current). It needs uv, runs `uv sync --frozen` from `uv.lock` (failing instead of re-locking if the lock is missing or stale), then pre-commit and pytest, and CI runs the same script. Run `uv lock` and commit `uv.lock` once on a new repo; the script stops with that hint when it is missing. Set the Copier `uv_sync_args` answer (for example `--extra processing`) for extras the checks need; it is interpolated verbatim into the shell command, so keep it to simple, unquoted arguments. Dev tools live in `[dependency-groups] dev`.
**Validation contract:** every repo validates with `bash scripts/check.sh` (managed by Copier, so `copier update` keeps it current). It needs uv, runs `uv sync --frozen` from `uv.lock` (failing instead of re-locking if the lock is missing or stale), then pre-commit and pytest, and CI runs the same script. Run `uv lock` and commit `uv.lock` once on a new repo; the script stops with that hint when it is missing. Set the Copier `uv_sync_args` answer (for example `--extra processing`) for extras the checks need; it is interpolated verbatim into the shell command, so keep it to simple, unquoted arguments. Dev tools live in `[dependency-groups] dev`. A repo adopting the template for the first time follows the [first-adoption checklist](migration-guide.md#first-adoption-checklist).

## Portable agent guidance

Expand Down
10 changes: 10 additions & 0 deletions docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ Commit **`.copier-answers.yml`**: it records the adopted release (`_commit`) and

A repo that already has its own `scripts/check.sh` gets a Copier conflict on the first update: reconcile it with the template version.

### First-adoption checklist

For a repo without `.copier-answers.yml`, `scripts/check.sh` only passes once the repo satisfies this contract:

- `pre-commit`, `ruff`, `mypy` and `pytest` are in `[dependency-groups] dev`. `check.sh` runs them with `python -m` inside the uv environment, so a globally installed binary never satisfies it, and it stops with a hint when `pre-commit` is missing.
- `pyproject.toml` has `[tool.ruff] extend = "baselines/ruff.toml"` without its own `line-length` or `select`, and a `[tool.mypy]` section copied from [`template/pyproject.toml.jinja`](../template/pyproject.toml.jinja).
- The ruff and mypy versions in `.pre-commit-config.yaml` match the ones in `uv.lock`.
- `reusable_lint: false` when CI already runs `bash scripts/check.sh`, so the template does not add a second lint job.
- `test_workflow: false` when tests run in another workflow. Do not rerun pytest in a separate job without a reason, because `check.sh` already runs it.

## 2. Install and validate

```bash
Expand Down
3 changes: 3 additions & 0 deletions scripts/tests/agent-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ copier copy --defaults --data package_name=demo "$tmp/source" "$tmp/default" >/d
[[ ! -e "$tmp/default/AGENTS.md" ]]
[[ -x "$tmp/default/scripts/check.sh" ]]
grep -qx 'uv sync --frozen' "$tmp/default/scripts/check.sh"
grep -qx "uv run --frozen python -m pre_commit run --all-files" "$tmp/default/scripts/check.sh"
grep -qx "uv run --frozen python -m pytest" "$tmp/default/scripts/check.sh"
grep -q "import pre_commit" "$tmp/default/scripts/check.sh"
copier copy --defaults --data package_name=demo --data 'uv_sync_args=--extra processing' "$tmp/source" "$tmp/extra" >/dev/null
[[ -x "$tmp/extra/scripts/check.sh" ]]
actionlint "$tmp/extra/.github/workflows/test.yml" "$tmp/extra/.github/workflows/lint.yml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
python -m pip install --upgrade pip uv
uv sync --frozen{% if uv_sync_args %} {{ uv_sync_args }}{% endif %}

pre-commit-command: uv run --frozen pre-commit run --all-files
pre-commit-command: uv run --frozen python -m pre_commit run --all-files
5 changes: 3 additions & 2 deletions template/scripts/check.sh.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ cd "$(dirname "$0")/.."
command -v uv >/dev/null || { echo 'uv is required: https://docs.astral.sh/uv/' >&2; exit 1; }
[ -f uv.lock ] || { echo 'uv.lock is missing: run `uv lock` and commit it' >&2; exit 1; }
uv sync --frozen{% if uv_sync_args %} {{ uv_sync_args }}{% endif %}
uv run --frozen pre-commit run --all-files
uv run --frozen pytest
uv run --frozen python -c 'import pre_commit' || { echo 'check failed: if the error above is ModuleNotFoundError, add pre-commit to [dependency-groups] dev' >&2; exit 1; }
uv run --frozen python -m pre_commit run --all-files
uv run --frozen python -m pytest
Loading