fix: simplify quality gate workflow and harden monitor coverage#7
fix: simplify quality gate workflow and harden monitor coverage#7
Conversation
- Remove auto-commit instructions from all three agents — contents: read prevents pushing commits on pull_request events - Agents now post PR comments with proposed fixes/snippets instead - Add test branch to workflow trigger (feature PRs target test, not main) Fixes Copilot review comments on PR #5. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s automation and Python code/tests around ptop3, including a new Claude “quality gate” workflow and a substantial refactor/extension of the ptop3.monitor data/UI layer with expanded test coverage.
Changes:
- Add a new
claude-quality-gate.ymlworkflow configured for PR comment-only feedback and triggering onmain/test. - Refactor
ptop3/monitor.py(sampling/caching viaProcessSampler, sorting helpers, scrolling, net sort removal) and expandtests/test_monitor.pysignificantly. - Improve tests for privileged subscripts (
swap_clean,drop_caches) and add packaging metadata/coverage configuration inpyproject.toml.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/claude-quality-gate.yml |
Adds a PR-triggered “quality gate” workflow with three Claude agents and comment-only instructions. |
ptop3/monitor.py |
Refactors process sampling/caching, removes net sorting, adds sort helpers + scrolling, and adjusts TUI behavior. |
tests/test_monitor.py |
Adds extensive unit tests for monitor sampling, helpers, and TUI behavior (with mocked curses/psutil). |
tests/test_swap_clean.py |
Adds more swap-clean edge case tests (short lines, swapoff failure, dry-run, file-by-file). |
tests/test_drop_caches.py |
Adds a main() error-path test and minor test cleanup. |
tests/test_sudo_config.py |
Minor import cleanup. |
tests/conftest.py |
Adds sys.path/module-cache manipulation for test imports. |
pyproject.toml |
Adds project.urls and coverage configuration sections. |
| rss_mb = rss_bytes / (1024 * 1024) | ||
| cpu = 0.0 if lite and rss_mb < 2.0 else proc.cpu_percent() | ||
| swap_mb = _swap_value(proc.pid, rss_mb, lite) | ||
| io_read_mb, io_write_mb = _io_values(proc, rss_mb, lite) |
There was a problem hiding this comment.
ProcessSampler._sample_process() computes swap_mb via _swap_value(), which calls the module-level read_vmswap_mb() and therefore always uses DEFAULT_SAMPLER’s cache. This couples all ProcessSampler instances together and makes per-instance TTL/cache behavior ineffective. Consider moving _swap_value onto ProcessSampler (or passing self.read_vmswap_mb into the helper) so sampling uses the current sampler instance consistently.
tests/conftest.py
Outdated
| ROOT = Path(__file__).resolve().parents[1] | ||
| if str(ROOT) not in sys.path: | ||
| sys.path.insert(0, str(ROOT)) | ||
|
|
||
| for module_name in list(sys.modules): | ||
| if module_name == "ptop3" or module_name.startswith("ptop3."): | ||
| sys.modules.pop(module_name, None) |
There was a problem hiding this comment.
This conftest mutates sys.path and forcefully removes all ptop3* entries from sys.modules at import time. In CI the package is already installed via pip install -e ".[dev]", so this is redundant and can mask real packaging/import issues or make tests behave differently from installed usage. Prefer removing this block and relying on the editable install (or configure PYTHONPATH/pytest pythonpath explicitly if needed).
|
|
||
| SORT_KEYS = ("mem", "cpu", "rss", "swap", "io", "net", "count") | ||
|
|
||
| SORT_KEYS = ("mem", "cpu", "rss", "swap", "io", "count") |
There was a problem hiding this comment.
SORT_KEYS (and the help text) drops the net sort option, which is a user-facing behavior change (keybinding s cycle and CLI --sort). CHANGELOG.md currently doesn’t mention this under ## [Unreleased]; please add an entry (likely under Changed or Removed) describing the removal so users aren’t surprised.
| name: Claude Quality Gate | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main, test] | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: |
There was a problem hiding this comment.
The PR description/title focuses on GitHub Actions quality-gate prompt tweaks, but this PR also includes substantial runtime and test changes (e.g., ptop3/monitor.py refactor, new coverage config, test updates). Please update the PR description (and/or split into separate PRs) so reviewers can clearly understand the scope and risk.
…issions # Conflicts: # .github/workflows/claude-quality-gate.yml
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
* fix: simplify quality gate workflow and harden monitor coverage (#7) * fix: harden monitor behavior and raise coverage * fix: quality gate agents comment-only, add test branch trigger - Remove auto-commit instructions from all three agents — contents: read prevents pushing commits on pull_request events - Agents now post PR comments with proposed fixes/snippets instead - Add test branch to workflow trigger (feature PRs target test, not main) Fixes Copilot review comments on PR #5. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address PR review feedback * fix: simplify claude code review workflow --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: simplify Claude workflows and TestPyPI publishing (#8) * fix: harden monitor behavior and raise coverage * fix: quality gate agents comment-only, add test branch trigger - Remove auto-commit instructions from all three agents — contents: read prevents pushing commits on pull_request events - Agents now post PR comments with proposed fixes/snippets instead - Add test branch to workflow trigger (feature PRs target test, not main) Fixes Copilot review comments on PR #5. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address PR review feedback * fix: simplify claude code review workflow * ci: auto-version testpypi publishes * ci: set testpypi environment * chore: ignore coverage artifacts * chore: use standard python gitignore * test: tighten swap fallback assertion * fix: pass github_token to claude-code-action to resolve permission denials --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
This PR does two things:
mainandtestPRsptop3runtime and test hardening changes needed for the monitor refactor and coverage expansionChanges
claude-quality-gate.ymlwith comment-only prompts for test, docs, and code review agentsptop3.monitorsampling/sorting/TUI state, including tree selection fixes and scroll handlingnetsort mode from the TUI/CLInetsort modeProcessSampleruse its own swap reader path instead of the global default sampler cachetests/conftest.pyimport-cache hack with explicit pytestpythonpath = ["."]Verification
pytestruff check .Reviewer follow-ups addressed
ProcessSamplerinstancesys.modulesCHANGELOG.mddocuments the removal ofnetsort