diff --git a/magefiles/magefile.go b/magefiles/magefile.go index 17c92f99e..4f7d59060 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -303,7 +303,7 @@ func (ci CI) TestE2E() error { } // Eventually we'll introduce mage rules for all repositories, so this condition won't be needed anymore - if pr.RepoName == "e2e-tests" || pr.RepoName == "integration-service" { + if pr.RepoName == "e2e-tests" || pr.RepoName == "integration-service" || pr.RepoName == "release-service" { return engine.MageEngine.RunRulesOfCategory("ci", rctx) } diff --git a/magefiles/rulesengine/engine/engine.go b/magefiles/rulesengine/engine/engine.go index 75fe8a69e..61b00b92f 100644 --- a/magefiles/rulesengine/engine/engine.go +++ b/magefiles/rulesengine/engine/engine.go @@ -17,6 +17,7 @@ var MageEngine = rulesengine.RuleEngine{ "ci": { "e2e-repo": repos.E2ECIChainCatalog, + "release-service": repos.ReleaseServiceCICatalog, "integration-service": repos.IntegrationServiceCICatalog, // TODO: to be implemented in a follow-up PR //"infra-deployments": repos.InfraDeploymentsCIChainCatalog, diff --git a/magefiles/rulesengine/repos/release_service.go b/magefiles/rulesengine/repos/release_service.go new file mode 100644 index 000000000..2383df663 --- /dev/null +++ b/magefiles/rulesengine/repos/release_service.go @@ -0,0 +1,53 @@ +package repos + +import ( + "fmt" + "os" + + "github.com/konflux-ci/e2e-tests/magefiles/rulesengine" + "k8s.io/klog" +) + +var ReleaseServiceCICatalog = rulesengine.RuleCatalog{ReleaseServiceCIRule} + +var ReleaseServiceCIRule = rulesengine.Rule{Name: "Release-service repo CI Workflow Rule", + Description: "Execute the full workflow for release-service repo in CI", + Condition: rulesengine.All{ + &ReleaseServiceRepoSetDefaultSettingsRule, + rulesengine.Any{&InfraDeploymentsPRPairingRule, rulesengine.None{&InfraDeploymentsPRPairingRule}}, + &PreflightInstallGinkgoRule, + &InstallKonfluxRule, + }, + Actions: []rulesengine.Action{rulesengine.ActionFunc(ExecuteTestAction)}, +} + +var ReleaseServiceRepoSetDefaultSettingsRule = rulesengine.Rule{Name: "General Required Settings for release-service repository jobs", + Description: "relese-service jobs default rule", + Condition: rulesengine.Any{ + IsReleaseServiceRepoPR, + }, + Actions: []rulesengine.Action{rulesengine.ActionFunc(func(rctx *rulesengine.RuleCtx) error { + rctx.LabelFilter = "release-service" + klog.Info("setting 'release-service' test label") + + if rctx.DryRun { + klog.Info("setting up env vars for deploying component image") + return nil + } + rctx.ComponentEnvVarPrefix = "RELEASE_SERVICE" + // TODO keep only "KONFLUX_CI" option once we migrate off openshift-ci + if os.Getenv("KONFLUX_CI") == "true" { + rctx.ComponentImageTag = fmt.Sprintf("on-pr-%s", rctx.PrCommitSha) + } else { + rctx.ComponentImageTag = "redhat-appstudio-release-service-image" + } + //This is env variable is specified for release service + os.Setenv(fmt.Sprintf("%s_CATALOG_REVISION", rctx.ComponentEnvVarPrefix), "development") + return SetEnvVarsForComponentImageDeployment(rctx) + })}, +} + +var IsReleaseServiceRepoPR = rulesengine.ConditionFunc(func(rctx *rulesengine.RuleCtx) (bool, error) { + klog.Info("checking if repository is release-service") + return rctx.RepoName == "release-service", nil +})