diff --git a/decisionlib.py b/decisionlib.py index 9502c30..0b55d8d 100644 --- a/decisionlib.py +++ b/decisionlib.py @@ -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 diff --git a/gha.py b/gha.py index 9d2b8e3..ce5f759 100644 --- a/gha.py +++ b/gha.py @@ -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} @@ -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() @@ -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}" @@ -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) diff --git a/tasks/lang_task.py b/tasks/lang_task.py index 5bc5fe5..f5a42a1 100644 --- a/tasks/lang_task.py +++ b/tasks/lang_task.py @@ -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( @@ -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( @@ -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}")