Skip to content

Conversation

@systemroller
Copy link

@systemroller systemroller commented Jan 11, 2026

This PR is for the purpose of triggering periodic CI testing. We don't currently have a way to trigger CI without a PR, so this PR serves that purpose.

Summary by Sourcery

Tests:

  • Introduce a dump_packages callback plugin that records non-removed packages used by Ansible package-related tasks during test execution.

@systemroller
Copy link
Author

[citest]

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 11, 2026

Reviewer's Guide

Adds an Ansible aggregate callback plugin used in CI to capture and print all non-removed packages requested via package-related modules, enabling inspection of package usage across test runs.

File-Level Changes

Change Details Files
Introduce an Ansible callback plugin to aggregate and log packages used by package-related tasks during CI runs.
  • Create a new aggregate callback plugin class CallbackModule extending CallbackBase with appropriate metadata (version, type, name, and compatibility flags)
  • Implement v2_runner_on_ok to intercept successful tasks, filter for package, dnf, and yum actions where state is not absent, and extract requested package names from invocation.module_args.name for both single and multi-result task formats
  • Aggregate all package names into a set and output a deterministic, sorted, space-separated list prefixed with lsrpackages: via the plugin display interface for downstream consumption in CI and image build tooling
tests/callback_plugins/dump_packages.py

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

result._result["results"], list
):
results = result._result["results"]
for item in results:

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable

Local variable 'results' may be used before it is initialized.

Copilot Autofix

AI 30 days ago

In general, to fix a “potentially uninitialized local variable” problem, either (1) initialize the variable to a safe default before any conditional assignments or (2) ensure all control-flow paths that reach its use have definitely assigned it (for example, by adding else cases or early returns).

Here, the safest change without altering existing behavior is:

  • Initialize results to an empty list before the if/elif chain.
  • After the chain, only iterate over results if it is non-empty; otherwise, simply skip the loop so no UnboundLocalError can occur.
    This preserves current behavior when results is defined as before, while making the code no-op (rather than crash) in the rare case that neither condition is met.

Concretely in tests/callback_plugins/dump_packages.py:

  • In CallbackModule.v2_runner_on_ok, add results = [] right after packages = set().
  • Wrap the for item in results: loop and subsequent package processing in an if results: guard so it only executes when results has been set to something meaningful.

No new imports or helper methods are required.

Suggested changeset 1
tests/callback_plugins/dump_packages.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/callback_plugins/dump_packages.py b/tests/callback_plugins/dump_packages.py
--- a/tests/callback_plugins/dump_packages.py
+++ b/tests/callback_plugins/dump_packages.py
@@ -45,20 +45,22 @@
             and fields["args"].get("state") != "absent"
         ):
             packages = set()
+            results = []
             if "invocation" in result._result:
                 results = [result._result]
             elif "results" in result._result and isinstance(
                 result._result["results"], list
             ):
                 results = result._result["results"]
-            for item in results:
-                pkgs = item["invocation"]["module_args"]["name"]
-                if isinstance(pkgs, list):
-                    for ii in pkgs:
-                        packages.add(ii)
-                else:
-                    packages.add(pkgs)
-            # tell python black that this line is ok
-            # fmt: off
-            self._display.display("lsrpackages: " + " ".join(sorted(list(packages))))
-            # fmt: on
+            if results:
+                for item in results:
+                    pkgs = item["invocation"]["module_args"]["name"]
+                    if isinstance(pkgs, list):
+                        for ii in pkgs:
+                            packages.add(ii)
+                    else:
+                        packages.add(pkgs)
+                # tell python black that this line is ok
+                # fmt: off
+                self._display.display("lsrpackages: " + " ".join(sorted(list(packages))))
+                # fmt: on
EOF
@@ -45,20 +45,22 @@
and fields["args"].get("state") != "absent"
):
packages = set()
results = []
if "invocation" in result._result:
results = [result._result]
elif "results" in result._result and isinstance(
result._result["results"], list
):
results = result._result["results"]
for item in results:
pkgs = item["invocation"]["module_args"]["name"]
if isinstance(pkgs, list):
for ii in pkgs:
packages.add(ii)
else:
packages.add(pkgs)
# tell python black that this line is ok
# fmt: off
self._display.display("lsrpackages: " + " ".join(sorted(list(packages))))
# fmt: on
if results:
for item in results:
pkgs = item["invocation"]["module_args"]["name"]
if isinstance(pkgs, list):
for ii in pkgs:
packages.add(ii)
else:
packages.add(pkgs)
# tell python black that this line is ok
# fmt: off
self._display.display("lsrpackages: " + " ".join(sorted(list(packages))))
# fmt: on
Copilot is powered by AI and may make mistakes. Always verify output.
@systemroller
Copy link
Author

[citest]

@systemroller
Copy link
Author

[citest]

1 similar comment
@systemroller
Copy link
Author

[citest]

@systemroller
Copy link
Author

[citest]

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.

1 participant