From 18a2fdf3e3cd54bbbd2f7f9b858bc7eb60e05b8a Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Mon, 30 Nov 2026 10:56:34 +0100 Subject: [PATCH 1/2] conforma: carry URL and reason for skipped and in-progress runs ConformaViolations.SkippedRuns and InProgressRuns now hold ConformaRunInfo entries with the pipeline run's Konflux UI URL and, for skipped runs, the reason the report was unavailable, instead of bare run names. The list-conforma-violations output adapts accordingly. Co-Authored-By: Claude Code --- .../konflux/list_conforma_violations.go | 28 ++++++++++------ pkg/konflux/conforma.go | 32 +++++++++++++++---- pkg/konflux/conforma_runs.go | 10 +++--- tests/konflux/conforma_violations_test.go | 24 +++++++++++--- 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/cmd/relacs/konflux/list_conforma_violations.go b/cmd/relacs/konflux/list_conforma_violations.go index c8d622a..bdbb890 100644 --- a/cmd/relacs/konflux/list_conforma_violations.go +++ b/cmd/relacs/konflux/list_conforma_violations.go @@ -12,12 +12,12 @@ import ( ) type ConformaViolationsOutput struct { - Organization string `json:"organization" yaml:"organization"` - Repository string `json:"repository" yaml:"repository"` - Tag string `json:"tag" yaml:"tag"` - Violations konflux.Violations `json:"violations" yaml:"violations"` - SkippedRuns []string `json:"skippedRuns" yaml:"skippedRuns"` - InProgressRuns []string `json:"inProgressRuns" yaml:"inProgressRuns"` + Organization string `json:"organization" yaml:"organization"` + Repository string `json:"repository" yaml:"repository"` + Tag string `json:"tag" yaml:"tag"` + Violations konflux.Violations `json:"violations" yaml:"violations"` + SkippedRuns []konflux.ConformaRunInfo `json:"skippedRuns" yaml:"skippedRuns"` + InProgressRuns []konflux.ConformaRunInfo `json:"inProgressRuns" yaml:"inProgressRuns"` } func (c ConformaViolationsOutput) String() string { @@ -34,13 +34,13 @@ func (c ConformaViolationsOutput) String() string { if len(c.InProgressRuns) > 0 { output += fmt.Sprintln("In-progress runs:") for _, run := range c.InProgressRuns { - output += fmt.Sprintf(" - %s\n", run) + output += fmt.Sprintf(" - %s (%s)\n", run.Name, run.URL) } } if len(c.SkippedRuns) > 0 { output += fmt.Sprintln("Skipped runs (no report available):") for _, run := range c.SkippedRuns { - output += fmt.Sprintf(" - %s\n", run) + output += fmt.Sprintf(" - %s: %s\n", run.Name, run.Reason) } } return output @@ -94,10 +94,10 @@ func runListConformaViolations(cmd *cobra.Command, args []string, c *client.Clie // The result is partial: still render the output, but exit non-zero. var reasons []string if len(result.SkippedRuns) > 0 { - reasons = append(reasons, fmt.Sprintf("no conforma report available for %d run(s): %s", len(result.SkippedRuns), strings.Join(result.SkippedRuns, ", "))) + reasons = append(reasons, fmt.Sprintf("no conforma report available for %d run(s): %s", len(result.SkippedRuns), runNames(result.SkippedRuns))) } if len(result.InProgressRuns) > 0 { - reasons = append(reasons, fmt.Sprintf("%d conforma run(s) still in progress: %s", len(result.InProgressRuns), strings.Join(result.InProgressRuns, ", "))) + reasons = append(reasons, fmt.Sprintf("%d conforma run(s) still in progress: %s", len(result.InProgressRuns), runNames(result.InProgressRuns))) } return output, &common.PartialResultError{ Err: fmt.Errorf("%s", strings.Join(reasons, "; ")), @@ -105,3 +105,11 @@ func runListConformaViolations(cmd *cobra.Command, args []string, c *client.Clie } return output, nil } + +func runNames(runs []konflux.ConformaRunInfo) string { + names := make([]string, len(runs)) + for i, run := range runs { + names[i] = run.Name + } + return strings.Join(names, ", ") +} diff --git a/pkg/konflux/conforma.go b/pkg/konflux/conforma.go index 9141b64..a350232 100644 --- a/pkg/konflux/conforma.go +++ b/pkg/konflux/conforma.go @@ -32,12 +32,21 @@ type Violation struct { Violation string `json:"violation"` } +// ConformaRunInfo describes a conforma pipeline run that did not contribute +// to the violations: it is either still in progress or its report could not +// be retrieved or parsed (Reason). +type ConformaRunInfo struct { + Name string `json:"name" yaml:"name"` + URL string `json:"url" yaml:"url"` + Reason string `json:"reason,omitempty" yaml:"reason,omitempty"` +} + // ConformaViolations is the result of listing the conforma violations for a // tag. The result is partial when SkippedRuns or InProgressRuns is non-empty. type ConformaViolations struct { - Violations Violations `json:"violations" yaml:"violations"` - SkippedRuns []string `json:"skippedRuns" yaml:"skippedRuns"` - InProgressRuns []string `json:"inProgressRuns" yaml:"inProgressRuns"` + Violations Violations `json:"violations" yaml:"violations"` + SkippedRuns []ConformaRunInfo `json:"skippedRuns" yaml:"skippedRuns"` + InProgressRuns []ConformaRunInfo `json:"inProgressRuns" yaml:"inProgressRuns"` } // ListConformaViolations returns the violations reported by the conforma @@ -66,7 +75,10 @@ func violationsFromPipelineRuns(ctx context.Context, c *client.Client, pipelineR reportsRead := 0 for _, conformaRun := range conformaRuns { if isPipelineRunInProgress(conformaRun.Status.Conditions) { - result.InProgressRuns = append(result.InProgressRuns, conformaRun.Metadata.Name) + result.InProgressRuns = append(result.InProgressRuns, ConformaRunInfo{ + Name: conformaRun.Metadata.Name, + URL: pipelineRunURL(conformaRun), + }) continue } @@ -74,14 +86,22 @@ func violationsFromPipelineRuns(ctx context.Context, c *client.Client, pipelineR report, err := c.GetKonflux().GetPodLogs(ctx, podName, "step-report-json") if err != nil { fmt.Fprintf(os.Stderr, "WARNING: failed to get report for conforma run %s: %v\n", conformaRun.Metadata.Name, err) - result.SkippedRuns = append(result.SkippedRuns, conformaRun.Metadata.Name) + result.SkippedRuns = append(result.SkippedRuns, ConformaRunInfo{ + Name: conformaRun.Metadata.Name, + URL: pipelineRunURL(conformaRun), + Reason: err.Error(), + }) continue } runViolations, err := parseConformaViolations(report) if err != nil { fmt.Fprintf(os.Stderr, "WARNING: failed to parse conforma report for run %s: %v\n", conformaRun.Metadata.Name, err) - result.SkippedRuns = append(result.SkippedRuns, conformaRun.Metadata.Name) + result.SkippedRuns = append(result.SkippedRuns, ConformaRunInfo{ + Name: conformaRun.Metadata.Name, + URL: pipelineRunURL(conformaRun), + Reason: err.Error(), + }) continue } result.Violations.Violations = append(result.Violations.Violations, runViolations.Violations...) diff --git a/pkg/konflux/conforma_runs.go b/pkg/konflux/conforma_runs.go index 7b3c0fa..7359200 100644 --- a/pkg/konflux/conforma_runs.go +++ b/pkg/konflux/conforma_runs.go @@ -123,19 +123,21 @@ func getConformaPipelineRuns(ctx context.Context, c *client.Client, org, repo, t return conformaRuns, nil } -func convertToConformaRunEntry(plr kflx.PipelineRun) ConformaRunEntry { +func pipelineRunURL(plr kflx.PipelineRun) string { appName := plr.Metadata.Labels["appstudio.openshift.io/application"] + return utils.Application{Name: appName}.GetPipelineRunURL(plr.Metadata.Name) +} + +func convertToConformaRunEntry(plr kflx.PipelineRun) ConformaRunEntry { component := plr.Metadata.Labels["appstudio.openshift.io/component"] scenario := plr.Metadata.Labels["test.appstudio.openshift.io/scenario"] - plrURL := utils.Application{Name: appName}.GetPipelineRunURL(plr.Metadata.Name) - return ConformaRunEntry{ Name: plr.Metadata.Name, Component: component, Scenario: scenario, Status: resolveStatus(plr.Status.Conditions), - URL: plrURL, + URL: pipelineRunURL(plr), } } diff --git a/tests/konflux/conforma_violations_test.go b/tests/konflux/conforma_violations_test.go index 67a04d1..c399b5f 100644 --- a/tests/konflux/conforma_violations_test.go +++ b/tests/konflux/conforma_violations_test.go @@ -8,6 +8,7 @@ import ( "github.com/h2non/gock" "github.com/stackrox/relacs/pkg/config" relacskonflux "github.com/stackrox/relacs/pkg/konflux" + "github.com/stackrox/relacs/pkg/utils" "github.com/stackrox/relacs/tests/helpers" "github.com/stretchr/testify/suite" ) @@ -242,6 +243,15 @@ func (s *ConformaViolationsTestSuite) TestListConformaViolations_InProgress() { s.True(gock.IsDone()) } +// expectedRunInfo returns the expected ConformaRunInfo for a pipeline run +// built by the suite's fixtures, whose application label is "acs-4-10". +func (s *ConformaViolationsTestSuite) expectedRunInfo(name string) relacskonflux.ConformaRunInfo { + return relacskonflux.ConformaRunInfo{ + Name: name, + URL: utils.Application{Name: "acs-4-10"}.GetPipelineRunURL(name), + } +} + func (s *ConformaViolationsTestSuite) TestListConformaViolations_PartialInProgress() { succeeded := s.conformaPipelineRun("acs-conforma-dev-4-10-done", "uid-done", "main-4-10", s.succeededConditions()) running := s.conformaPipelineRun("acs-conforma-dev-4-10-running", "uid-running", "scanner-4-10", nil) @@ -254,7 +264,7 @@ func (s *ConformaViolationsTestSuite) TestListConformaViolations_PartialInProgre s.Len(result.Violations.Violations, 1) s.Equal("violation one", result.Violations.Violations[0].Violation) s.Empty(result.SkippedRuns) - s.Equal([]string{"acs-conforma-dev-4-10-running"}, result.InProgressRuns) + s.Equal([]relacskonflux.ConformaRunInfo{s.expectedRunInfo("acs-conforma-dev-4-10-running")}, result.InProgressRuns) s.True(gock.IsDone()) } @@ -270,8 +280,11 @@ func (s *ConformaViolationsTestSuite) TestListConformaViolations_PartialSkippedA s.Require().NoError(err) s.Len(result.Violations.Violations, 1) - s.Equal([]string{"acs-conforma-dev-4-10-failed"}, result.SkippedRuns) - s.Equal([]string{"acs-conforma-dev-4-10-running"}, result.InProgressRuns) + s.Require().Len(result.SkippedRuns, 1) + s.Equal(s.expectedRunInfo("acs-conforma-dev-4-10-failed").Name, result.SkippedRuns[0].Name) + s.Equal(s.expectedRunInfo("acs-conforma-dev-4-10-failed").URL, result.SkippedRuns[0].URL) + s.NotEmpty(result.SkippedRuns[0].Reason) + s.Equal([]relacskonflux.ConformaRunInfo{s.expectedRunInfo("acs-conforma-dev-4-10-running")}, result.InProgressRuns) s.True(gock.IsDone()) } @@ -301,7 +314,10 @@ func (s *ConformaViolationsTestSuite) TestListConformaViolations_UnparseableRepo s.Require().NoError(err) s.Len(result.Violations.Violations, 1) - s.Equal([]string{"acs-conforma-dev-4-10-empty"}, result.SkippedRuns) + s.Require().Len(result.SkippedRuns, 1) + s.Equal(s.expectedRunInfo("acs-conforma-dev-4-10-empty").Name, result.SkippedRuns[0].Name) + s.Equal(s.expectedRunInfo("acs-conforma-dev-4-10-empty").URL, result.SkippedRuns[0].URL) + s.NotEmpty(result.SkippedRuns[0].Reason) s.Empty(result.InProgressRuns) s.True(gock.IsDone()) } From 7234c874e0853d8391390095094e8335504d2254 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Mon, 30 Nov 2026 10:56:41 +0100 Subject: [PATCH 2/2] conforma: return partial result while every run is in progress ListConformaViolations now errors only when no report could be read because runs were skipped; while every conforma run is still in progress, the partial result is returned with the runs listed in InProgressRuns instead of an error. Co-Authored-By: Claude Code --- pkg/konflux/conforma.go | 11 ++++++----- tests/konflux/conforma_violations_test.go | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/konflux/conforma.go b/pkg/konflux/conforma.go index a350232..8204d8b 100644 --- a/pkg/konflux/conforma.go +++ b/pkg/konflux/conforma.go @@ -52,7 +52,9 @@ type ConformaViolations struct { // ListConformaViolations returns the violations reported by the conforma // pipeline runs for the given tag and scenario. Runs that are still in // progress are listed in InProgressRuns, and runs whose report could not be -// retrieved (e.g. they failed before the report step ran) in SkippedRuns. +// retrieved (e.g. they failed before the report step ran) in SkippedRuns. It +// errors only when no report could be read at all because runs were skipped; +// while every run is still in progress, the partial result is returned. func ListConformaViolations(ctx context.Context, c *client.Client, org, repo, tag, scenario string) (ConformaViolations, error) { pipelineRuns, err := conformaPipelineRunsForScenario(ctx, c, org, repo, tag, scenario) if err != nil { @@ -107,12 +109,11 @@ func violationsFromPipelineRuns(ctx context.Context, c *client.Client, pipelineR result.Violations.Violations = append(result.Violations.Violations, runViolations.Violations...) reportsRead++ } - if reportsRead == 0 { - if len(result.SkippedRuns) == 0 { - return ConformaViolations{}, fmt.Errorf("conforma checks for tag %s are still in progress (%d run(s) running)", tag, len(result.InProgressRuns)) - } + if reportsRead == 0 && len(result.SkippedRuns) > 0 { return ConformaViolations{}, fmt.Errorf("failed to retrieve any conforma report for tag %s (%d run(s) still in progress)", tag, len(result.InProgressRuns)) } + // When every run is still in progress, the result is partial with the + // runs listed in InProgressRuns rather than an error. return result, nil } diff --git a/tests/konflux/conforma_violations_test.go b/tests/konflux/conforma_violations_test.go index c399b5f..17b96ff 100644 --- a/tests/konflux/conforma_violations_test.go +++ b/tests/konflux/conforma_violations_test.go @@ -230,16 +230,17 @@ func (s *ConformaViolationsTestSuite) TestListConformaRuns_ProdLike() { func (s *ConformaViolationsTestSuite) TestListConformaViolations_InProgress() { // Tekton reports a started run as a Succeeded condition with unknown - // status, not as an absent condition. + // status, not as an absent condition. With every run still in progress, + // the partial result is returned instead of an error. started := s.conformaPipelineRun("acs-conforma-dev-4-10-started", "uid-started", "main-4-10", s.startedConditions()) s.mockConformaPipelineRuns(started) result, err := s.listConformaViolations() - s.Require().Error(err) - s.Contains(err.Error(), "still in progress") + s.Require().NoError(err) s.Empty(result.Violations.Violations) s.Empty(result.SkippedRuns) + s.Equal([]relacskonflux.ConformaRunInfo{s.expectedRunInfo("acs-conforma-dev-4-10-started")}, result.InProgressRuns) s.True(gock.IsDone()) }