From 8f0d6cf579f39589db958ec6a8b042f533965ccc Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Mon, 3 Mar 2025 09:32:45 -0500 Subject: [PATCH] refactor: remove 'hgmo' template for taskgraph init hg.mozilla.org is being decommissioned and new repos will no longer be created there. Besides, this template never worked and had a bunch of errors in it. --- src/taskgraph/main.py | 6 +- template/cookiecutter.json | 2 +- .../taskcluster.hgmo.yml | 225 ------------------ test/test_main.py | 7 +- 4 files changed, 9 insertions(+), 231 deletions(-) delete mode 100644 template/{{cookiecutter.project_name}}/taskcluster.hgmo.yml diff --git a/src/taskgraph/main.py b/src/taskgraph/main.py index b0acb9078..0c90ab927 100644 --- a/src/taskgraph/main.py +++ b/src/taskgraph/main.py @@ -912,16 +912,14 @@ def init_taskgraph(options): if repo.tool == "git" and "github.com" in repo_url: context["repo_host"] = "github" - elif repo.tool == "hg" and "hg.mozilla.org" in repo_url: - context["repo_host"] = "hgmo" else: print( dedent( """\ Repository not supported! - Taskgraph only supports repositories hosted on Github or hg.mozilla.org. - Ensure you have a remote that points to one of these locations. + The `taskgraph init` command only supports repositories hosted on + Github. Ensure you use a remote that points to a Github repository. """ ), file=sys.stderr, diff --git a/template/cookiecutter.json b/template/cookiecutter.json index e5b8c7252..f60e20b1e 100644 --- a/template/cookiecutter.json +++ b/template/cookiecutter.json @@ -1,7 +1,7 @@ { "project_name": "my-project", "taskgraph_version": "{{ cookiecutter.taskgraph_version }}", - "repo_host": ["github", "hgmo"], + "repo_host": ["github"], "repo_name": "my-repo", "project_slug": "{{ cookiecutter.repo_name.lower().replace(' ', '_').replace('-', '_') }}", "trust_domain": "mozilla", diff --git a/template/{{cookiecutter.project_name}}/taskcluster.hgmo.yml b/template/{{cookiecutter.project_name}}/taskcluster.hgmo.yml deleted file mode 100644 index 6cb467876..000000000 --- a/template/{{cookiecutter.project_name}}/taskcluster.hgmo.yml +++ /dev/null @@ -1,225 +0,0 @@ -# This file is rendered via JSON-e by build-decision: -# https://hg.mozilla.org/ci/ci-configuration/file/tip/build-decision ---- -version: 1 -tasks: - - $let: - trustDomain: "{{cookiecutter.trust_domain}}" - # sometimes the push user is just `ffxbld` or the like, but we want an email-like field.. - ownerEmail: {$if: '"@" in push.owner', then: '${push.owner}', else: '${push.owner}@noreply.mozilla.org'} - project: {$eval: repository.project} - # ensure there's no trailing `/` on the repo URL - repoUrl: {$if: 'repository.url[-1] == "/"', then: {$eval: 'repository.url[:-1]'}, else: {$eval: 'repository.url'}} - in: - $if: 'tasks_for in ["hg-push", "action", "cron"]' - then: - taskId: {$if: 'tasks_for != "action"', then: '${ownTaskId}'} - taskGroupId: - $if: 'tasks_for == "action"' - then: - '${action.taskGroupId}' - else: - '${ownTaskId}' # same as taskId; this is how automation identifies a decision task - schedulerId: '${trustDomain}-level-${repository.level}' - - created: {$fromNow: ''} - deadline: {$fromNow: '1 day'} - expires: {$fromNow: '1 year 1 second'} # 1 second so artifacts expire first, despite rounding errors - metadata: - $merge: - - owner: "${ownerEmail}" - source: "${repoUrl}/raw-file/${push.revision}/.taskcluster.yml" - - $if: 'tasks_for == "hg-push"' - then: - name: "Decision Task" - description: 'The task that creates all of the other tasks in the task graph' - else: - $if: 'tasks_for == "action"' - then: - name: "Action: ${action.title}" - description: '${action.description}' - else: - name: "Decision Task for cron job ${cron.job_name}" - description: 'Created by a [cron task](https://firefox-ci-tc.services.mozilla.com/tasks/${cron.task_id})' - provisionerId: "${trustDomain}-${repository.level}" - workerType: "decision-gcp" - tags: - $if: 'tasks_for == "hg-push"' - then: - createdForUser: "${ownerEmail}" - kind: decision-task - else: - $if: 'tasks_for == "action"' - then: - createdForUser: '${ownerEmail}' - kind: 'action-callback' - else: - $if: 'tasks_for == "cron"' - then: - kind: cron-task - - routes: - $flatten: - - $if: 'tasks_for == "hg-push"' - then: - - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision" - - "index.${trustDomain}.v2.${project}.revision.${push.revision}.taskgraph.decision" - - "index.${trustDomain}.v2.${project}.pushlog-id.${push.pushlog_id}.decision" - else: - $if: 'tasks_for == "action"' - then: - - "index.${trustDomain}.v2.${project}.pushlog-id.${push.pushlog_id}.actions.${ownTaskId}" - else: # cron - - "index.${trustDomain}.v2.${project}.latest.taskgraph.decision-${cron.job_name}" - - scopes: - $if: 'tasks_for == "hg-push"' - then: - - 'assume:repo:${repoUrl[8:]}:branch:default' - else: - $if: 'tasks_for == "action"' - then: - - 'assume:repo:${repoUrl[8:]}:action:${action.action_perm}' - else: - - 'assume:repo:${repoUrl[8:]}:cron:${cron.job_name}' - - dependencies: [] - requires: all-completed - - priority: - # Most times, there is plenty of worker capacity so everything runs - # quickly, but sometimes a storm of action tasks lands. Then we - # want, from highest to lowest: - # - cron tasks (time-sensitive) (low) - # - decision tasks (minimize user-visible delay) (very-low) - # - action tasks (avoid interfering with the other two) (lowest) - # SCM levels all use different workerTypes, so there is no need for priority - # between levels; "low" is the highest priority available at all levels, and - # nothing runs at any higher priority on these workerTypes. - $if: "tasks_for == 'cron'" - then: low - else: - $if: "tasks_for == 'hg-push'" - then: very-low - else: lowest # tasks_for == 'action' - retries: 5 - - payload: - $let: - normProject: - $eval: 'join(split(project, "-"), "_")' - normProjectUpper: - $eval: 'uppercase(join(split(project, "-"), "_"))' - env: - # run-task uses these to check out the source; the inputs - # to `taskgraph decision` are all on the command line. - $merge: - # run-task uses these to check out the source; the inputs to - # `taskgraph decision` are all on the command line. - $merge: - - ${normProjectUpper}_BASE_REPOSITORY: '${baseRepoUrl}' - ${normProjectUpper}_BASE_REF: '${base_ref}' - ${normProjectUpper}_BASE_REV: '${base_sha}' - ${normProjectUpper}_HEAD_REPOSITORY: '${repoUrl}' - ${normProjectUpper}_HEAD_REF: '${head_ref}' - ${normProjectUpper}_HEAD_REV: '${head_sha}' - ${normProjectUpper}_REPOSITORY_TYPE: git - REPOSITORIES: - $json: - ${normProject}: ${normProject} - - $if: 'tasks_for == "action"' - then: - ACTION_TASK_GROUP_ID: '${action.taskGroupId}' # taskGroupId of the target task - ACTION_TASK_ID: {$json: {$eval: 'taskId'}} # taskId of the target task (JSON-encoded) - ACTION_INPUT: {$json: {$eval: 'input'}} - ACTION_CALLBACK: '${action.cb_name}' - - cache: - ${trustDomain}-level-${repository.level}-checkouts-sparse-v2: /builds/worker/checkouts - - features: - taskclusterProxy: true - - image: mozillareleases/taskgraph:decision-v{{ cookiecutter.taskgraph_version }} - - maxRunTime: 1800 - - command: - $flatten: - - /usr/local/bin/run-task - - '--config-checkout=/builds/worker/checkouts/src' - - '--task-cwd=/builds/worker/checkouts/src' - - '--' - - bash - - -cx - - $let: - extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''} - in: - $if: 'tasks_for == "action"' - then: > - cd /builds/worker/checkouts/src && - ln -s /builds/worker/artifacts artifacts && - taskgraph action-callback - else: > - ln -s /builds/worker/artifacts artifacts && - taskgraph decision - --pushlog-id='${push.pushlog_id}' - --pushdate='${push.pushdate}' - --project='${project}' - --message="" - --owner='${ownerEmail}' - --level='${repository.level}' - --base-repository="${repoUrl}" - --head-repository="${repoUrl}" - --head-ref="${push.revision}" - --head-rev="${push.revision}" - --repository-type=hg - --tasks-for='${tasks_for}' - $${TRY_TASK_CONFIG_FILE+--try-task-config-file="$${TRY_TASK_CONFIG_FILE}"} - ${extraArgs} - - artifacts: - 'public': - type: 'directory' - path: '/builds/worker/artifacts' - expires: {$fromNow: '1 year'} - 'public/docker-contexts': - type: 'directory' - path: '/builds/worker/checkouts/src/docker-contexts' - # This needs to be at least the deadline of the - # decision task + the docker-image task deadlines. - # It is set to a week to allow for some time for - # debugging, but they are not useful long-term. - expires: {$fromNow: '7 day'} - - extra: - $merge: - - treeherder: - $merge: - - machine: - platform: gecko-decision - - $if: 'tasks_for == "hg-push"' - then: - symbol: D - else: - $if: 'tasks_for == "action"' - then: - groupName: 'action-callback' - groupSymbol: AC - symbol: "${action.symbol}" - else: - groupSymbol: cron - symbol: "${cron.job_symbol}" - - $if: 'tasks_for == "action"' - then: - parent: '${action.taskGroupId}' - action: - name: '${action.name}' - context: - taskGroupId: '${action.taskGroupId}' - taskId: {$eval: 'taskId'} - input: {$eval: 'input'} - - $if: 'tasks_for == "cron"' - then: - cron: {$json: {$eval: 'cron'}} - - tasks_for: '${tasks_for}' diff --git a/test/test_main.py b/test/test_main.py index 61c435f81..f01a77bd2 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -263,10 +263,15 @@ def test_init_taskgraph(mocker, tmp_path, project_root, repo_with_upstream): oldcwd = Path.cwd() try: os.chdir(repo_root) - taskgraph_main(["init", "--template", str(project_root)]) + ret = taskgraph_main(["init", "--template", str(project_root)]) finally: os.chdir(oldcwd) + if repo.tool == "hg": + assert ret == 1 + assert not (repo_root / ".taskcluster.yml").exists() + return + # Make assertions about the repository state. expected_files = [ ".taskcluster.yml",