ci(nix): wire ruff and pyright into flake check and add Gitea Actions workflow
- flake.nix: add ruff and pyright to packages.default nativeCheckInputs and preCheck so nix build / nix flake check enforce lint, types, and pytest in the Nix sandbox - .githooks/pre-commit: keep local pre-commit hook fast (<0.5s) running ruff, pyright, and pytest - .gitea/workflows/ci.yaml: run nix flake check on push and pull_request to main - AGENTS.md: document .githooks/pre-commit, @pytest.mark.xfail(strict=True) Red-phase rule, and .gitea/workflows/ci.yaml expectations
This commit is contained in:
1 parent
98ffc65cb1
commit
7ea45c3d3b
4 files changed
+42
-8
No files matched your search
@@ -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
|
||||||
@@ -8,5 +8,3 @@ if command -v ruff >/dev/null 2>&1 && command -v pyright >/dev/null 2>&1 && comm
|
|||||||
else
|
else
|
||||||
nix develop --command bash -c "ruff check . && pyright && pytest"
|
nix develop --command bash -c "ruff check . && pyright && pytest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nix flake check
|
|
||||||
@@ -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:
|
Every task and commit must pass automated verification inside `nix develop`:
|
||||||
1. Run linters, formatters, and type checks: `nix develop --command ruff check .` and `nix develop --command pyright`.
|
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. Run test suites when tests are present: `nix develop --command pytest`.
|
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. Report: (1) What changed, (2) Files modified/created, (3) Verification performed, (4) Unverified areas/risks.
|
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.
|
||||||
@@ -34,7 +34,15 @@
|
|||||||
pyproject = true;
|
pyproject = true;
|
||||||
build-system = [ ps.setuptools ];
|
build-system = [ ps.setuptools ];
|
||||||
dependencies = runtimeDeps;
|
dependencies = runtimeDeps;
|
||||||
nativeCheckInputs = [ ps.pytestCheckHook ] ++ testDeps;
|
nativeCheckInputs = [
|
||||||
|
ps.pytestCheckHook
|
||||||
|
pkgs.ruff
|
||||||
|
pkgs.pyright
|
||||||
|
] ++ testDeps;
|
||||||
|
preCheck = ''
|
||||||
|
ruff check .
|
||||||
|
pyright
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
|
|||||||
Reference in new issue
Block a user