Skip to content

Conversation

@ArtiomDivak
Copy link
Collaborator

@ArtiomDivak ArtiomDivak commented Nov 12, 2025

Summary by Sourcery

resolve #940

Add a new GitHub Actions workflow to run Sourcery code reviews on pull requests.

CI:

  • Introduce .github/workflows/sourcery.yml to trigger Sourcery reviews on pull request events
  • Set up Python 3.11, install Sourcery, and run reviews against the tools directory

Summary by Sourcery

Integrate Sourcery static analysis into local tooling and apply minor code cleanups to qmctl.

Enhancements:

  • Add a Sourcery pre-commit hook to run static analysis with checks on staged changes.
  • Simplify subprocess invocation and remove redundant code in the qmctl CLI tool.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds Sourcery static analysis to the project via pre-commit and small refactors suggested by Sourcery in qmctl, along with cleanup of an unnecessary pass statement.

File-Level Changes

Change Details Files
Integrate Sourcery as a pre-commit hook for static analysis on Python code.
  • Add Sourcery repository configuration with pinned version v1.40.0 to pre-commit config
  • Configure sourcery hook to run in check mode via --check argument
  • Exclude demos, tests, and oci-hooks/tests directories from Sourcery checks
.pre-commit-config.yaml
Apply Sourcery-driven refactors and minor cleanup in qmctl subprocess handling and main entrypoint.
  • Simplify _run_subprocess options selection by using kwargs or defaults
  • Inline the subprocess.run result by returning it directly instead of storing in a temporary variable
  • Remove redundant pass statement after warning print in main
tools/qmctl/qmctl.py

Assessment against linked issues

Issue Objective Addressed Explanation
#940 Add a GitHub Actions workflow (.github/workflows/sourcery.yml) to run Sourcery code reviews in CI for better error visibility and control. The diff does not include a new .github/workflows/sourcery.yml (or any workflow file). It only adds a Sourcery hook to .pre-commit-config.yaml and applies some Sourcery-driven code changes, so CI-based workflow execution is not implemented.
#940 Replace the existing local/CLI-based Sourcery review mechanism (which can fail silently and require a personal token) with the new CI-based approach. The PR adds Sourcery as a pre-commit hook, which remains a local execution mechanism, and does not show removal or reconfiguration of any existing local/CLI-based Sourcery integration. It also does not change how authentication or logging is handled in CI, so the issues with personal tokens and poor error visibility are not clearly addressed.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArtiomDivak ArtiomDivak force-pushed the sourcery branch 3 times, most recently from 99a8707 to 36c2ec7 Compare November 12, 2025 11:46
@ArtiomDivak ArtiomDivak self-assigned this Nov 12, 2025
@ArtiomDivak
Copy link
Collaborator Author

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Yarboa
Copy link
Collaborator

Yarboa commented Nov 13, 2025

Please take a look here

https://github.com/containers/qm/actions/runs/19296341436/job/55179130811?pr=948

There are output and ideas to fix
how comes review is passing?

@ArtiomDivak ArtiomDivak force-pushed the sourcery branch 4 times, most recently from a3c713b to 6b6e6e0 Compare November 20, 2025 12:20
@ArtiomDivak ArtiomDivak force-pushed the sourcery branch 2 times, most recently from f8f28be to 0573ac4 Compare November 20, 2025 12:47
@ArtiomDivak ArtiomDivak force-pushed the sourcery branch 3 times, most recently from 398415e to 6c2a7b5 Compare December 16, 2025 05:23
@ArtiomDivak ArtiomDivak requested a review from Yarboa December 16, 2025 05:25
@ArtiomDivak ArtiomDivak force-pushed the sourcery branch 2 times, most recently from 1eef217 to c1f445b Compare December 16, 2025 06:44
@ArtiomDivak ArtiomDivak marked this pull request as ready for review December 16, 2025 06:59
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `tools/qmctl/qmctl.py:264-269` </location>
<code_context>

-        options = kwargs if kwargs else defaults
+        options = kwargs or defaults
         try:
-            result = subprocess.run(    # nosec B603
+            return subprocess.run(    # nosec B603
                 cmd,
                 **options,
             )
-            return result
         except Exception as e:
             raise RuntimeError(f"subprocess.run failed: {e}") from e

</code_context>

<issue_to_address>
**issue (bug_risk):** Narrow the exception type around `subprocess.run` to avoid swallowing interrupts and unrelated errors.

Catching `Exception` here will also intercept `KeyboardInterrupt` and `SystemExit`, making the CLI harder to interrupt and potentially hiding unrelated problems. Prefer catching specific errors (e.g., `OSError`, `subprocess.SubprocessError`) so only subprocess-related failures are wrapped in `RuntimeError` and truly exceptional conditions still propagate.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- Add Sourcery pre-commit hook with exclusions for demos and test directories
- Fix syntax error in tests/qm-ipc/server/server.py

closes https://issues.redhat.com/browse/VROOM-34063

Signed-off-by: Artiom Divak <adivak@redhat.com>
Copy link
Collaborator

@Yarboa Yarboa left a comment

Choose a reason for hiding this comment

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

LGTM,
Thank you

@dougsland
Copy link
Member

triggering CI/CD failure.

@dougsland
Copy link
Member

Related: #951

@dougsland dougsland merged commit 699c09a into containers:main Dec 19, 2025
25 of 26 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.

Change sourcery local review into pre-commit script

3 participants