Skip to content

Conversation

joestringer
Copy link
Member

@joestringer joestringer commented Apr 17, 2025

The first half of this PR is just tidying up the codeowners logic to move it
into its own package for better reuse elsewhere in the CLI.

The second half reworks the way that codeowners are emitted into the junit
files. Previously, code owners for test cases were emitted multiple times
per test case in the following form, once per owner per scenario and once
per owner of the workflow:

@owner (test-name-or-github-workflow)

This form will continue to be used for the text output in CI runs, but it will
be changed for the junit format that is reported into the CI dashboard.
Following this PR, the workflow owners are instead injected once at the top
'test_suite' node of the junit, which avoids duplication. These are injected
without the test name, since that is available in the parent node. Furthermore,
rather than duplicating the owners properties for each scenario in a test case,
each owner is included just once.

For an alternative visualization, inspect the following example junit diff,
generated via:

export GITHUB_WORKFLOW_REF=cilium/cilium/.github/workflows/conformance-kind-proxy-embedded.yaml@refs/pull/37593/merge
./cilium-cli/cilium connectivity test --log-code-owners --test no-errors-in-logs --junit-file junit_results.xml
--- junit_results.xml.old       2025-04-17 16:04:31.786164160 -0700
+++ junit_results.xml.new       2025-04-17 16:03:56.614366718 -0700
@@ -1,1104 +1,741 @@
 <?xml version="1.0" encoding="UTF-8"?>
   <testsuites tests="119" disabled="118" errors="0" failures="1" time="x">
       <testsuite name="connectivity test" id="0" package="cilium" tests="119" errors="0" failures="1" skipped="118" time="x" timestamp="0001-01-01T00:00:00">
           <properties>
               <property name="Args" value="--log-code-owners|--test|no-errors-in-logs|--junit-file|junit_results.xml"></property>
+              <property name="owner" value="@cilium/sig-servicemesh"></property>
+              <property name="owner" value="@cilium/github-sec"></property>
+              <property name="owner" value="@cilium/ci-structure"></property>
           </properties>
           <testcase name="no-unexpected-packet-drops" classname="connectivity test" status="skipped" time="0">
               <properties>
-                  <property name="owner" value="@cilium/ci-structure (.github/workflows/conformance-kind-proxy-embedded.yaml)"></property>
-                  <property name="owner" value="@cilium/github-sec (.github/workflows/conformance-kind-proxy-embedded.yaml)"></property>
-                  <property name="owner" value="@cilium/sig-agent (no-unexpected-packet-drops)"></property>
-                  <property name="owner" value="@cilium/sig-datapath (no-unexpected-packet-drops)"></property>
-                  <property name="owner" value="@cilium/sig-servicemesh (.github/workflows/conformance-kind-proxy-embedded.yaml)"></property>
+                  <property name="owner" value="@cilium/sig-agent"></property>
+                  <property name="owner" value="@cilium/sig-datapath"></property>
               </properties>
               <skipped message="no-unexpected-packet-drops skipped"></skipped>
           </testcase>
           ...

Note that this example only shows the diff for the top of the file; every test case would have the equivalent of the latter hunk applied, dropping the github owners and simplifying the individual owners for the test case.

@joestringer joestringer added the release-note/ci This PR makes changes to the CI. label Apr 17, 2025
@github-actions github-actions bot added cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary labels Apr 17, 2025
@joestringer

This comment was marked as duplicate.

@joestringer
Copy link
Member Author

/test

@joestringer joestringer marked this pull request as ready for review April 18, 2025 03:10
@joestringer joestringer requested review from a team as code owners April 18, 2025 03:10
Wrap the codeowners type up so that the rest of the CLI doesn't need to
import or use the original library. This will be useful as we extend the
type to natively support excluded owners, and it should make it easier
to move more codeowners logic into this package to reduce complexity in
the other CLI packages.

Signed-off-by: Joe Stringer <joe@cilium.io>
Move the code owners exclusions into the codeowners package. Unused for
now, but an upcoming commit will move the main logic into this package
which will make it simpler to adopt this representation.

Signed-off-by: Joe Stringer <joe@cilium.io>
Move the main codeowners logic into the dedicated package. Only minor
changes here for function signatures to allow the package to not worry
about logging internally but instead return owners errors up to the
caller for handling.

Signed-off-by: Joe Stringer <joe@cilium.io>
Signed-off-by: Joe Stringer <joe@cilium.io>
Move the detection and encoding of the GitHub owner up into the
test_suite in order to (a) de-duplicate this ownership reporting and (b)
allow the owner property to be simplified to no longer include the test
name / github workflow in a custom format.

Signed-off-by: Joe Stringer <joe@cilium.io>
There's no need to include the scenario name in the owners field of the
junit, since the parent test is already named in the parent node. Drop it.

However, this _is_ still useful context to keep in the text output to
help inform developers consulting the test logs about which test /
workflow failed or which package emitted an error log. Keep it there.

Signed-off-by: Joe Stringer <joe@cilium.io>
@joestringer joestringer force-pushed the pr/joe/cli-owners-workflows branch from 40e0e64 to f6d38ca Compare April 22, 2025 18:28
@joestringer joestringer requested a review from tklauser April 22, 2025 18:29
@joestringer
Copy link
Member Author

/test

Copy link
Member

@tklauser tklauser left a comment

Choose a reason for hiding this comment

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

Thanks!

@joestringer joestringer enabled auto-merge April 22, 2025 19:25
@joestringer joestringer added this pull request to the merge queue Apr 22, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Apr 22, 2025
Merged via the queue into main with commit 2df93e5 Apr 22, 2025
209 checks passed
@joestringer joestringer deleted the pr/joe/cli-owners-workflows branch April 22, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants