From 426c610e042c345c1d2f7ba78aa70595bda0d587 Mon Sep 17 00:00:00 2001 From: leej3 Date: Thu, 25 Nov 2021 16:07:34 +0000 Subject: [PATCH] make rendering optional --- qhub/render/__init__.py | 4 +++- .../.github/workflows/qhub-ops.yaml | 3 +++ .../template/{{ cookiecutter.repo_directory }}/.gitlab-ci.yml | 2 ++ qhub/utils.py | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/qhub/render/__init__.py b/qhub/render/__init__.py index a5e80c18d..412eb6607 100644 --- a/qhub/render/__init__.py +++ b/qhub/render/__init__.py @@ -10,7 +10,7 @@ from cookiecutter.generate import generate_files from ..version import __version__ from ..constants import TERRAFORM_VERSION -from ..utils import pip_install_qhub, QHUB_GH_BRANCH +from ..utils import pip_install_qhub, QHUB_GH_BRANCH, QHUB_PREVENT_COMMIT_RENDER # existing files and folders to delete when `render_template` is called DELETABLE_PATHS = [ @@ -60,6 +60,8 @@ def patch_versioning_extra_config(config): config["QHUB_GH_BRANCH"] = QHUB_GH_BRANCH + config["QHUB_PREVENT_COMMIT_RENDER"] = QHUB_PREVENT_COMMIT_RENDER + if "terraform_version" not in config: config["terraform_version"] = TERRAFORM_VERSION diff --git a/qhub/template/{{ cookiecutter.repo_directory }}/.github/workflows/qhub-ops.yaml b/qhub/template/{{ cookiecutter.repo_directory }}/.github/workflows/qhub-ops.yaml index 4ac0ec933..5ba85b10a 100644 --- a/qhub/template/{{ cookiecutter.repo_directory }}/.github/workflows/qhub-ops.yaml +++ b/qhub/template/{{ cookiecutter.repo_directory }}/.github/workflows/qhub-ops.yaml @@ -68,6 +68,8 @@ jobs: - name: Deploy Changes made in qhub-config.yaml run: | qhub deploy -c qhub-config.yaml --disable-prompt {% if cookiecutter.QHUB_GH_BRANCH == '' %}--skip-remote-state-provision{% endif %} + +{% if cookiecutter.QHUB_PREVENT_COMMIT_RENDER != 'yes' -%} - name: Push Changes run: | git config user.email "qhub@quansight.com" @@ -78,3 +80,4 @@ jobs: env: COMMIT_MSG: | qhub-config.yaml automated commit: {{ '${{ github.sha }}' }} +{% endif %} diff --git a/qhub/template/{{ cookiecutter.repo_directory }}/.gitlab-ci.yml b/qhub/template/{{ cookiecutter.repo_directory }}/.gitlab-ci.yml index 58f9b6be4..d49ee1ec8 100644 --- a/qhub/template/{{ cookiecutter.repo_directory }}/.gitlab-ci.yml +++ b/qhub/template/{{ cookiecutter.repo_directory }}/.gitlab-ci.yml @@ -21,10 +21,12 @@ render-qhub: - git checkout "{{ cookiecutter.ci_cd.branch }}" - {{ cookiecutter.pip_install_qhub }} - qhub deploy --config qhub-config.yaml --disable-prompt --skip-remote-state-provision +{% if cookiecutter.QHUB_PREVENT_COMMIT_RENDER != 'yes' -%} - git config user.email "qhub@quansight.com" - git config user.name "gitlab ci" - git add . - git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin "{{ cookiecutter.ci_cd.branch }}") +{% endif %} only: refs: - "{{ cookiecutter.ci_cd.branch }}" diff --git a/qhub/utils.py b/qhub/utils.py index 0a8ed9b6b..e6db363ed 100644 --- a/qhub/utils.py +++ b/qhub/utils.py @@ -36,7 +36,7 @@ pip_install_qhub = ( f"pip install https://github.com/Quansight/qhub/archive/{QHUB_GH_BRANCH}.zip" ) - +QHUB_PREVENT_COMMIT_RENDER = os.environ.get("QHUB_PREVENT_COMMIT_RENDER","no") # Regex for suitable project names namestr_regex = r"^[A-Za-z][A-Za-z\-_]*[A-Za-z]$"