|
| 1 | +name: Claude Quality Gate |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + types: [opened, synchronize, reopened] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + pull-requests: write |
| 11 | + issues: write |
| 12 | + id-token: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + # Agent 1 — verify tests exist for all changed code |
| 16 | + test-coverage-agent: |
| 17 | + name: Test Coverage Agent |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - uses: anthropics/claude-code-action@v1 |
| 25 | + with: |
| 26 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 27 | + prompt: | |
| 28 | + You are a test quality agent for the ptop3 project. |
| 29 | +
|
| 30 | + Review the diff of this PR (compare HEAD to the base branch) and: |
| 31 | + 1. List every new or modified function/method in ptop3/ source files. |
| 32 | + 2. Check tests/ to confirm each one has a corresponding test. |
| 33 | + 3. For any function missing a test, write the missing test(s) following the project rules: |
| 34 | + - Mock /proc/* files with tmp_path fixtures |
| 35 | + - Mock curses — never test TUI rendering directly |
| 36 | + - Patch os.geteuid for root-required paths |
| 37 | + - Tests must pass on Python 3.10–3.13 |
| 38 | + 4. If all functions are covered, post a short confirmation comment. |
| 39 | + 5. If you added tests, create a commit on this PR branch with message "test: add missing tests for <summary>" |
| 40 | +
|
| 41 | + Project test style is in tests/conftest.py and existing test files. |
| 42 | + Quality rules are in .github/instructions/code-review.instructions.md. |
| 43 | +
|
| 44 | + # Agent 2 — verify CHANGELOG and docs are updated |
| 45 | + docs-changelog-agent: |
| 46 | + name: Docs & Changelog Agent |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + fetch-depth: 0 |
| 52 | + |
| 53 | + - uses: anthropics/claude-code-action@v1 |
| 54 | + with: |
| 55 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 56 | + prompt: | |
| 57 | + You are a documentation quality agent for the ptop3 project. |
| 58 | +
|
| 59 | + Review the diff of this PR and: |
| 60 | +
|
| 61 | + 1. CHANGELOG check: |
| 62 | + - If any user-facing behavior changed (new feature, bug fix, CLI flag, keybinding), |
| 63 | + verify CHANGELOG.md has an entry under ## [Unreleased]. |
| 64 | + - If missing, add the appropriate entry under the correct section |
| 65 | + (Added / Changed / Fixed / Security / Deprecated / Removed). |
| 66 | + - Do NOT bump version numbers. |
| 67 | +
|
| 68 | + 2. README check: |
| 69 | + - If new keybindings, CLI flags, or entry points were added, verify README.md documents them. |
| 70 | + - If missing, add the documentation. |
| 71 | +
|
| 72 | + 3. Docstring check: |
| 73 | + - For any new public function in ptop3/ that lacks a docstring, add a one-line docstring. |
| 74 | +
|
| 75 | + If you made changes, commit them with message "docs: update changelog/readme for <summary>". |
| 76 | + If everything is already documented, post a short confirmation comment. |
| 77 | +
|
| 78 | + # Agent 3 — code quality and security review |
| 79 | + code-review-agent: |
| 80 | + name: Code Review Agent |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + fetch-depth: 0 |
| 86 | + |
| 87 | + - uses: anthropics/claude-code-action@v1 |
| 88 | + with: |
| 89 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 90 | + prompt: | |
| 91 | + You are a code quality and security agent for the ptop3 project. |
| 92 | +
|
| 93 | + Review the diff of this PR against the standards in |
| 94 | + .github/instructions/code-review.instructions.md and check for: |
| 95 | +
|
| 96 | + 1. Style violations: bare except, print() in library code, typing.Dict/List/Optional, |
| 97 | + shell=True in subprocess, string path concatenation instead of pathlib. |
| 98 | + 2. Security issues: unsanitized input to subprocess, hardcoded secrets, |
| 99 | + missing root check before writing /proc/sys/vm/drop_caches or calling swapoff/swapon, |
| 100 | + missing visudo validation before sudoers writes. |
| 101 | + 3. GitHub Actions: missing permissions blocks, missing skip-existing on TestPyPI steps. |
| 102 | + 4. Module-specific rules from the instructions file. |
| 103 | +
|
| 104 | + For each issue found: |
| 105 | + - Post an inline PR review comment at the exact file+line. |
| 106 | + - If the fix is straightforward (style, missing guard), apply it directly and commit |
| 107 | + with message "fix: <short description>". |
| 108 | + - If the fix requires design decisions, comment only — do not auto-fix. |
| 109 | +
|
| 110 | + If no issues are found, post a brief approval comment summarising what was checked. |
0 commit comments