Conversation
* 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: 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>
There was a problem hiding this comment.
Pull request overview
This PR updates ptop3’s CI workflows and project metadata while significantly expanding the test suite and refactoring the monitor’s sampling/caching logic.
Changes:
- Refactors
ptop3/monitor.pysampling into aProcessSampler, removes thenetsort mode, and improves TUI scrolling/status behavior. - Expands tests for
swap_clean,drop_caches, and monitor behavior (including error paths and caching). - Tightens/clarifies GitHub Actions workflows (Claude agents comment-only) and improves packaging/coverage metadata.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
ptop3/monitor.py |
Introduces ProcessSampler/SampleResult, removes net sort references, and adds scrolling/status helpers in the TUI. |
tests/test_monitor.py |
Adds extensive unit coverage for sampling, sorting, caching, and TUI helper paths. |
tests/test_swap_clean.py |
Adds new cases for swap parsing, swapoff failure handling, dry-run, and file-by-file fallback. |
tests/test_drop_caches.py |
Adds coverage for main() error surfacing and minor test cleanup. |
tests/test_sudo_config.py |
Import cleanup / minor test organization adjustments. |
tests/conftest.py |
Minor fixture/import cleanup. |
pyproject.toml |
Adds project URLs, pytest pythonpath, and coverage configuration. |
CHANGELOG.md |
Notes removal of non-functional net sort mode under Unreleased. |
.github/workflows/claude-quality-gate.yml |
Runs on main + test, adds github_token, and enforces comment-only feedback. |
.github/workflows/claude-code-review.yml |
Updates permissions and prompt to enforce PR-comment-only reviews. |
.github/workflows/publish-testpypi.yml |
Uses Trusted Publishing with unique dev versions per run and removes API token usage. |
.gitignore |
Expands ignored artifacts (venvs, coverage outputs, tooling caches). |
tests/test_swap_clean.py
Outdated
| rc = swap_clean( | ||
| safety_mb=1, | ||
| meminfo_path=str(meminfo), | ||
| swaps_path=str(swaps), | ||
| ) |
There was a problem hiding this comment.
The swap_clean( call in this test isn't closed/indented correctly (the closing ) is missing at the correct indentation level), which makes the file a syntax error and will fail test collection. Fix the indentation and ensure the function call is properly closed before exiting the nested with blocks.
|
|
||
|
|
||
| def test_swap_clean_returns_error_when_swapoff_fails(tmp_meminfo, tmp_swaps, capsys): | ||
| with patch("ptop3.scripts.swap_clean.subprocess.run", return_value=MagicMock(returncode=1, stderr="nope")): |
There was a problem hiding this comment.
This patch(...) context manager line exceeds the project's configured Ruff line length (100) and is likely to fail ruff check (E501). Please wrap the patch() call across multiple lines (e.g., split args / use parentheses) to keep it within the limit.
| if self.view == "detail" and self.detail_app: | ||
| lst = [r for r in rows if r.app == self.detail_app] | ||
| if self.tree_mode: | ||
| self.detail_tree = build_process_tree(lst, self.sort_key) | ||
| self.detail_list = lst | ||
| else: | ||
| if self.sort_key == "mem": | ||
| lst.sort(key=lambda x: x.mem_pct, reverse=True) | ||
| elif self.sort_key == "cpu": | ||
| lst.sort(key=lambda x: x.cpu, reverse=True) | ||
| elif self.sort_key == "rss": | ||
| lst.sort(key=lambda x: x.rss_mb, reverse=True) | ||
| elif self.sort_key == "swap": | ||
| lst.sort(key=lambda x: x.swap_mb, reverse=True) | ||
| elif self.sort_key == "io": | ||
| lst.sort(key=lambda x: (x.io_read_mb + x.io_write_mb), reverse=True) | ||
| elif self.sort_key == "net": | ||
| lst.sort(key=lambda x: x.net_sent_mb, reverse=True) | ||
| else: | ||
| lst.sort(key=lambda x: x.pid, reverse=True) | ||
| self.detail_list = lst | ||
| detail_list = [row for row in sample.rows if row.app == self.detail_app] | ||
| self.detail_list = sort_processes(detail_list, self.sort_key) | ||
| self.detail_tree = build_process_tree(detail_list, self.sort_key) |
There was a problem hiding this comment.
sample() always builds detail_tree even when tree_mode is off, which adds extra work on every refresh for large groups. Consider only calling build_process_tree(...) when self.tree_mode is enabled (or computing it lazily when switching into tree view) to avoid a performance regression.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This pull request improves the CI/CD workflow, strengthens test coverage, and enhances project metadata and documentation. The most significant changes include stricter and safer automation for quality gates and publishing, expanded tests for swap and cache cleaning scripts, and improvements to project configuration for better maintainability and discoverability.
CI/CD Workflow Improvements:
mainandtestbranches, ensuring coverage on feature and integration branches.github_tokento Claude action steps for all agents to enable proper PR commenting. [1] [2] [3]Testing Improvements:
ptop3.scripts.swap_cleanandptop3.scripts.drop_caches, ensuring error paths, dry-run logic, and fallback behaviors are covered. This includes tests for swapoff failures, file-by-file fallback, and OSError handling. [1] [2] [3] [4]Project Metadata and Configuration:
pyproject.tomlfor improved discoverability and packaging best practices.ptop3source directory and ensured test paths and Python path are set for consistent local and CI runs.Documentation and Changelog:
CHANGELOG.mdto note the removal of the unsupportednetsort mode, reflecting current feature support.Claude Code Review Workflow:
These changes collectively improve the project's automation safety, test reliability, documentation accuracy, and overall maintainability.