Skip to content

Commit

Permalink
feat(RELEASE-1172): add a mage engine rule for release-service
Browse files Browse the repository at this point in the history
Signed-off-by: Jing Qi <[email protected]>
  • Loading branch information
jinqi7 committed Sep 18, 2024
1 parent de036c7 commit 25404e2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions magefiles/rulesengine/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
54 changes: 54 additions & 0 deletions magefiles/rulesengine/repos/release_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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,
//&BootstrapClusterWithSprayProxyRuleChain,
&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")

Check warning

Code scanning / gosec

Errors unhandled. Warning

Errors unhandled.
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
})

0 comments on commit 25404e2

Please sign in to comment.