diff --git a/controllers/integrationpipeline/integrationpipeline_adapter_test.go b/controllers/integrationpipeline/integrationpipeline_adapter_test.go index a648f4f08..8ac5cb05f 100644 --- a/controllers/integrationpipeline/integrationpipeline_adapter_test.go +++ b/controllers/integrationpipeline/integrationpipeline_adapter_test.go @@ -60,7 +60,7 @@ func (r *MockStatusReporter) ReportStatus(client.Client, context.Context, *tekto return r.ReportStatusError } -func (r *MockStatusReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot, *[]gitops.IntegrationTestStatusDetail) error { +func (r *MockStatusReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot) error { r.Called = true return r.ReportStatusError } diff --git a/controllers/statusreport/statusreport_adapter.go b/controllers/statusreport/statusreport_adapter.go index f6116f182..b8d346827 100644 --- a/controllers/statusreport/statusreport_adapter.go +++ b/controllers/statusreport/statusreport_adapter.go @@ -18,11 +18,8 @@ package statusreport import ( "context" - "encoding/json" - "fmt" applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1" - "github.com/redhat-appstudio/integration-service/gitops" "github.com/redhat-appstudio/integration-service/helpers" "github.com/redhat-appstudio/integration-service/status" @@ -65,19 +62,7 @@ func (a *Adapter) EnsureSnapshotTestStatusReported() (controller.OperationResult } for _, reporter := range reporters { - integrationTestStatusDetails, err := getIntegrationScenarioTestStatusFromAnnotation(a.snapshot) - if err != nil { - a.logger.Error(err, "failed to get test status to snapshot annotations for snapshot", - "snapshot.Namespace", a.snapshot.Namespace, "snapshot.Name", a.snapshot.Name) - return controller.RequeueWithError(err) - } - if integrationTestStatusDetails == nil { - a.logger.Info("no snapshot annotation test.appstudio.openshift.io/status defined for snapshot, no need to report integration test status", - "snapshot.Namespace", a.snapshot.Namespace, "snapshot.Name", a.snapshot.Name) - return controller.ContinueProcessing() - } - - if err := reporter.ReportStatusForSnapshot(a.client, a.context, &a.logger, a.snapshot, integrationTestStatusDetails); err != nil { + if err := reporter.ReportStatusForSnapshot(a.client, a.context, &a.logger, a.snapshot); err != nil { a.logger.Error(err, "failed to report test status to github for snapshot", "snapshot.Namespace", a.snapshot.Namespace, "snapshot.Name", a.snapshot.Name) return controller.RequeueWithError(err) @@ -86,19 +71,3 @@ func (a *Adapter) EnsureSnapshotTestStatusReported() (controller.OperationResult return controller.ContinueProcessing() } - -// getIntegrationScenarioTestStatusFromAnnotation get the test status list for all integration test scenarios of snapshot -// then Unmarshal to get structured data, return error if Unmarshal fails -func getIntegrationScenarioTestStatusFromAnnotation(snapshot *applicationapiv1alpha1.Snapshot) (*[]gitops.IntegrationTestStatusDetail, error) { - statusAnnotation, ok := snapshot.GetAnnotations()[gitops.SnapshotTestsStatusAnnotation] - if !ok { - return nil, nil - } - - integrationTestStatusDetails := &[]gitops.IntegrationTestStatusDetail{} - err := json.Unmarshal([]byte(statusAnnotation), integrationTestStatusDetails) - if err != nil { - return nil, fmt.Errorf("failed to load tests statuses from the scenario annotation: %w", err) - } - return integrationTestStatusDetails, nil -} diff --git a/controllers/statusreport/statusreport_adapter_test.go b/controllers/statusreport/statusreport_adapter_test.go index efc502e19..6e55dbf77 100644 --- a/controllers/statusreport/statusreport_adapter_test.go +++ b/controllers/statusreport/statusreport_adapter_test.go @@ -18,6 +18,7 @@ package statusreport import ( "context" + "fmt" "reflect" . "github.com/onsi/ginkgo/v2" @@ -51,7 +52,7 @@ func (r *MockStatusReporter) ReportStatus(client.Client, context.Context, *tekto return r.ReportStatusError } -func (r *MockStatusReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot, *[]gitops.IntegrationTestStatusDetail) error { +func (r *MockStatusReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot) error { r.Called = true return r.ReportStatusError } @@ -104,7 +105,7 @@ var _ = Describe("Snapshot Adapter", Ordered, func() { gitops.PipelineAsCodeInstallationIDAnnotation: "123", "build.appstudio.redhat.com/commit_sha": "6c65b2fcaea3e1a0a92476c8b5dc89e92a85f025", "appstudio.redhat.com/updateComponentOnSuccess": "false", - gitops.SnapshotTestsStatusAnnotation: "[{\"ScenarioName\":\"scenario-1\",\"Status\":\"EnvironmentProvisionError\",\"StartTime\":\"2023-07-26T16:57:49+02:00\",\"CompletionTime\":\"2023-07-26T17:57:49+02:00\",\"Details\":\"Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment\"}]", + gitops.SnapshotTestsStatusAnnotation: "[{\"scenario\":\"scenario-1\",\"status\":\"EnvironmentProvisionError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment\"}]", }, }, Spec: applicationapiv1alpha1.SnapshotSpec{ @@ -159,6 +160,7 @@ var _ = Describe("Snapshot Adapter", Ordered, func() { }, }) result, err := adapter.EnsureSnapshotTestStatusReported() + fmt.Fprintf(GinkgoWriter, "-------err: %v\n", err) Expect(!result.CancelRequest && err == nil).To(BeTrue()) }) }) diff --git a/git/github/github.go b/git/github/github.go index ed2ce36d2..cce30e70d 100644 --- a/git/github/github.go +++ b/git/github/github.go @@ -359,13 +359,13 @@ func (c *Client) GetExistingCheckRun(checkRuns []*ghapi.CheckRun, newCheckRun *C } func (c *Client) IsUpdateNeeded(existingCheckRun *ghapi.CheckRun, newCheckRun *CheckRunAdapter) bool { - if newCheckRun.CompletionTime.After((*existingCheckRun.CompletedAt).Time) { + if newCheckRun.Conclusion != *existingCheckRun.Conclusion { // We need to update the existing checkrun if the completionTime is after the gotten checkrun's CompletionTime - c.logger.Info("found CheckRun with a matching ExternalID and early CompletedAt, so need to update", "ExternalID", newCheckRun.ExternalID) + c.logger.Info("found CheckRun with a matching ExternalID and different Conclusion, so need to update", "ExternalID", newCheckRun.ExternalID) return true } else { // We don't need to update the existing checkrun if the completionTime is not after the gotten checkrun's CompletionTime - c.logger.Info("found CheckRun with a matching ExternalID and CompletedAt, so no need to update", "ExternalID", newCheckRun.ExternalID) + c.logger.Info("found CheckRun with a matching ExternalID and Conclusion, so no need to update", "ExternalID", newCheckRun.ExternalID) return false } } diff --git a/git/github/github_test.go b/git/github/github_test.go index 633312192..a228e3b8d 100644 --- a/git/github/github_test.go +++ b/git/github/github_test.go @@ -55,7 +55,8 @@ func (MockChecksService) ListCheckRunsForRef( ) (*ghapi.ListCheckRunsResults, *ghapi.Response, error) { var id int64 = 20 var externalID string = "example-external-id" - checkRuns := []*ghapi.CheckRun{{ID: &id, ExternalID: &externalID, CompletedAt: &ghapi.Timestamp{Time: time.Now()}}} + conclusion := "failure" + checkRuns := []*ghapi.CheckRun{{ID: &id, ExternalID: &externalID, Conclusion: &conclusion}} total := len(checkRuns) return &ghapi.ListCheckRunsResults{Total: &total, CheckRuns: checkRuns}, nil, nil } @@ -66,7 +67,8 @@ func (MockChecksService) GetAllCheckRunsForRef( ) ([]*ghapi.CheckRun, error) { var id int64 = 20 var externalID string = "example-external-id" - checkRuns := []*ghapi.CheckRun{{ID: &id, ExternalID: &externalID, CompletedAt: &ghapi.Timestamp{Time: time.Now()}}} + conclusion := "failure" + checkRuns := []*ghapi.CheckRun{{ID: &id, ExternalID: &externalID, Conclusion: &conclusion}} return checkRuns, nil } @@ -239,7 +241,7 @@ var _ = Describe("Client", func() { Summary: "example-summary", Text: "example-text", StartTime: time.Now(), - CompletionTime: time.Now().Add(5 * time.Minute), + CompletionTime: time.Now(), } allCheckRuns, err := client.GetAllCheckRunsForRef(context.TODO(), "", "", "", 1) @@ -256,12 +258,12 @@ var _ = Describe("Client", func() { Repository: "example-repo", SHA: "abcdef1", ExternalID: "example-external-id", - Conclusion: "success", + Conclusion: "failure", Title: "example-title", Summary: "example-summary", Text: "example-text", StartTime: time.Now(), - CompletionTime: existingCheckRun.CompletedAt.Time, + CompletionTime: time.Now(), } Expect(client.IsUpdateNeeded(existingCheckRun, checkRunAdapter)).To(BeFalse()) }) diff --git a/gitops/snapshot.go b/gitops/snapshot.go index 16eb49e48..80ff0e601 100644 --- a/gitops/snapshot.go +++ b/gitops/snapshot.go @@ -119,17 +119,17 @@ const ( //AppStudioIntegrationStatusFinished is the reason that's set when the AppStudio tests finish. AppStudioIntegrationStatusFinished = "Finished" - //IntegrationTestStatusQueuedGithub is the status reported to github when integration test is in a queue - IntegrationTestStatusQueuedGithub = "queued" - - //IntegrationTestStatusInProgressGithub is the status reported to github when integration test is in progress - IntegrationTestStatusInProgressGithub = "in_progress" + //IntegrationTestStatusPendingGithub is the status reported to github when integration test is in a queue + IntegrationTestStatusPendingGithub = "pending" //IntegrationTestStatusSuccessGithub is the status reported to github when integration test succeed IntegrationTestStatusSuccessGithub = "success" //IntegrationTestStatusFailureGithub is the status reported to github when integration test fail IntegrationTestStatusFailureGithub = "failure" + + //IntegrationTestStatusErrorGithub is the status reported to github when integration test experience error + IntegrationTestStatusErrorGithub = "error" ) // IntegrationTestScenario test runs status diff --git a/gitops/snapshot_predicate_test.go b/gitops/snapshot_predicate_test.go index 3e63232e8..4d46c1794 100644 --- a/gitops/snapshot_predicate_test.go +++ b/gitops/snapshot_predicate_test.go @@ -99,7 +99,7 @@ var _ = Describe("Predicates", Ordered, func() { gitops.SnapshotComponentLabel: componentName, }, Annotations: map[string]string{ - gitops.SnapshotTestsStatusAnnotation: "[{\"ScenarioName\":\"scenario-1\",\"Status\":\"EnvironmentProvisionError\",\"StartTime\":\"2023-07-26T16:57:49+02:00\",\"CompletionTime\":\"2023-07-26T17:57:49+02:00\",\"Details\":\"Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment\"}]", + gitops.SnapshotTestsStatusAnnotation: "[{\"scenario\":\"scenario-1\",\"status\":\"EnvironmentProvisionError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"sompletionTime\":\"2023-07-26T17:57:49+02:00\",\"details\":\"Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment\"}]", }, }, Spec: applicationapiv1alpha1.SnapshotSpec{ @@ -122,7 +122,7 @@ var _ = Describe("Predicates", Ordered, func() { gitops.SnapshotComponentLabel: componentName, }, Annotations: map[string]string{ - gitops.SnapshotTestsStatusAnnotation: "[{\"ScenarioName\":\"scenario-1\",\"Status\":\"TestPassed\",\"StartTime\":\"2023-07-26T16:57:49+02:00\",\"CompletionTime\":\"2023-07-26T17:57:49+02:00\",\"Details\": \"test pass\"}]", + gitops.SnapshotTestsStatusAnnotation: "[{\"scenario\":\"scenario-1\",\"status\":\"TestPassed\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"details\": \"test pass\"}]", }, }, Spec: applicationapiv1alpha1.SnapshotSpec{ diff --git a/status/reporters.go b/status/reporters.go index f38f28fbd..033b177f0 100644 --- a/status/reporters.go +++ b/status/reporters.go @@ -231,28 +231,34 @@ func (r *GitHubReporter) createCheckRunAdapter(k8sClient client.Client, ctx cont func generateSummary(state gitops.IntegrationTestStatus, snapshotName, scenarioName string) (string, error) { var title string + var statusDesc string = "is unknown" + switch state { case gitops.IntegrationTestStatusPending: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " is pending" + statusDesc = "is pending" case gitops.IntegrationTestStatusInProgress: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " is in progress" + statusDesc = "is in progress" case gitops.IntegrationTestStatusEnvironmentProvisionError: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " experienced error when provisioning environment" + statusDesc = "experienced an error when provisioning environment" case gitops.IntegrationTestStatusDeploymentError: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " experienced error when deploying snapshotEnvironmentBinding" + statusDesc = "experienced an error when deploying snapshotEnvironmentBinding" case gitops.IntegrationTestStatusTestPassed: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " has passed" + statusDesc = "has passed" case gitops.IntegrationTestStatusTestFail: - title = "Integration test for snapshot " + snapshotName + " and scenario " + scenarioName + " has failed" + statusDesc = "has failed" default: return title, fmt.Errorf("unknown status") } + title = fmt.Sprintf("Integration test for snapshot %s and scenario %s %s", snapshotName, scenarioName, statusDesc) + return title, nil } -// generateStateConclusion generate a conclusion as the conclusion of CheckRun or state of CommitStatus -func generateStateConclusion(state gitops.IntegrationTestStatus) (string, error) { +// generateCheckRunConclusion generate a conclusion as the conclusion of CheckRun +// can be Can be one of: action_required, cancelled, failure, neutral, success, skipped, stale, timed_out +// https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run +func generateCheckRunConclusion(state gitops.IntegrationTestStatus) (string, error) { var conclusion string switch state { @@ -260,10 +266,8 @@ func generateStateConclusion(state gitops.IntegrationTestStatus) (string, error) conclusion = gitops.IntegrationTestStatusFailureGithub case gitops.IntegrationTestStatusTestPassed: conclusion = gitops.IntegrationTestStatusSuccessGithub - case gitops.IntegrationTestStatusPending: - conclusion = gitops.IntegrationTestStatusQueuedGithub - case gitops.IntegrationTestStatusInProgress: - conclusion = gitops.IntegrationTestStatusInProgressGithub + case gitops.IntegrationTestStatusPending, gitops.IntegrationTestStatusInProgress: + conclusion = "" default: return conclusion, fmt.Errorf("unknown status") } @@ -271,12 +275,37 @@ func generateStateConclusion(state gitops.IntegrationTestStatus) (string, error) return conclusion, nil } -// createCheckRunAdapterForSnapshot create a CheckRunAdapter for given snapshot, integrationTestStatusDetail, owner, repo and sha +// generateCommitState generate state of CommitStatus +// Can be one of: error, failure, pending, success +// https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status +func generateCommitState(state gitops.IntegrationTestStatus) (string, error) { + var commitState string + + switch state { + case gitops.IntegrationTestStatusTestFail: + commitState = gitops.IntegrationTestStatusFailureGithub + case gitops.IntegrationTestStatusEnvironmentProvisionError, gitops.IntegrationTestStatusDeploymentError: + commitState = gitops.IntegrationTestStatusErrorGithub + case gitops.IntegrationTestStatusTestPassed: + commitState = gitops.IntegrationTestStatusSuccessGithub + case gitops.IntegrationTestStatusPending: + commitState = gitops.IntegrationTestStatusPendingGithub + case gitops.IntegrationTestStatusInProgress: + commitState = "" + default: + return commitState, fmt.Errorf("unknown status") + } + + return commitState, nil +} + +// createCheckRunAdapterForSnapshot create a CheckRunAdapter for given snapshot, integrationTestStatusDetail, owner, repo and sha to create a checkRun +// https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run func (r *GitHubReporter) createCheckRunAdapterForSnapshot(snapshot *applicationapiv1alpha1.Snapshot, integrationTestStatusDetail gitops.IntegrationTestStatusDetail, owner, repo, sha string) (*github.CheckRunAdapter, error) { snapshotName := snapshot.Name scenarioName := integrationTestStatusDetail.ScenarioName - conclusion, err := generateStateConclusion(integrationTestStatusDetail.Status) + conclusion, err := generateCheckRunConclusion(integrationTestStatusDetail.Status) if err != nil { return nil, fmt.Errorf("unknown status %s for integrationTestScenario %s and snapshot %s/%s", integrationTestStatusDetail.Status, scenarioName, snapshot.Namespace, snapshot.Name) } @@ -286,7 +315,7 @@ func (r *GitHubReporter) createCheckRunAdapterForSnapshot(snapshot *applicationa return nil, fmt.Errorf("unknown status %s for integrationTestScenario %s and snapshot %s/%s", integrationTestStatusDetail.Status, scenarioName, snapshot.Namespace, snapshot.Name) } - return &github.CheckRunAdapter{ + cra := &github.CheckRunAdapter{ Owner: owner, Repository: repo, Name: NamePrefix + " / " + snapshotName + " / " + scenarioName, @@ -295,11 +324,19 @@ func (r *GitHubReporter) createCheckRunAdapterForSnapshot(snapshot *applicationa Conclusion: conclusion, Title: conclusion, // This summary will be reworked once PLNSRVCE-1295 is implemented in the future - Summary: summary, - Text: integrationTestStatusDetail.Details, - StartTime: *integrationTestStatusDetail.StartTime, - CompletionTime: *integrationTestStatusDetail.CompletionTime, - }, nil + Summary: summary, + Text: integrationTestStatusDetail.Details, + } + + if start := integrationTestStatusDetail.StartTime; start != nil { + cra.StartTime = *start + } + + if complete := integrationTestStatusDetail.CompletionTime; complete != nil { + cra.CompletionTime = *complete + } + + return cra, nil } func (r *GitHubReporter) createCommitStatus(k8sClient client.Client, ctx context.Context, pipelineRun *tektonv1beta1.PipelineRun) error { @@ -365,12 +402,14 @@ func (r *GitHubReporter) createCommitStatus(k8sClient client.Client, ctx context return nil } +// createCommitStatusAdapterForSnapshot create a commitStatusAdapter used to create commitStatus on GitHub +// https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status func (r *GitHubReporter) createCommitStatusAdapterForSnapshot(snapshot *applicationapiv1alpha1.Snapshot, integrationTestStatusDetail gitops.IntegrationTestStatusDetail, owner, repo, sha string) (*github.CommitStatusAdapter, error) { snapshotName := snapshot.Name scenarioName := integrationTestStatusDetail.ScenarioName statusContext := NamePrefix + " / " + snapshot.Name + " / " + scenarioName - state, err := generateStateConclusion(integrationTestStatusDetail.Status) + state, err := generateCommitState(integrationTestStatusDetail.Status) if err != nil { return nil, fmt.Errorf("unknown status %s for integrationTestScenario %s and snapshot %s/%s", integrationTestStatusDetail.Status, scenarioName, snapshot.Namespace, snapshot.Name) } @@ -517,27 +556,35 @@ func (r *GitHubReporter) ReportStatus(k8sClient client.Client, ctx context.Conte // ReportStatusForSnapshot creates CheckRun when using GitHub App integration. // create a a commit status when using GitHub webhook integration -func (r *GitHubReporter) ReportStatusForSnapshot(k8sClient client.Client, ctx context.Context, logger *helpers.IntegrationLogger, snapshot *applicationapiv1alpha1.Snapshot, details *[]gitops.IntegrationTestStatusDetail) error { +func (r *GitHubReporter) ReportStatusForSnapshot(k8sClient client.Client, ctx context.Context, logger *helpers.IntegrationLogger, snapshot *applicationapiv1alpha1.Snapshot) error { if !metadata.HasLabelWithValue(snapshot, gitops.PipelineAsCodeEventTypeLabel, gitops.PipelineAsCodePullRequestType) { return nil } + statuses, err := gitops.NewSnapshotIntegrationTestStatusesFromSnapshot(snapshot) + if err != nil { + logger.Error(err, "failed to get test status annotations from snapshot", + "snapshot.Namespace", snapshot.Namespace, "snapshot.Name", snapshot.Name) + return err + } + labels := snapshot.GetLabels() owner, found := labels[gitops.PipelineAsCodeURLOrgLabel] if !found { - return fmt.Errorf("snapshot label not found %q", gitops.PipelineAsCodeURLOrgLabel) + return fmt.Errorf("org label not found %q", gitops.PipelineAsCodeURLOrgLabel) } repo, found := labels[gitops.PipelineAsCodeURLRepositoryLabel] if !found { - return fmt.Errorf("snapshot label not found %q", gitops.PipelineAsCodeURLRepositoryLabel) + return fmt.Errorf("repository label not found %q", gitops.PipelineAsCodeURLRepositoryLabel) } sha, found := labels[gitops.PipelineAsCodeSHALabel] if !found { - return fmt.Errorf("snapshot label not found %q", gitops.PipelineAsCodeSHALabel) + return fmt.Errorf("sha label not found %q", gitops.PipelineAsCodeSHALabel) } + integrationTestStatusDetails := statuses.GetStatuses() // Existence of the Pipelines as Code installation ID annotation signals configuration using GitHub App integration. // If it doesn't exist, GitHub webhook integration is configured. if metadata.HasAnnotation(snapshot, gitops.PipelineAsCodeInstallationIDAnnotation) { @@ -564,45 +611,42 @@ func (r *GitHubReporter) ReportStatusForSnapshot(k8sClient client.Client, ctx co return err } - for _, integrationTestStatusDetail := range *details { - // We report the final status of handling a integrationTestScenario only - // such as TestFail, TestPassed, DeploymentError, EnvironmentProvisionError - integrationTestStatusDetail := integrationTestStatusDetail // G601 - if integrationTestStatusDetail.Status == gitops.IntegrationTestStatusEnvironmentProvisionError || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusDeploymentError || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestFail || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestPassed { - checkRun, err := r.createCheckRunAdapterForSnapshot(snapshot, integrationTestStatusDetail, owner, repo, sha) + for _, integrationTestStatusDetail := range integrationTestStatusDetails { + integrationTestStatusDetail := *integrationTestStatusDetail // G601 + checkRun, err := r.createCheckRunAdapterForSnapshot(snapshot, integrationTestStatusDetail, owner, repo, sha) + if err != nil { + logger.Error(err, "failed to create checkRunAdapter for snapshot", + "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name) + return err + } + + existingCheckrun := r.client.GetExistingCheckRun(allCheckRuns, checkRun) + + if existingCheckrun == nil { + logger.Info("creating checkrun for scenario test status of snapshot", + "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName) + _, err = r.client.CreateCheckRun(ctx, checkRun) if err != nil { - logger.Error(err, "failed to create checkRunAdapter for snapshot", - "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name) + logger.Error(err, "failed to create checkrun", + "checkRun", checkRun) return err } - - existingCheckrun := r.client.GetExistingCheckRun(allCheckRuns, checkRun) - - if existingCheckrun == nil { - logger.Info("creating checkrun for scenario test status of snapshot", - "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName) - _, err = r.client.CreateCheckRun(ctx, checkRun) + } else { + if r.client.IsUpdateNeeded(existingCheckrun, checkRun) { + logger.Info("found existing check run with the same ExternalID but old CompletedAt time, updating checkrun for scenario test status of snapshot", + "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName, "checkrun.ExternalID", checkRun.ExternalID) + err = r.client.UpdateCheckRun(ctx, *existingCheckrun.ID, checkRun) if err != nil { - logger.Error(err, "failed to create checkrun", + logger.Error(err, "failed to update checkrun", "checkRun", checkRun) return err } } else { - if r.client.IsUpdateNeeded(existingCheckrun, checkRun) { - logger.Info("found existing check run with the same ExternalID but old CompletedAt time, updating checkrun for scenario test status of snapshot", - "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName, "checkrun.ExternalID", checkRun.ExternalID) - err = r.client.UpdateCheckRun(ctx, *existingCheckrun.ID, checkRun) - if err != nil { - logger.Error(err, "failed to update checkrun", - "checkRun", checkRun) - return err - } - } else { - logger.Info("found existing check run with the same ExternalID and CompletedAt time, no need to update checkrun for scenario test status of snapshot", - "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName, "checkrun.ExternalID", checkRun.ExternalID) - } + logger.Info("found existing check run with the same ExternalID and CompletedAt time, no need to update checkrun for scenario test status of snapshot", + "snapshot.NameSpace", snapshot.Namespace, "snapshot.Name", snapshot.Name, "scenarioName", integrationTestStatusDetail.ScenarioName, "checkrun.ExternalID", checkRun.ExternalID) } } + // } } } else { token, err := r.getToken(ctx, snapshot, snapshot.Namespace) @@ -621,9 +665,12 @@ func (r *GitHubReporter) ReportStatusForSnapshot(k8sClient client.Client, ctx co return err } - for _, integrationTestStatusDetail := range *details { - integrationTestStatusDetail := integrationTestStatusDetail //G601 - if integrationTestStatusDetail.Status == gitops.IntegrationTestStatusEnvironmentProvisionError || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusDeploymentError || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestFail || integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestPassed { + for _, integrationTestStatusDetail := range integrationTestStatusDetails { + integrationTestStatusDetail := *integrationTestStatusDetail //G601 + if integrationTestStatusDetail.Status == gitops.IntegrationTestStatusEnvironmentProvisionError || + integrationTestStatusDetail.Status == gitops.IntegrationTestStatusDeploymentError || + integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestFail || + integrationTestStatusDetail.Status == gitops.IntegrationTestStatusTestPassed { commitStatus, err := r.createCommitStatusAdapterForSnapshot(snapshot, integrationTestStatusDetail, owner, repo, sha) if err != nil { logger.Error(err, "failed to create CommitStatusAdapter for snapshot", diff --git a/status/reporters_test.go b/status/reporters_test.go index 1e26fc4a0..0b5021827 100644 --- a/status/reporters_test.go +++ b/status/reporters_test.go @@ -239,7 +239,6 @@ var _ = Describe("GitHubReporter", func() { var failedTaskRun *tektonv1beta1.TaskRun var skippedTaskRun *tektonv1beta1.TaskRun var hasSnapshot *applicationapiv1alpha1.Snapshot - var integrationTestStatusDetails *[]gitops.IntegrationTestStatusDetail var logger helpers.IntegrationLogger BeforeEach(func() { @@ -409,24 +408,6 @@ var _ = Describe("GitHubReporter", func() { }, }, } - - time := time.Now().UTC() - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusInProgress, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - { - ScenarioName: "scenario2", - Status: gitops.IntegrationTestStatusEnvironmentProvisionError, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } }) Context("when provided GitHub app credentials", func() { @@ -468,7 +449,7 @@ var _ = Describe("GitHubReporter", func() { delete(pipelineRun.Labels, "pac.test.appstudio.openshift.io/event-type") Expect(reporter.ReportStatus(mockK8sClient, context.TODO(), pipelineRun)).To(BeNil()) delete(hasSnapshot.Labels, "pac.test.appstudio.openshift.io/event-type") - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) }) It("doesn't report status when the credentials are invalid/missing", func() { @@ -479,7 +460,7 @@ var _ = Describe("GitHubReporter", func() { pipelineRun.Annotations["pac.test.appstudio.openshift.io/installation-id"] = "123" hasSnapshot.Annotations["pac.test.appstudio.openshift.io/installation-id"] = "bad-installation-id" - err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails) + err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot) Expect(err).ToNot(BeNil()) hasSnapshot.Annotations["pac.test.appstudio.openshift.io/installation-id"] = "123" @@ -487,7 +468,7 @@ var _ = Describe("GitHubReporter", func() { secretData["github-application-id"] = []byte("bad-app-id") err = reporter.ReportStatus(mockK8sClient, context.TODO(), pipelineRun) Expect(err).ToNot(BeNil()) - err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails) + err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot) Expect(err).ToNot(BeNil()) secretData["github-application-id"] = []byte("456") @@ -495,7 +476,7 @@ var _ = Describe("GitHubReporter", func() { delete(secretData, "github-application-id") err = reporter.ReportStatus(mockK8sClient, context.TODO(), pipelineRun) Expect(err).ToNot(BeNil()) - err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails) + err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot) Expect(err).ToNot(BeNil()) secretData["github-application-id"] = []byte("456") @@ -503,7 +484,7 @@ var _ = Describe("GitHubReporter", func() { delete(secretData, "github-private-key") err = reporter.ReportStatus(mockK8sClient, context.TODO(), pipelineRun) Expect(err).ToNot(BeNil()) - err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails) + err = reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot) Expect(err).ToNot(BeNil()) }) @@ -539,72 +520,44 @@ var _ = Describe("GitHubReporter", func() { }) It("reports snapshot tests status via CheckRuns", func() { - // Create an in progress CheckRun - time := time.Now().UTC() - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusEnvironmentProvisionError, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) - Expect(mockGitHubClient.CreateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced error when provisioning environment")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.Conclusion).To(Equal(gitops.IntegrationTestStatusFailureGithub)) - Expect(mockGitHubClient.CreateCheckRunResult.cra.ExternalID).To(Equal("scenario1")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.Owner).To(Equal("devfile-sample")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.Repository).To(Equal("devfile-sample-go-basic")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.SHA).To(Equal("12a4a35ccd08194595179815e4646c3a6c08bb77")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.Name).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) - Expect(mockGitHubClient.CreateCheckRunResult.cra.StartTime.IsZero()).To(BeFalse()) - Expect(mockGitHubClient.CreateCheckRunResult.cra.CompletionTime.IsZero()).To(BeFalse()) + // Create an pending CheckRun + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"Pending\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"pending\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) + Expect(mockGitHubClient.CreateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 is pending")) + Expect(mockGitHubClient.CreateCheckRunResult.cra.Conclusion).To(Equal("")) - // Update existing CheckRun w/failure + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"EnvironmentProvisionError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"Failed to find deploymentTargetClass with right provisioner for copy of existingEnvironment\"}]" var id int64 = 1 var externalID string = "example-external-id" - mockGitHubClient.GetCheckRunResult.cr = &ghapi.CheckRun{ID: &id, ExternalID: &externalID} - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusDeploymentError, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) - Expect(mockGitHubClient.UpdateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced error when deploying snapshotEnvironmentBinding")) + conclusion := "" + mockGitHubClient.GetCheckRunResult.cr = &ghapi.CheckRun{ID: &id, ExternalID: &externalID, Conclusion: &conclusion} + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced an error when provisioning environment")) Expect(mockGitHubClient.UpdateCheckRunResult.cra.Conclusion).To(Equal(gitops.IntegrationTestStatusFailureGithub)) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.ExternalID).To(Equal("scenario1")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Owner).To(Equal("devfile-sample")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Repository).To(Equal("devfile-sample-go-basic")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.SHA).To(Equal("12a4a35ccd08194595179815e4646c3a6c08bb77")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Name).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.StartTime.IsZero()).To(BeFalse()) Expect(mockGitHubClient.UpdateCheckRunResult.cra.CompletionTime.IsZero()).To(BeFalse()) - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusTestFail, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) + // Update existing CheckRun w/failure + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"DeploymentError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"error\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced an error when deploying snapshotEnvironmentBinding")) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.Conclusion).To(Equal(gitops.IntegrationTestStatusFailureGithub)) + Expect(mockGitHubClient.UpdateCheckRunResult.cra.CompletionTime.IsZero()).To(BeFalse()) + + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"TestFail\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"failed\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) Expect(mockGitHubClient.UpdateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 has failed")) Expect(mockGitHubClient.UpdateCheckRunResult.cra.Conclusion).To(Equal(gitops.IntegrationTestStatusFailureGithub)) Expect(mockGitHubClient.UpdateCheckRunResult.cra.CompletionTime.IsZero()).To(BeFalse()) // Update existing CheckRun w/success - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusTestPassed, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - setPipelineRunOutcome(pipelineRun, failedTaskRun) - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"TestPassed\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"failed\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) Expect(mockGitHubClient.UpdateCheckRunResult.cra.Summary).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 has passed")) Expect(mockGitHubClient.UpdateCheckRunResult.cra.Conclusion).To(Equal(gitops.IntegrationTestStatusSuccessGithub)) }) @@ -717,62 +670,29 @@ var _ = Describe("GitHubReporter", func() { It("creates a commit status for snapshot", func() { // Error - time := time.Now().UTC() - integrationTestStatusDetails := &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusEnvironmentProvisionError, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"EnvironmentProvisionError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"failed\"}]" - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) - Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusFailureGithub)) - Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced error when provisioning environment")) + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) + Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusErrorGithub)) + Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced an error when provisioning environment")) Expect(mockGitHubClient.CreateCommitStatusResult.statusContext).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusDeploymentError, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) - Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusFailureGithub)) - Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced error when deploying snapshotEnvironmentBinding")) + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"DeploymentError\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"failed\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) + Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusErrorGithub)) + Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 experienced an error when deploying snapshotEnvironmentBinding")) Expect(mockGitHubClient.CreateCommitStatusResult.statusContext).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) // Success - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusTestPassed, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"TestPassed\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"passed\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusSuccessGithub)) Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 has passed")) Expect(mockGitHubClient.CreateCommitStatusResult.statusContext).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) // Failure - integrationTestStatusDetails = &[]gitops.IntegrationTestStatusDetail{ - { - ScenarioName: "scenario1", - Status: gitops.IntegrationTestStatusTestFail, - StartTime: &time, - CompletionTime: &time, - Details: "details", - }, - } - Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot, integrationTestStatusDetails)).To(BeNil()) + hasSnapshot.Annotations["test.appstudio.openshift.io/status"] = "[{\"scenario\":\"scenario1\",\"status\":\"TestFail\",\"startTime\":\"2023-07-26T16:57:49+02:00\",\"completionTime\":\"2023-07-26T17:57:49+02:00\",\"lastUpdateTime\":\"2023-08-26T17:57:49+02:00\",\"details\":\"passed\"}]" + Expect(reporter.ReportStatusForSnapshot(mockK8sClient, context.TODO(), &logger, hasSnapshot)).To(BeNil()) Expect(mockGitHubClient.CreateCommitStatusResult.state).To(Equal(gitops.IntegrationTestStatusFailureGithub)) Expect(mockGitHubClient.CreateCommitStatusResult.description).To(Equal("Integration test for snapshot snapshot-sample and scenario scenario1 has failed")) Expect(mockGitHubClient.CreateCommitStatusResult.statusContext).To(Equal("Red Hat Trusted App Test / snapshot-sample / scenario1")) diff --git a/status/status.go b/status/status.go index 8c3119971..c88791358 100644 --- a/status/status.go +++ b/status/status.go @@ -18,7 +18,7 @@ const NamePrefix = "Red Hat Trusted App Test" // Reporter is a generic interface all status implementations must follow. type Reporter interface { ReportStatus(client.Client, context.Context, *tektonv1beta1.PipelineRun) error - ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot, *[]gitops.IntegrationTestStatusDetail) error + ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot) error } // Status is the interface of the main status Adapter. diff --git a/status/status_test.go b/status/status_test.go index 5964b1010..e0df8767b 100644 --- a/status/status_test.go +++ b/status/status_test.go @@ -6,7 +6,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1" - "github.com/redhat-appstudio/integration-service/gitops" "github.com/redhat-appstudio/integration-service/helpers" "github.com/redhat-appstudio/integration-service/status" @@ -22,7 +21,7 @@ func (r *MockReporter) ReportStatus(client.Client, context.Context, *tektonv1bet return nil } -func (r *MockReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot, *[]gitops.IntegrationTestStatusDetail) error { +func (r *MockReporter) ReportStatusForSnapshot(client.Client, context.Context, *helpers.IntegrationLogger, *applicationapiv1alpha1.Snapshot) error { return nil }