Check for TEST_OUTPUT in RPM build tasks#1709
Conversation
As with container builds, we want to verify that there's at least one SAST test run JIRA: ROK-1119
📝 WalkthroughWalkthroughTwo Rego policy files were modified to add RPM-specific test data validation. A new warning rule was added to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@policy/release/test/test.rego`:
- Around line 106-110: The warning currently uses lib.results_from_tests over
lib.pipelinerun_attestations and thus examines all TEST_OUTPUT entries; restrict
the scope to RPM-only before counting: filter lib.pipelinerun_attestations to
RPM attestations (e.g., by an attestation field that identifies RPM builds or
task name) and then derive results from that filtered set (or filter
lib.results_from_tests output for entries with TEST_OUTPUT that are tied to RPM
attestations) so that the check in warn contains result if uses only RPM-related
results when evaluating count(results) == 0.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c7eb1aa-5dc7-4979-a89a-5ff0f00638d2
📒 Files selected for processing (2)
policy/release/test/test.regopolicy/release/test/test_test.rego
| warn contains result if { | ||
| count(lib.pipelinerun_attestations) > 0 # make sure we're looking at a PipelineRun attestation | ||
| results := lib.results_from_tests | ||
| count(results) == 0 # there are none at all | ||
|
|
There was a problem hiding this comment.
Scope this warning to RPM attestations only
Line 108 uses lib.results_from_tests, which aggregates TEST_OUTPUT from all PipelineRun tasks, not RPM-only. That means this rule can miss missing RPM test output when non-RPM tasks contain TEST_OUTPUT, and can also warn on non-RPM-only inputs. Please filter attestations/results to RPM builds before evaluating count(results) == 0.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@policy/release/test/test.rego` around lines 106 - 110, The warning currently
uses lib.results_from_tests over lib.pipelinerun_attestations and thus examines
all TEST_OUTPUT entries; restrict the scope to RPM-only before counting: filter
lib.pipelinerun_attestations to RPM attestations (e.g., by an attestation field
that identifies RPM builds or task name) and then derive results from that
filtered set (or filter lib.results_from_tests output for entries with
TEST_OUTPUT that are tied to RPM attestations) so that the check in warn
contains result if uses only RPM-related results when evaluating count(results)
== 0.
There was a problem hiding this comment.
I think it's fine, because we're expecting one build pipeline attestation, or if there is multiple for some reason, all of them will be rpm builds.
There was a problem hiding this comment.
@simonbaird, that makes sense — since the policy is already scoped to the redhat_rpms collection and the pipeline will only ever have RPM build attestations in that context, the existing check is sufficient. I'll drop this concern.
📝 Learnings were identified and not saved (knowledge base disabled). Enable
As with container builds, we want to verify that there's at least one
test run. This is a temporary duplicate set to warn, which will be removed
when we verify this change will not break the rpm build pipleline using the original
deny test.
JIRA: ROK-1119