diff --git a/qhub/initialize.py b/qhub/initialize.py index ed505769c5..f35dc30397 100644 --- a/qhub/initialize.py +++ b/qhub/initialize.py @@ -65,7 +65,11 @@ }, } -CICD_CONFIGURATION = {"type": "PLACEHOLDER", "branch": "main"} +CICD_CONFIGURATION = { + "type": "PLACEHOLDER", + "branch": "main", + "commit_render": True, +} AUTH_PASSWORD = { "type": "password", @@ -255,7 +259,8 @@ def render_config( config["provider"] = cloud_provider if ci_provider is not None and ci_provider != "none": - config["ci_cd"] = {"type": ci_provider, "branch": "main"} + config["ci_cd"] = CICD_CONFIGURATION.copy() + config["ci_cd"]["type"] = ci_provider if terraform_state is not None: config["terraform_state"] = {"type": terraform_state} diff --git a/qhub/provider/cicd/github.py b/qhub/provider/cicd/github.py index 8f60ce59c7..94cfb930f9 100644 --- a/qhub/provider/cicd/github.py +++ b/qhub/provider/cicd/github.py @@ -215,6 +215,7 @@ def gen_qhub_ops(config): env_vars = gha_env_vars(config) branch = config["ci_cd"]["branch"] + commit_render = config["ci_cd"]["commit_render"] qhub_version = config["qhub_version"] push = GHA_on_extras(branches=[branch], paths=["qhub-config.yaml"]) @@ -245,9 +246,11 @@ def gen_qhub_ops(config): }, ) - job1 = GHA_job_id( - name="qhub", runs_on_="ubuntu-latest", steps=[step1, step2, step3, step4, step5] - ) + gha_steps = [step1, step2, step3, step4] + if commit_render: + gha_steps.append(step5) + + job1 = GHA_job_id(name="qhub", runs_on_="ubuntu-latest", steps=gha_steps) jobs = GHA_jobs(__root__={"build": job1}) return QhubOps( diff --git a/qhub/provider/cicd/gitlab.py b/qhub/provider/cicd/gitlab.py index c63982a3a4..75a5e444c8 100644 --- a/qhub/provider/cicd/gitlab.py +++ b/qhub/provider/cicd/gitlab.py @@ -41,6 +41,7 @@ class GLCI(BaseModel): def gen_gitlab_ci(config): branch = config["ci_cd"]["branch"] + commit_render = config["ci_cd"]["commit_render"] before_script = config["ci_cd"].get("before_script") after_script = config["ci_cd"].get("after_script") pip_install = pip_install_qhub(config["qhub_version"]) @@ -53,6 +54,9 @@ def gen_gitlab_ci(config): f"git checkout {branch}", f"{pip_install}", "qhub deploy --config qhub-config.yaml --disable-prompt --skip-remote-state-provision", + ] + + commit_render_script = [ "git config user.email 'qhub@quansight.com'", "git config user.name 'gitlab ci'", "git add .", @@ -60,6 +64,9 @@ def gen_gitlab_ci(config): f"git push origin {branch})", ] + if commit_render: + script += commit_render_script + rules = [ GLCI_rules( if_=f"$CI_COMMIT_BRANCH == '{branch}'", diff --git a/qhub/schema.py b/qhub/schema.py index d9c8fceea4..074968d2a3 100644 --- a/qhub/schema.py +++ b/qhub/schema.py @@ -54,6 +54,7 @@ class Config: class CICD(Base): type: CiEnum branch: str + commit_render: typing.Optional[bool] = True before_script: typing.Optional[typing.List[str]] after_script: typing.Optional[typing.List[str]]