diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..6f4c2af --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,27 @@ +name: Core Architecture & Invariant CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + validate: + runs-on: ubuntu-latest + container: + image: nixery.dev/shell/coreutils/git/nix/nodejs:latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Configure Git Safe Directory & Nix Flakes + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + mkdir -p ~/.config/nix + echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf + echo "build-users-group =" >> ~/.config/nix/nix.conf + + - name: Run Architecture & Security Invariant Checks + run: | + nix flake check diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 0d5b515..5d03393 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,5 +8,3 @@ if command -v ruff >/dev/null 2>&1 && command -v pyright >/dev/null 2>&1 && comm else nix develop --command bash -c "ruff check . && pyright && pytest" fi - -nix flake check diff --git a/AGENTS.md b/AGENTS.md index 9839527..0731395 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,9 +42,10 @@ The working tree represents the user's active work. --- -## 5. Verification & Completion +## 5. Verification, Hooks & CI Expectations -Every task must be verified inside `nix develop` before declaring completion: -1. Run linters, formatters, and type checks: `nix develop --command ruff check .` and `nix develop --command pyright`. -2. Run test suites when tests are present: `nix develop --command pytest`. -3. Report: (1) What changed, (2) Files modified/created, (3) Verification performed, (4) Unverified areas/risks. +Every task and commit must pass automated verification inside `nix develop`: +1. **Local Pre-Commit Hook (`.githooks/pre-commit`):** Configured automatically by `flake.nix` `shellHook` (`git config core.hooksPath .githooks`). Runs `ruff check .`, `pyright`, and `pytest` before every commit. Never bypass hooks with `--no-verify`. +2. **TDD Red-Phase Commits (`@pytest.mark.xfail`):** When committing Red-phase tests before the feature implementation exists, provide typed symbol stubs (`raise NotImplementedError`) so `pyright` passes, and decorate unimplemented tests with `@pytest.mark.xfail(strict=True, reason="Red phase: ...")` so `pytest` and `.githooks/pre-commit` exit `0` while still failing if a Red test passes tautologically. Remove `xfail` in the Green-phase commit. +3. **Server-Side Gitea Actions CI (`.gitea/workflows/ci.yaml`):** Runs `nix flake check` on every push and pull request targeting `main`, executing `ruff check .`, `pyright`, `pytestCheckHook`, and `buildPythonApplication` inside the isolated Nix sandbox. Verify `nix flake check` locally before opening or updating a pull request. +4. **Completion Reporting:** Report: (1) What changed, (2) Files modified/created, (3) Verification performed, (4) Unverified areas/risks. diff --git a/flake.nix b/flake.nix index 23f12c2..c612763 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,15 @@ pyproject = true; build-system = [ ps.setuptools ]; dependencies = runtimeDeps; - nativeCheckInputs = [ ps.pytestCheckHook ] ++ testDeps; + nativeCheckInputs = [ + ps.pytestCheckHook + pkgs.ruff + pkgs.pyright + ] ++ testDeps; + preCheck = '' + ruff check . + pyright + ''; }; devShells.${system}.default = pkgs.mkShell {