diff --git a/.taskcluster.yml b/.taskcluster.yml index db03e69..1d0dc11 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -7,8 +7,17 @@ tasks: - $let: taskgraph: branch: taskgraph - revision: 2b32db7d303dd175ed4c4abf5fcfe00c6c593acd + revision: c78d65237c6ed064b9cbb3cd063b22e9e052a06a + template: + # XXX uncomment to merge + # repo: https://github.com/mozilla-releng/xpi-template + # branch: master + repo: https://github.com/escapewindow/xpi-template + branch: shared-tc-dir trustDomain: xpi + # XXX for private repos, uncomment this line, and comment out the next + # githubCloneSecret: project/xpi/xpi-github-clone-ssh + githubCloneSecret: "" in: $if: 'tasks_for in ["github-pull-request", "github-push", "action", "cron"]' then: @@ -173,12 +182,18 @@ tasks: XPI_HEAD_REF: '${head_branch}' XPI_HEAD_REV: '${head_sha}' XPI_REPOSITORY_TYPE: git + TEMPLATE_BASE_REPOSITORY: '${template.repo}' + TEMPLATE_HEAD_REPOSITORY: '${template.repo}' + TEMPLATE_HEAD_REV: '${template.branch}' + TEMPLATE_HEAD_REF: '${template.branch}' + TEMPLATE_REPOSITORY_TYPE: git TASKGRAPH_BASE_REPOSITORY: https://hg.mozilla.org/ci/taskgraph TASKGRAPH_HEAD_REPOSITORY: https://hg.mozilla.org/ci/${taskgraph.branch} TASKGRAPH_HEAD_REV: '${taskgraph.revision}' TASKGRAPH_REPOSITORY_TYPE: hg - REPOSITORIES: {$json: {xpi: "XPI Manifest", taskgraph: "Taskgraph"}} + REPOSITORIES: {$json: {xpi: "XPI Manifest", taskgraph: "Taskgraph", template: "XPI Template"}} HG_STORE_PATH: /builds/worker/checkouts/hg-store + GITHUB_CLONE_SECRET: '${githubCloneSecret}' - $if: 'tasks_for in ["github-pull-request"]' then: XPI_PULL_REQUEST_NUMBER: '${event.pull_request.number}' @@ -201,6 +216,7 @@ tasks: command: - /usr/local/bin/run-task - '--xpi-checkout=/builds/worker/checkouts/src' + - '--template-checkout=/builds/worker/checkouts/template' - '--taskgraph-checkout=/builds/worker/checkouts/taskgraph' - '--task-cwd=/builds/worker/checkouts/src' - '--' @@ -213,10 +229,14 @@ tasks: then: > PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph && cd /builds/worker/checkouts/src && + rm -rf taskcluster && + ln -s /builds/worker/checkouts/template/taskcluster taskcluster && ln -s /builds/worker/artifacts artifacts && ~/.local/bin/taskgraph action-callback else: > PIP_IGNORE_INSTALLED=0 pip install --user /builds/worker/checkouts/taskgraph && + rm -rf taskcluster && + ln -s /builds/worker/checkouts/template/taskcluster taskcluster && ln -s /builds/worker/artifacts artifacts && ~/.local/bin/taskgraph decision --pushlog-id='0' diff --git a/taskcluster/ci/build/kind.yml b/taskcluster/ci/build/kind.yml index 686d9bf..cfec213 100644 --- a/taskcluster/ci/build/kind.yml +++ b/taskcluster/ci/build/kind.yml @@ -19,6 +19,8 @@ job-defaults: docker-image: indexed: xpi.cache.level-3.docker-images.v2.node-latest.latest run: + checkout: + xpi: {} use-caches: false jobs: diff --git a/taskcluster/ci/config.yml b/taskcluster/ci/config.yml index ad784af..8c86c0b 100644 --- a/taskcluster/ci/config.yml +++ b/taskcluster/ci/config.yml @@ -8,6 +8,16 @@ taskgraph: repositories: xpi: name: "XPI source" + project-regex: '(?!xpi-template)' + template: + name: "XPI template" + project-regex: 'xpi-template' + # XXX + #default-repository: https://github.com/mozilla-extensions/xpi-template + #default-ref: master + default-repository: https://github.com/escapewindow/xpi-template + default-ref: shared-tc-dir + type: git workers: aliases: @@ -16,6 +26,3 @@ workers: implementation: docker-worker os: linux worker-type: 'b-linux' - -# Uncomment if this is a private repo -# github_clone_secret: project/xpi/xpi-github-clone-ssh diff --git a/taskcluster/ci/test/kind.yml b/taskcluster/ci/test/kind.yml index 2577ceb..cd73521 100644 --- a/taskcluster/ci/test/kind.yml +++ b/taskcluster/ci/test/kind.yml @@ -19,6 +19,8 @@ job-defaults: docker-image: indexed: xpi.cache.level-3.docker-images.v2.node-latest.latest run: + checkout: + xpi: {} use-caches: false jobs: diff --git a/taskcluster/xpi_taskgraph/__init__.py b/taskcluster/xpi_taskgraph/__init__.py index f5708a7..2a2a2d4 100644 --- a/taskcluster/xpi_taskgraph/__init__.py +++ b/taskcluster/xpi_taskgraph/__init__.py @@ -12,4 +12,14 @@ def register(graph_config): Import all modules that are siblings of this one, triggering decorators in the process. """ - pass + _import_modules([ + "build", + "cached", + "test", + "xpi_manifest", + ]) + + +def _import_modules(modules): + for module in modules: + import_module(".{}".format(module), package=__name__) diff --git a/taskcluster/xpi_taskgraph/build.py b/taskcluster/xpi_taskgraph/build.py index cce885b..9d754c6 100644 --- a/taskcluster/xpi_taskgraph/build.py +++ b/taskcluster/xpi_taskgraph/build.py @@ -32,12 +32,10 @@ def tasks_from_manifest(config, jobs): task["label"] = "build-{}".format(xpi_config["name"]) env["XPI_NAME"] = xpi_config["name"] task.setdefault("extra", {})["xpi-name"] = xpi_config["name"] - try: - checkout_config["ssh_secret_name"] = config.graph_config[ - "github_clone_secret" - ] + if env.get("GITHUB_CLONE_SECRET", ""): + checkout_config["ssh_secret_name"] = env["GITHUB_CLONE_SECRET"] artifact_prefix = "xpi/build" - except KeyError: + else: artifact_prefix = "public/build" env["ARTIFACT_PREFIX"] = artifact_prefix artifacts = task["worker"].setdefault("artifacts", []) diff --git a/taskcluster/xpi_taskgraph/test.py b/taskcluster/xpi_taskgraph/test.py index 0452f9f..349eed8 100644 --- a/taskcluster/xpi_taskgraph/test.py +++ b/taskcluster/xpi_taskgraph/test.py @@ -41,12 +41,10 @@ def test_tasks_from_manifest(config, jobs): run["cwd"] = "{checkout}" run["command"] = run["command"].format(target=target) task["label"] = "t-{}-{}".format(target, xpi_name) - try: - checkout_config["ssh_secret_name"] = config.graph_config[ - "github_clone_secret" - ] + if env.get("GITHUB_CLONE_SECRET", ""): + checkout_config["ssh_secret_name"] = env["GITHUB_CLONE_SECRET"] artifact_prefix = "xpi/build" - except KeyError: + else: artifact_prefix = "public/build" env["ARTIFACT_PREFIX"] = artifact_prefix yield task