Skip to content

Simplify quality gate workflows and enhance monitor coverage#9

Merged
spazyCZ merged 3 commits intomainfrom
test
Mar 10, 2026
Merged

Simplify quality gate workflows and enhance monitor coverage#9
spazyCZ merged 3 commits intomainfrom
test

Conversation

@spazyCZ
Copy link
Copy Markdown
Owner

@spazyCZ spazyCZ commented Mar 10, 2026

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:

  • Updated the Claude quality gate workflow to require all review feedback (test, documentation, code quality) to be posted as PR comments only, with no direct file modifications or commits by agents. This enforces safer, auditable feedback and clearer review boundaries. [1] [2] [3]
  • Expanded the quality gate trigger to run on both main and test branches, ensuring coverage on feature and integration branches.
  • Added github_token to Claude action steps for all agents to enable proper PR commenting. [1] [2] [3]
  • In the TestPyPI publish workflow, added a unique versioning step for each run, set the correct environment and permissions for Trusted Publishing, and removed the need for a TestPyPI API token. [1] [2] [3]

Testing Improvements:

  • Added new and improved tests for ptop3.scripts.swap_clean and ptop3.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]
  • Cleaned up imports and improved test structure in several test files for maintainability and clarity. [1] [2] [3] [4]

Project Metadata and Configuration:

  • Added project URLs (Homepage, Repository, Changelog, Bug Tracker) to pyproject.toml for improved discoverability and packaging best practices.
  • Configured coverage reporting for the ptop3 source directory and ensured test paths and Python path are set for consistent local and CI runs.

Documentation and Changelog:

  • Updated CHANGELOG.md to note the removal of the unsupported net sort mode, reflecting current feature support.

Claude Code Review Workflow:

  • Refined the Claude code review workflow to focus on correctness, security, maintainability, and test coverage, with clear instructions for feedback and no direct file modifications.

These changes collectively improve the project's automation safety, test reliability, documentation accuracy, and overall maintainability.

spazyCZ and others added 2 commits March 9, 2026 14:50
* 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>
Copilot AI review requested due to automatic review settings March 10, 2026 04:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py sampling into a ProcessSampler, removes the net sort 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).

Comment on lines +252 to +256
rc = swap_clean(
safety_mb=1,
meminfo_path=str(meminfo),
swaps_path=str(swaps),
)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.


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")):
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 675 to +678
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)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@spazyCZ spazyCZ deployed to testpypi March 10, 2026 05:01 — with GitHub Actions Active
@spazyCZ spazyCZ merged commit 63a6ff6 into main Mar 10, 2026
20 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants