Skip to content

Better taskcluster-gha branching #9

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

Merged
merged 10 commits into from
Mar 1, 2024
12 changes: 7 additions & 5 deletions decisionlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,18 +487,20 @@ def with_ghas(self, actions: List[Tuple[str, gha.GithubAction]], enabled=True):
self.with_gha(name, action, enabled)
return self

def with_gha(self, name: str, gha: gha.GithubAction, branch=None, enabled=True):
def with_gha(self, name: str, gha: gha.GithubAction, enabled=True):
if not enabled:
return self

if gha.git_fetch_url and gha.git_fetch_url not in self.action_paths:
action_path = f"{gha.git_fetch_url}@{gha.branch}"

if gha.git_fetch_url and action_path not in self.action_paths:
self.with_additional_repo(
gha.git_fetch_url,
os.path.join(SHARED.task_root_for(
self.platform()), gha.repo_name),
branch=branch
self.platform()), gha.repo_clone_path),
branch=gha.branch
)
self.action_paths.add(gha.git_fetch_url)
self.action_paths.add(action_path)

if not any(
CONFIG.git_ref == "refs/heads/%s" % branch for branch in DEPLOY_BRANCHES
Expand Down
24 changes: 17 additions & 7 deletions gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class GithubAction:
def __init__(self, path, args, *, run_if=None, npm_install=False, enable_post=True):
def __init__(self, path, args, *, branch=None, run_if=None, npm_install=False, enable_post=True):
"""
Path here is the github path to an actions which is {org}/{repo}/{action_path_in_repo}
Args will all be put in the env as INPUT_{key} = {value}
Expand All @@ -18,6 +18,7 @@ def __init__(self, path, args, *, run_if=None, npm_install=False, enable_post=Tr
self.path = path
self.version = "master"
self.args = {}
self.branch = branch
self.post_path = None
self.run_path = "index.js"
self.parse_config()
Expand Down Expand Up @@ -94,6 +95,13 @@ def action_path(self):

return "/".join(parts[2:])

@property
def repo_clone_path(self):
if not self.branch:
return self.repo_name

return f"{self.repo_name}@{self.branch}"

@property
def git_fetch_url(self):
return f"https://github.com/{self.repo_name}"
Expand All @@ -120,21 +128,23 @@ def task_root(self, platform):

def gen_script(self, platform):
task_root = self.task_root(platform)
repo_path = f"{task_root}{self.repo_clone_path}"

out = ""
if self.npm_install:
out += f"npm install {task_root}{self.repo_name}\n"
self.env["NODE_PATH"] = f"{task_root}{self.repo_name}/node_modules"
return out + f"node {task_root}{self.repo_name}/{self.script_path}"
out += f"npm install {repo_path}\n"
self.env["NODE_PATH"] = f"{repo_path}/node_modules"
return out + f"node {repo_path}/{self.script_path}"

def gen_post_script(self, platform):
task_root = self.task_root(platform)
repo_path = f"{task_root}{self.repo_clone_path}"

out = ""
if self.npm_install:
out += f"npm install {task_root}{self.repo_name}\n"
self.env["NODE_PATH"] = f"{task_root}{self.repo_name}/node_modules"
return out + f"node {task_root}{self.repo_name}/{self.post_script_path}"
out += f"npm install {repo_path}\n"
self.env["NODE_PATH"] = f"{repo_path}/node_modules"
return out + f"node {repo_path}/{self.post_script_path}"

def with_outputs_from(self, task_id):
self.outputs_from.add(task_id)
Expand Down
6 changes: 4 additions & 2 deletions tasks/lang_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ def create_bundle_task(os_name, type_, lang_task_id):
"packages": "pahkat-uploader",
},
),
# TODO: remove branch when done developing
branch="windows-codesign",
)
.with_gha("setup", gha_setup())
.with_gha(
Expand Down Expand Up @@ -231,6 +229,8 @@ def create_bundle_task(os_name, type_, lang_task_id):
GithubAction(
"divvun/taskcluster-gha/codesign",
{ "path": "${{ steps.bundler.outputs['payload-path'] }}" },
# TODO: remove branch when done developing
branch="windows-codesign",
),
)
.with_gha(
Expand All @@ -246,6 +246,8 @@ def create_bundle_task(os_name, type_, lang_task_id):
"repo": "https://pahkat.uit.no/main/",
"nightly-channel": NIGHTLY_CHANNEL,
},
# TODO: remove branch when done developing
branch="windows-codesign",
),
)
.find_or_create(f"bundle.{os_name}_x64_{type_}.{CONFIG.index_path}")
Expand Down