From 2796a0961984762525153b5ff65b3c1df4fcd0b0 Mon Sep 17 00:00:00 2001 From: Adam Kloboucnik Date: Wed, 2 Sep 2026 12:45:09 +0200 Subject: [PATCH 1/2] build: add ruff + pytest verification contract + CI (via make) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same shape as remix_kube#1 / predev-training#1, per ADR-0003 (predev-brain): make check/check-changed/fix/test, ruff pinned via uvx (0.16.5), lint+format enforced only on python files changed vs origin/main (repo baseline 2026-09-02: 228 findings, 10/17 files misformatted — touch a file, own its findings). make test runs the python SDK's 24 pytest tests (fast, offline, all passing). AGENTS.md + CLAUDE.md symlink carry the contract; CI runs exactly make check. Node SDK gets its own contract when touched. --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ .tool-versions | 2 ++ AGENTS.md | 23 +++++++++++++++++++++++ CLAUDE.md | 1 + Makefile | 21 +++++++++++++++++++++ scripts/lint_changed.sh | 26 ++++++++++++++++++++++++++ 6 files changed, 94 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .tool-versions create mode 100644 AGENTS.md create mode 120000 CLAUDE.md create mode 100644 Makefile create mode 100755 scripts/lint_changed.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..827a79f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +# CI runs exactly what `make check` runs locally — no CI-only logic +# (ADR-0003 in predev-brain). Ruff is pinned inside scripts/lint_changed.sh. +name: ci + +on: + pull_request: + push: + branches: [main] + +jobs: + check: + runs-on: ubuntu-latest + steps: + # Full history: the changed-files diff needs the merge-base with main. + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: astral-sh/setup-uv@v10 + + - run: make check diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..e2ae895 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +python 3.12 +uv 0.12.3 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..f3915bd --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,23 @@ +# Agent instructions — predev-api + +For AI coding agents and humans alike. Two SDKs: `predev-api-python/` and +`predev-api-node/`. Verification follows ADR-0003 (predev-brain); this +contract currently covers the python side (node gets its own when touched). + +## Verify your changes + +- `make check` — before pushing or opening a PR. CI runs exactly this: + ruff (lint + format) **only on python files you changed** vs origin/main + (the repo is not ruff-clean — 228 findings at baseline — and legacy files + are deliberately not your problem), plus the python SDK's pytest suite + (24 tests, fast, offline). +- `make fix` — autofix + format the same changed set. +- Requires `uv` (`brew install uv` or `mise use uv`); ruff and pytest are + fetched automatically, versions pinned in the scripts. + +## House rules + +- Never push to `main`. Every change is a feature branch + PR. +- Conventional Commits v1.0.0; one logical change per commit. +- Do not weaken, skip, or reconfigure checks to get green — fix the code, or + stop and escalate to a human. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f7d5d91 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Verification contract (ADR-0003 in predev-brain). CI runs exactly +# `make check`, so a local green is a CI green. Requires uv +# (https://docs.astral.sh/uv/ — `brew install uv` or `mise use uv`); ruff is +# version-pinned in scripts/lint_changed.sh, pytest deps are declared inline +# below — nothing else to install. +.PHONY: check check-changed lint fix test + +check: lint test + +check-changed: check + +lint: + bash scripts/lint_changed.sh + +fix: + bash scripts/lint_changed.sh --fix + +# The python SDK's suite (fast, no network). --no-project because the SDK is +# a setup.py package, not a uv project; requests is its one runtime dep. +test: + cd predev-api-python && uv run --no-project --with pytest --with requests -- pytest tests/ -q diff --git a/scripts/lint_changed.sh b/scripts/lint_changed.sh new file mode 100755 index 0000000..8036673 --- /dev/null +++ b/scripts/lint_changed.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Changed-files ruff (ADR-0003 in predev-brain): the repo is not ruff-clean +# (measured 2026-09-02: 228 lint findings, 10/17 files misformatted), so lint +# + format are enforced only on python files touched relative to origin/main. +# Violations in files you touch get fixed in that PR; untouched legacy files +# are not your problem. `--fix` applies autofixes + formatting to the same set. +set -euo pipefail +cd "$(dirname "$0")/.." + +RUFF="uvx ruff@0.16.5" + +base=$(git merge-base HEAD origin/main 2>/dev/null || echo "") +files=$(git diff --name-only --diff-filter=d ${base:+"$base"} -- '*.py') +if [ -z "$files" ]; then + echo "lint: no changed python files" + exit 0 +fi + +# shellcheck disable=SC2086 # word splitting is intended; no spaces in paths +if [ "${1:-}" = "--fix" ]; then + $RUFF check --fix $files + $RUFF format $files +else + $RUFF check $files + $RUFF format --check $files +fi From 3b059ba6ed22aefe2022aef0afa866ff30e85f43 Mon Sep 17 00:00:00 2001 From: Adam Kloboucnik Date: Wed, 2 Sep 2026 15:45:40 +0200 Subject: [PATCH 2/2] ci: pin setup-uv to v10.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit astral-sh publishes no floating v10 major tag — @v10 fails action resolution at job setup ("unable to find version v10"). --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 827a79f..7a5a96d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,6 @@ jobs: with: fetch-depth: 0 - - uses: astral-sh/setup-uv@v10 + - uses: astral-sh/setup-uv@v10.0.1 - run: make check