Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates/fixes for rendering CICD workflows #1086

Merged
merged 9 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions qhub/provider/cicd/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def gha_env_vars(config):

class GHA_on_extras(BaseModel):
branches: List[str]
path: List[str]
paths: List[str]


class GHA_on(BaseModel):
Expand Down Expand Up @@ -171,7 +171,7 @@ class GHA(BaseModel):
name: str
on: GHA_on
env: Optional[Dict[str, str]]
jobs: List[GHA_jobs]
jobs: GHA_jobs


class QhubOps(GHA):
Expand All @@ -193,7 +193,7 @@ def checkout_image_step():
uses="actions/checkout@master",
with_={
"token": GHA_job_steps_extras(
__root__="{{ '${{ secrets.REPOSITORY_ACCESS_TOKEN }}' }}"
__root__="${{ secrets.REPOSITORY_ACCESS_TOKEN }}"
)
},
)
Expand All @@ -217,7 +217,7 @@ def gen_qhub_ops(config):
branch = config["ci_cd"]["branch"]
qhub_version = config["qhub_version"]

push = GHA_on_extras(branches=[branch], path=["qhub-config.yaml"])
push = GHA_on_extras(branches=[branch], paths=["qhub-config.yaml"])
on = GHA_on(__root__={"push": push})

step1 = checkout_image_step()
Expand All @@ -235,20 +235,20 @@ def gen_qhub_ops(config):
"git config user.email 'qhub@quansight.com' ; "
"git config user.name 'github action' ; "
"git add . ; "
"git diff --quiet && git diff --staged --quiet || (git commit -m '${COMMIT_MSG}') ; "
"git diff --quiet && git diff --staged --quiet || (git commit -m '${{ env.COMMIT_MSG }}') ; "
f"git push origin {branch}"
),
env={
"COMMIT_MSG": GHA_job_steps_extras(
__root__="qhub-config.yaml automated commit: {{ '${{ github.sha }}' }}"
__root__="qhub-config.yaml automated commit: ${{ github.sha }}"
)
},
)

job1 = GHA_job_id(
name="qhub", runs_on_="ubuntu-latest", steps=[step1, step2, step3, step4, step5]
)
jobs = [GHA_jobs(__root__={"build": job1})]
jobs = GHA_jobs(__root__={"build": job1})

return QhubOps(
name="qhub auto update",
Expand All @@ -270,20 +270,18 @@ def gen_qhub_linter(config):
branch = config["ci_cd"]["branch"]
qhub_version = config["qhub_version"]

pull_request = GHA_on_extras(branches=[branch], path=["qhub-config.yaml"])
pull_request = GHA_on_extras(branches=[branch], paths=["qhub-config.yaml"])
on = GHA_on(__root__={"pull_request": pull_request})

step1 = checkout_image_step()
step2 = setup_python_step()
step3 = install_qhub_step(qhub_version)

step4_envs = {
"PR_NUMBER": GHA_job_steps_extras(
__root__="{{ '${{ github.event.number }}' }}"
),
"REPO_NAME": GHA_job_steps_extras(__root__="{{ '${{ github.repository }}' }}"),
"PR_NUMBER": GHA_job_steps_extras(__root__="${{ github.event.number }}"),
"REPO_NAME": GHA_job_steps_extras(__root__="${{ github.repository }}"),
"GITHUB_TOKEN": GHA_job_steps_extras(
__root__="{{ '${{ secrets.REPOSITORY_ACCESS_TOKEN }}' }}"
__root__="${{ secrets.REPOSITORY_ACCESS_TOKEN }}"
),
}

Expand All @@ -296,7 +294,11 @@ def gen_qhub_linter(config):
job1 = GHA_job_id(
name="qhub", runs_on_="ubuntu-latest", steps=[step1, step2, step3, step4]
)
jobs = [GHA_jobs(__root__={"qhub-validate": job1})]
jobs = GHA_jobs(
__root__={
"qhub-validate": job1,
}
)

return QhubLinter(
name="qhub linter",
Expand Down
4 changes: 0 additions & 4 deletions qhub/provider/cicd/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ def gen_gitlab_ci(config):
"COMMIT_MSG": "qhub-config.yaml automated commit: {{ '$CI_COMMIT_SHA' }}",
}

# if qhub_gh_branch:
# render_vars["QHUB_GH_BRANCH"] = qhub_gh_branch
# pip_install_qhub = f"pip install https://github.com/Quansight/qhub/archive/{qhub_gh_branch}.zip"

script = [
f"git checkout {branch}",
f"{pip_install}",
Expand Down
2 changes: 1 addition & 1 deletion qhub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def pip_install_qhub(qhub_version: str) -> str:
# dev branches
if len(qhub_version.split(".")) > 3 and qhub_gh_branch:
pip_install = (
f"pip install https://github.com/Quansight/qhub.git@{qhub_gh_branch}"
f"pip install git+https://github.com/Quansight/qhub.git@{qhub_gh_branch}"
)

return pip_install