Skip to content

Commit 2f407f4

Browse files
authored
Merge pull request #5 from spazyCZ/test
chore: sync test → main (quality gate, branching strategy, docs)
2 parents 8449401 + a7aa794 commit 2f407f4

4 files changed

Lines changed: 162 additions & 1 deletion

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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.

.github/workflows/publish-testpypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish to TestPyPI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [test]
66
workflow_dispatch:
77

88
permissions:

CLAUDE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ptop3 — Claude Code Context
2+
3+
`ptop3` is a Linux TUI process monitor (htop-like) that groups processes by application.
4+
It uses `curses` for the UI, `psutil` for process data, and ships two privileged scripts
5+
(`ptop3-drop-caches`, `ptop3-swap-clean`) that run via passwordless sudo.
6+
7+
## Key Files
8+
9+
| File | Purpose |
10+
|------|---------|
11+
| `ptop3/monitor.py` | Core TUI + data aggregation |
12+
| `ptop3/sudo_config.py` | Passwordless sudo setup |
13+
| `ptop3/scripts/drop_caches.py` | Kernel cache clearing |
14+
| `ptop3/scripts/swap_clean.py` | Swap cleanup |
15+
| `tests/` | Pytest suite — all 4 Python versions |
16+
| `CHANGELOG.md` | User-facing change log |
17+
| `.github/instructions/code-review.instructions.md` | Full style & quality guide |
18+
19+
## Code Standards
20+
21+
- Python 3.10+: use `X | None`, `list[str]`, `match`, builtin generics — no `typing.Dict/List/Optional`
22+
- Ruff: line-length 100, rules E/F/I/UP — run `ruff check ptop3/` before committing
23+
- No bare `except:`, no `print()` in library code, no `shell=True` in subprocess calls
24+
- File paths via `pathlib.Path` — never string concatenation
25+
26+
## Testing
27+
28+
- Run: `pytest --cov=ptop3 --cov-report=term-missing`
29+
- Every new function must have a test; mock `/proc/*` files with `tmp_path`; mock `curses`
30+
- Tests must not require root — patch `os.geteuid` for privileged paths
31+
32+
## CHANGELOG
33+
34+
Every PR with user-facing changes must add an entry under `## [Unreleased]`.
35+
Sections: `Added`, `Changed`, `Fixed`, `Security`, `Deprecated`, `Removed`.
36+
Do **not** bump versions manually — that's handled by `bump-my-version` in the release workflow.
37+
38+
## Commits
39+
40+
Conventional format: `feat:`, `fix:`, `docs:`, `ci:`, `chore:`, `refactor:`, `test:`
41+
CI must be green on all 4 Python versions (3.10–3.13) before merging.

codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: auto
6+
threshold: 1%
7+
8+
codecov:
9+
notify:
10+
after_n_builds: 4 # match matrix size (3.10, 3.11, 3.12, 3.13)

0 commit comments

Comments
 (0)