From 3e921d2a8d59950f979c19c32030227471ded8c8 Mon Sep 17 00:00:00 2001 From: "Ben Hearsum (he/him)" Date: Fri, 6 Sep 2024 13:53:31 -0400 Subject: [PATCH] restrict github-push taskcluster events to `main` (#777) * restrict github-push taskcluster events to `main`, `release*`, and `dev*` In https://bugzilla.mozilla.org/show_bug.cgi?id=1907217 we're becoming more explicit about scopes we grant to branches in Github, which means branches that do not show up in the explicit list in fxci-config (https://github.com/mozilla-releng/fxci-config/blob/main/projects.yml) will not be able to start tasks. * Update documentation and training helper script to take into account supported branches for Taskcluster --- .taskcluster.yml | 3 ++- docs/task-cluster.md | 4 ++++ utils/train.py | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index e868bcc16..4db625b9e 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -83,7 +83,8 @@ tasks: else: ${head_ref} in: $if: > - tasks_for in ["action", "pr-action", "cron", "github-push"] + tasks_for in ["action", "pr-action", "cron"] + || (tasks_for == "github-push" && (head_branch == "refs/heads/main" || head_branch[:18] == "refs/heads/release" || head_branch[:14] == "refs/heads/dev")) || (isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"]) then: $let: diff --git a/docs/task-cluster.md b/docs/task-cluster.md index 5ca1d8f06..38817b0c6 100644 --- a/docs/task-cluster.md +++ b/docs/task-cluster.md @@ -14,6 +14,10 @@ which increases scalability and observability compared to [Snakemake](snakemake. We use [Taskcluster taskgraph](https://taskcluster-taskgraph.readthedocs.io/en/latest/) to define the DAG (Directly Acyclic Graph) of the pipeline steps. +## Development + +When making changes to Taskcluster parts of the pipeline it is often necessary to run training before opening a pull request with the change. To do this, ensure that you push your change to a branch of `mozilla/firefox-translations-training` that begins with `dev`. (Only pushes to `main`, `dev*`, and `release*` will run Taskcluster tasks.) + ## Running training 1. Create a new branch in your local git repo and push it to `mozilla/firefox-translations-training`. diff --git a/utils/train.py b/utils/train.py index c1b546283..b1c323652 100644 --- a/utils/train.py +++ b/utils/train.py @@ -101,6 +101,11 @@ def main() -> None: ) sys.exit(1) + if branch != "main" and not branch.startswith("dev") and not branch.startswith("release"): + print( + f"Branch must be `main` or start with `dev` or `release` for training to run. Detected branch was {branch}" + ) + timeout = 10 while True: decision_task = get_decision_task_push(branch)