mozilla-taskgraph 3.0.4__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. mozilla_taskgraph-3.1.0/.github/workflows/pre-commit-autoupdate.yml +15 -0
  2. mozilla_taskgraph-3.1.0/.github/workflows/pre-commit.yml +12 -0
  3. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.pre-commit-config.yaml +0 -2
  4. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/CHANGELOG.md +6 -0
  5. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/PKG-INFO +1 -1
  6. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/pyproject.toml +1 -1
  7. mozilla_taskgraph-3.1.0/src/mozilla_taskgraph/util/signed_artifacts.py +19 -0
  8. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/worker_types.py +59 -0
  9. mozilla_taskgraph-3.1.0/test/test_worker_types.py +468 -0
  10. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/uv.lock +1 -1
  11. mozilla_taskgraph-3.0.4/test/test_worker_types.py +0 -318
  12. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.codespell-ignore-words.txt +0 -0
  13. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.github/workflows/pypi-publish.yml +0 -0
  14. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.gitignore +0 -0
  15. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.readthedocs.yml +0 -0
  16. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.taskcluster.yml +0 -0
  17. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/.yamllint +0 -0
  18. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/CODE_OF_CONDUCT.md +0 -0
  19. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/CONTRIBUTING.md +0 -0
  20. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/LICENSE +0 -0
  21. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/Makefile +0 -0
  22. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/README.md +0 -0
  23. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/actions/index.rst +0 -0
  24. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/actions/release-promotion.rst +0 -0
  25. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/conf.py +0 -0
  26. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/index.rst +0 -0
  27. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/transforms/index.rst +0 -0
  28. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/transforms/scriptworker/index.rst +0 -0
  29. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/transforms/scriptworker/release_artifacts.rst +0 -0
  30. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/docs/transforms/scriptworker/ship-it.rst +0 -0
  31. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/__init__.py +0 -0
  32. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/actions/__init__.py +0 -0
  33. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/actions/release_promotion.py +0 -0
  34. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/config.py +0 -0
  35. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/transforms/__init__.py +0 -0
  36. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/transforms/scriptworker/__init__.py +0 -0
  37. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/transforms/scriptworker/release_artifacts.py +0 -0
  38. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/transforms/scriptworker/shipit/__init__.py +0 -0
  39. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/transforms/scriptworker/shipit/mark_as_shipped.py +0 -0
  40. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/src/mozilla_taskgraph/version.py +0 -0
  41. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/config.yml +0 -0
  42. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/docker/fetch/Dockerfile +0 -0
  43. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/docker/fetch/REGISTRY +0 -0
  44. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/docker/python/Dockerfile +0 -0
  45. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/check/kind.yml +0 -0
  46. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/codecov/kind.yml +0 -0
  47. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/docker-image/kind.yml +0 -0
  48. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/fetch/kind.yml +0 -0
  49. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/release-promotion-dummy/kind.yml +0 -0
  50. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/kinds/test/kind.yml +0 -0
  51. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/mt_taskgraph/target_tasks.py +0 -0
  52. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/mt_taskgraph/transforms/test.py +0 -0
  53. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/taskcluster/scripts/codecov-upload.py +0 -0
  54. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/__init__.py +0 -0
  55. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/actions/__init__.py +0 -0
  56. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/actions/test_release_promotion.py +0 -0
  57. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/conftest.py +0 -0
  58. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/data/taskcluster/config.yml +0 -0
  59. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/data/testver.py +0 -0
  60. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/test_register.py +0 -0
  61. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/test_version.py +0 -0
  62. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/transforms/test_scriptworker_release_artifacts.py +0 -0
  63. {mozilla_taskgraph-3.0.4 → mozilla_taskgraph-3.1.0}/test/transforms/test_scriptworker_shipit.py +0 -0
@@ -0,0 +1,15 @@
1
+ name: Autoupdate
2
+ on:
3
+ schedule:
4
+ - cron: '0 0 1 * *'
5
+ jobs:
6
+ pre-commit:
7
+ name: Pre-commit
8
+ runs-on: ubuntu-latest
9
+ permissions:
10
+ contents: write
11
+ pull-requests: write
12
+ steps:
13
+ - uses: mozilla-releng/actions/pre-commit-autoupdate@main
14
+ with:
15
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: "Pre-commit"
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ jobs:
8
+ pre-commit:
9
+ name: Run pre-commit hooks
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: mozilla-releng/actions/pre-commit@main
@@ -2,9 +2,7 @@
2
2
  # See https://pre-commit.com/hooks.html for more hooks
3
3
  ---
4
4
  ci:
5
- autofix_commit_msg: "style: pre-commit.ci auto fixes [...]"
6
5
  autoupdate_commit_msg: "chore: pre-commit autoupdate"
7
- autoupdate_schedule: monthly
8
6
  repos:
9
7
  - repo: https://github.com/pre-commit/pre-commit-hooks
10
8
  rev: v5.0.0
@@ -1,3 +1,9 @@
1
+ ## 3.1.0 (2025-04-25)
2
+
3
+ ### Feat
4
+
5
+ - add a scriptworker-signing payload builder
6
+
1
7
  ## 3.0.4 (2025-04-11)
2
8
 
3
9
  ### Fix
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mozilla-taskgraph
3
- Version: 3.0.4
3
+ Version: 3.1.0
4
4
  Summary: Mozilla specific transforms and utilities for Taskgraph
5
5
  Project-URL: Repository, https://github.com/mozilla-releng/mozilla-taskgraph
6
6
  Project-URL: Issues, https://github.com/mozilla-releng/mozilla-taskgraph/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mozilla-taskgraph"
3
- version = "3.0.4"
3
+ version = "3.1.0"
4
4
  description = "Mozilla specific transforms and utilities for Taskgraph"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -0,0 +1,19 @@
1
+ # This Source Code Form is subject to the terms of the Mozilla Public
2
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
+
5
+
6
+ def get_signed_artifacts(input, formats, behavior=None):
7
+ """
8
+ Get the list of signed artifacts for the given input and formats.
9
+ """
10
+ artifacts = set()
11
+ if input.endswith(".dmg"):
12
+ artifacts.add(input.replace(".dmg", ".tar.gz"))
13
+ else:
14
+ artifacts.add(input)
15
+
16
+ if "gcp_prod_autograph_gpg" in formats:
17
+ artifacts.add(f"{input}.asc")
18
+
19
+ return artifacts
@@ -1,6 +1,8 @@
1
1
  from taskgraph.transforms.task import payload_builder, taskref_or_string
2
2
  from voluptuous import Any, Extra, Optional, Required
3
3
 
4
+ from mozilla_taskgraph.util.signed_artifacts import get_signed_artifacts
5
+
4
6
 
5
7
  @payload_builder(
6
8
  "scriptworker-bitrise",
@@ -125,3 +127,60 @@ def build_shipit_payload(config, task, task_def):
125
127
  worker = task["worker"]
126
128
  task_def["tags"]["worker-implementation"] = "scriptworker"
127
129
  task_def["payload"] = {"release_name": worker["release-name"]}
130
+
131
+
132
+ @payload_builder(
133
+ "scriptworker-signing",
134
+ schema={
135
+ Required("signing-type"): str,
136
+ # list of artifact URLs for the artifacts that should be signed
137
+ Required("upstream-artifacts"): [
138
+ {
139
+ # taskId of the task with the artifact
140
+ Required("taskId"): taskref_or_string,
141
+ # type of signing task (for CoT)
142
+ Required("taskType"): str,
143
+ # Paths to the artifacts to sign
144
+ Required("paths"): [str],
145
+ # Signing formats to use on each of the paths
146
+ Required("formats"): [str],
147
+ # Only For MSI, optional for the signed Installer
148
+ Optional("authenticode_comment"): str,
149
+ }
150
+ ],
151
+ Optional("max-run-time"): int,
152
+ },
153
+ )
154
+ def build_signing_payload(config, task, task_def):
155
+ worker = task["worker"]
156
+
157
+ task_def["payload"] = {
158
+ "upstreamArtifacts": worker["upstream-artifacts"],
159
+ }
160
+ if "max-run-time" in worker:
161
+ task_def["payload"]["maxRunTime"] = worker["max-run-time"]
162
+
163
+ task_def.setdefault("tags", {})["worker-implementation"] = "scriptworker"
164
+
165
+ formats = set()
166
+ for artifacts in worker["upstream-artifacts"]:
167
+ formats.update(artifacts["formats"])
168
+
169
+ scope_prefix = config.graph_config["scriptworker"]["scope-prefix"]
170
+ scopes = set(task_def.get("scopes", []))
171
+ scopes.add(f"{scope_prefix}:signing:cert:{worker['signing-type']}")
172
+ scopes.update({f"{scope_prefix}:signing:format:{format}" for format in formats})
173
+
174
+ task_def["scopes"] = sorted(scopes)
175
+
176
+ # Set release artifacts
177
+ artifacts = set(task.setdefault("attributes", {}).get("release_artifacts", []))
178
+ for upstream_artifact in worker["upstream-artifacts"]:
179
+ for path in upstream_artifact["paths"]:
180
+ artifacts.update(
181
+ get_signed_artifacts(
182
+ input=path,
183
+ formats=upstream_artifact["formats"],
184
+ )
185
+ )
186
+ task["attributes"]["release_artifacts"] = sorted(list(artifacts))
@@ -0,0 +1,468 @@
1
+ import inspect
2
+ from pprint import pprint
3
+ from typing import Dict, Optional, Tuple
4
+
5
+ import pytest
6
+ from taskgraph.transforms.task import payload_builders
7
+ from taskgraph.util.schema import validate_schema
8
+
9
+ import mozilla_taskgraph.worker_types # noqa - trigger payload_builder registration
10
+
11
+
12
+ @pytest.fixture
13
+ def build_payload(make_graph_config, make_transform_config, parameters):
14
+ graph_config = make_graph_config(
15
+ extra_config={"scriptworker": {"scope-prefix": "foo"}}
16
+ )
17
+
18
+ def inner(
19
+ name: str,
20
+ worker: dict,
21
+ extra_params: Optional[Dict] = None,
22
+ raises: Optional[Exception] = None,
23
+ ) -> Optional[Tuple[Dict, Dict]]:
24
+ extra_params = extra_params or {}
25
+
26
+ worker.setdefault("implementation", name)
27
+
28
+ task = {"worker": worker}
29
+ task_def = {"tags": {}}
30
+
31
+ parameters.update(extra_params)
32
+ config = make_transform_config(params=parameters, graph_cfg=graph_config)
33
+
34
+ payload_builder = payload_builders[name]
35
+
36
+ if inspect.isclass(raises) and issubclass(raises, Exception):
37
+ with pytest.raises(raises):
38
+ validate_schema(payload_builder.schema, worker, "schema error")
39
+ payload_builder.builder(config, task, task_def)
40
+ else:
41
+ validate_schema(payload_builder.schema, worker, "schema error")
42
+ payload_builder.builder(config, task, task_def)
43
+
44
+ print("Dumping task_def for copy/paste:")
45
+ pprint(task_def, indent=2)
46
+ return task, task_def
47
+
48
+ return inner
49
+
50
+
51
+ def test_bitrise_missing(build_payload):
52
+ build_payload("scriptworker-bitrise", {}, raises=Exception)
53
+
54
+
55
+ def test_bitrise_missing_app(build_payload):
56
+ build_payload(
57
+ "scriptworker-bitrise", {"bitrise": {"workflows": ["foo"]}}, raises=Exception
58
+ )
59
+
60
+
61
+ def test_bitrise_missing_workflows(build_payload):
62
+ build_payload("scriptworker-bitrise", {"bitrise": {"app": "foo"}}, raises=Exception)
63
+
64
+
65
+ def test_bitrise_invalid_workflow_format(build_payload):
66
+ build_payload(
67
+ "scriptworker-bitrise",
68
+ {"bitrise": {"app": "foo", "workflows": {"err": "nope"}}},
69
+ raises=Exception,
70
+ )
71
+
72
+
73
+ def test_bitrise_invalid_workflow_format2(build_payload):
74
+ build_payload(
75
+ "scriptworker-bitrise",
76
+ {"bitrise": {"app": "foo", "workflows": [{"nope": ["wut"]}]}},
77
+ raises=Exception,
78
+ )
79
+
80
+
81
+ def test_bitrise_invalid_workflow_format3(build_payload):
82
+ build_payload(
83
+ "scriptworker-bitrise",
84
+ {"bitrise": {"app": "foo", "workflows": [{"foo": {"bar": ["oops"]}}]}},
85
+ raises=Exception,
86
+ )
87
+
88
+
89
+ def test_bitrise_default_params(build_payload):
90
+ assert build_payload(
91
+ "scriptworker-bitrise",
92
+ {"bitrise": {"app": "some-app", "workflows": ["bar", "baz"]}},
93
+ )[1] == {
94
+ "payload": {
95
+ "global_params": {
96
+ "branch": "default",
97
+ "branch_repo_owner": "http://example.com/head/repo",
98
+ "commit_hash": "abcdef",
99
+ },
100
+ },
101
+ "scopes": [
102
+ "foo:bitrise:app:some-app",
103
+ "foo:bitrise:workflow:bar",
104
+ "foo:bitrise:workflow:baz",
105
+ ],
106
+ "tags": {"worker-implementation": "scriptworker"},
107
+ }
108
+
109
+
110
+ def test_bitrise_pull_request(build_payload):
111
+ assert build_payload(
112
+ "scriptworker-bitrise",
113
+ {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
114
+ extra_params={
115
+ "tasks_for": "github-pull-request",
116
+ "commit_message": "This is a commit",
117
+ "pull_request_number": "123",
118
+ },
119
+ )[1] == {
120
+ "payload": {
121
+ "global_params": {
122
+ "branch": "default",
123
+ "branch_dest": "123456",
124
+ "branch_dest_repo_owner": "http://example.com/base/repo",
125
+ "branch_repo_owner": "http://example.com/head/repo",
126
+ "commit_hash": "abcdef",
127
+ "pull_request_author": "some-owner",
128
+ "commit_message": "This is a commit",
129
+ "pull_request_id": "123",
130
+ },
131
+ },
132
+ "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
133
+ "tags": {"worker-implementation": "scriptworker"},
134
+ }
135
+
136
+
137
+ def test_bitrise_opposite_params(build_payload):
138
+ assert build_payload(
139
+ "scriptworker-bitrise",
140
+ {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
141
+ extra_params={
142
+ "base_ref": "",
143
+ "base_repository": "",
144
+ "head_ref": "",
145
+ "head_tag": "some-tag",
146
+ "tasks_for": "github-pull-request",
147
+ "commit_message": "This is a commit",
148
+ "pull_request_number": "123",
149
+ },
150
+ )[1] == {
151
+ "payload": {
152
+ "global_params": {
153
+ "branch_repo_owner": "http://example.com/head/repo",
154
+ "commit_hash": "abcdef",
155
+ "pull_request_author": "some-owner",
156
+ "tag": "some-tag",
157
+ "commit_message": "This is a commit",
158
+ "pull_request_id": "123",
159
+ }
160
+ },
161
+ "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
162
+ "tags": {"worker-implementation": "scriptworker"},
163
+ }
164
+
165
+
166
+ def test_bitrise_normalize_refs(build_payload):
167
+ assert build_payload(
168
+ "scriptworker-bitrise",
169
+ {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
170
+ extra_params={
171
+ "base_ref": "refs/heads/foo",
172
+ "base_repository": "",
173
+ "head_ref": "refs/heads/bar",
174
+ "head_tag": "refs/tags/some-tag",
175
+ "tasks_for": "github-pull-request",
176
+ "commit_message": "This is a commit",
177
+ "pull_request_number": "123",
178
+ },
179
+ )[1] == {
180
+ "payload": {
181
+ "global_params": {
182
+ "branch": "bar",
183
+ "branch_dest": "foo",
184
+ "branch_repo_owner": "http://example.com/head/repo",
185
+ "commit_hash": "abcdef",
186
+ "pull_request_author": "some-owner",
187
+ "tag": "some-tag",
188
+ "commit_message": "This is a commit",
189
+ "pull_request_id": "123",
190
+ }
191
+ },
192
+ "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
193
+ "tags": {"worker-implementation": "scriptworker"},
194
+ }
195
+
196
+
197
+ def test_bitrise_normalize_refs_wrong_type(build_payload):
198
+ assert build_payload(
199
+ "scriptworker-bitrise",
200
+ {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
201
+ extra_params={
202
+ "base_ref": "refs/tags/foo",
203
+ "base_repository": "",
204
+ "head_ref": "refs/tags/bar",
205
+ "head_tag": "refs/heads/some-tag",
206
+ "tasks_for": "github-pull-request",
207
+ "commit_message": "This is a commit",
208
+ "pull_request_number": "123",
209
+ },
210
+ )[1] == {
211
+ "payload": {
212
+ "global_params": {
213
+ "branch_repo_owner": "http://example.com/head/repo",
214
+ "commit_hash": "abcdef",
215
+ "pull_request_author": "some-owner",
216
+ "commit_message": "This is a commit",
217
+ "pull_request_id": "123",
218
+ }
219
+ },
220
+ "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
221
+ "tags": {"worker-implementation": "scriptworker"},
222
+ }
223
+
224
+
225
+ def test_bitrise_environments(build_payload):
226
+ assert build_payload(
227
+ "scriptworker-bitrise",
228
+ {
229
+ "bitrise": {
230
+ "app": "some-app",
231
+ "workflows": [
232
+ "foo",
233
+ {
234
+ "bar": [
235
+ {
236
+ "FOO": "bar",
237
+ "PATH": {"artifact-reference": "<build/target.zip>"},
238
+ },
239
+ {
240
+ "FOO": "notbar",
241
+ "PATH": {"artifact-reference": "<build/target.zip>"},
242
+ },
243
+ ]
244
+ },
245
+ {
246
+ "bar": [
247
+ {
248
+ "FOO": "bazzz",
249
+ "PATH": {"artifact-reference": "<build/target.zip>"},
250
+ },
251
+ ]
252
+ },
253
+ ],
254
+ }
255
+ },
256
+ )[1] == {
257
+ "payload": {
258
+ "global_params": {
259
+ "branch": "default",
260
+ "branch_repo_owner": "http://example.com/head/repo",
261
+ "commit_hash": "abcdef",
262
+ },
263
+ "workflow_params": {
264
+ "bar": [
265
+ {
266
+ "environments": [
267
+ {"mapped_to": "FOO", "value": "bar"},
268
+ {
269
+ "mapped_to": "PATH",
270
+ "value": {"artifact-reference": "<build/target.zip>"},
271
+ },
272
+ ]
273
+ },
274
+ {
275
+ "environments": [
276
+ {"mapped_to": "FOO", "value": "notbar"},
277
+ {
278
+ "mapped_to": "PATH",
279
+ "value": {"artifact-reference": "<build/target.zip>"},
280
+ },
281
+ ]
282
+ },
283
+ {
284
+ "environments": [
285
+ {"mapped_to": "FOO", "value": "bazzz"},
286
+ {
287
+ "mapped_to": "PATH",
288
+ "value": {"artifact-reference": "<build/target.zip>"},
289
+ },
290
+ ]
291
+ },
292
+ ]
293
+ },
294
+ },
295
+ "scopes": [
296
+ "foo:bitrise:app:some-app",
297
+ "foo:bitrise:workflow:bar",
298
+ "foo:bitrise:workflow:foo",
299
+ ],
300
+ "tags": {"worker-implementation": "scriptworker"},
301
+ }
302
+
303
+
304
+ def test_bitrise_artifact_prefix(build_payload):
305
+ assert build_payload(
306
+ "scriptworker-bitrise",
307
+ {
308
+ "bitrise": {
309
+ "artifact_prefix": "public",
310
+ "app": "some-app",
311
+ "workflows": ["bar"],
312
+ }
313
+ },
314
+ )[1] == {
315
+ "payload": {
316
+ "artifact_prefix": "public",
317
+ "global_params": {
318
+ "branch": "default",
319
+ "branch_repo_owner": "http://example.com/head/repo",
320
+ "commit_hash": "abcdef",
321
+ },
322
+ },
323
+ "scopes": [
324
+ "foo:bitrise:app:some-app",
325
+ "foo:bitrise:workflow:bar",
326
+ ],
327
+ "tags": {"worker-implementation": "scriptworker"},
328
+ }
329
+
330
+
331
+ def test_build_shipit_payload(build_payload):
332
+ assert build_payload("scriptworker-shipit", {"release-name": "foo"})[1] == {
333
+ "payload": {"release_name": "foo"},
334
+ "tags": {"worker-implementation": "scriptworker"},
335
+ }
336
+
337
+
338
+ def test_build_signing_payload_invalid(build_payload):
339
+ worker = {}
340
+ build_payload("scriptworker-signing", worker=worker, raises=Exception)
341
+
342
+ worker["signing-type"] = "release"
343
+ build_payload("scriptworker-signing", worker=worker, raises=Exception)
344
+
345
+ ua = worker["upstream-artifacts"] = [
346
+ {
347
+ "taskId": "abc",
348
+ "taskType": "build",
349
+ "paths": ["foo/bar", "test.dmg"],
350
+ "formats": ["gpg", "gcp_prod_autograph_gpg"],
351
+ }
352
+ ]
353
+ for key in ("taskId", "taskType", "paths", "formats"):
354
+ val = ua[0].pop(key)
355
+ build_payload("scriptworker-signing", worker=worker, raises=Exception)
356
+ ua[0][key] = val
357
+
358
+
359
+ def test_build_signing_payload_basic(build_payload):
360
+ worker = {
361
+ "signing-type": "release",
362
+ "upstream-artifacts": [
363
+ {
364
+ "taskId": "abc",
365
+ "taskType": "build",
366
+ "paths": ["foo/bar"],
367
+ "formats": ["gpg"],
368
+ }
369
+ ],
370
+ }
371
+ task, task_def = build_payload("scriptworker-signing", worker=worker)
372
+ assert task_def == {
373
+ "payload": {
374
+ "upstreamArtifacts": [
375
+ {
376
+ "formats": ["gpg"],
377
+ "paths": ["foo/bar"],
378
+ "taskId": "abc",
379
+ "taskType": "build",
380
+ }
381
+ ],
382
+ },
383
+ "scopes": [
384
+ "foo:signing:cert:release",
385
+ "foo:signing:format:gpg",
386
+ ],
387
+ "tags": {"worker-implementation": "scriptworker"},
388
+ }
389
+ assert task["attributes"] == {
390
+ "release_artifacts": [
391
+ "foo/bar",
392
+ ]
393
+ }
394
+
395
+
396
+ def test_build_signing_payload_dmg(build_payload):
397
+ worker = {
398
+ "max-run-time": 3600,
399
+ "signing-type": "release",
400
+ "upstream-artifacts": [
401
+ {
402
+ "taskId": "abc",
403
+ "taskType": "build",
404
+ "paths": ["test.dmg"],
405
+ "formats": ["gpg"],
406
+ }
407
+ ],
408
+ }
409
+ task, task_def = build_payload("scriptworker-signing", worker=worker)
410
+ assert task_def == {
411
+ "payload": {
412
+ "maxRunTime": 3600,
413
+ "upstreamArtifacts": [
414
+ {
415
+ "formats": ["gpg"],
416
+ "paths": ["test.dmg"],
417
+ "taskId": "abc",
418
+ "taskType": "build",
419
+ }
420
+ ],
421
+ },
422
+ "scopes": [
423
+ "foo:signing:cert:release",
424
+ "foo:signing:format:gpg",
425
+ ],
426
+ "tags": {"worker-implementation": "scriptworker"},
427
+ }
428
+ assert task["attributes"] == {"release_artifacts": ["test.tar.gz"]}
429
+
430
+
431
+ def test_build_signing_payload_gpg_asc(build_payload):
432
+ worker = {
433
+ "max-run-time": 3600,
434
+ "signing-type": "release",
435
+ "upstream-artifacts": [
436
+ {
437
+ "taskId": "abc",
438
+ "taskType": "build",
439
+ "paths": ["foo/bar"],
440
+ "formats": ["gcp_prod_autograph_gpg"],
441
+ }
442
+ ],
443
+ }
444
+ task, task_def = build_payload("scriptworker-signing", worker=worker)
445
+ assert task_def == {
446
+ "payload": {
447
+ "maxRunTime": 3600,
448
+ "upstreamArtifacts": [
449
+ {
450
+ "formats": ["gcp_prod_autograph_gpg"],
451
+ "paths": ["foo/bar"],
452
+ "taskId": "abc",
453
+ "taskType": "build",
454
+ }
455
+ ],
456
+ },
457
+ "scopes": [
458
+ "foo:signing:cert:release",
459
+ "foo:signing:format:gcp_prod_autograph_gpg",
460
+ ],
461
+ "tags": {"worker-implementation": "scriptworker"},
462
+ }
463
+ assert task["attributes"] == {
464
+ "release_artifacts": [
465
+ "foo/bar",
466
+ "foo/bar.asc",
467
+ ]
468
+ }
@@ -567,7 +567,7 @@ wheels = [
567
567
 
568
568
  [[package]]
569
569
  name = "mozilla-taskgraph"
570
- version = "3.0.3"
570
+ version = "3.1.0"
571
571
  source = { editable = "." }
572
572
  dependencies = [
573
573
  { name = "taskcluster-taskgraph" },
@@ -1,318 +0,0 @@
1
- import inspect
2
- from pprint import pprint
3
-
4
- import pytest
5
- from taskgraph.transforms.task import payload_builders
6
- from taskgraph.util.schema import validate_schema
7
-
8
- from mozilla_taskgraph import worker_types
9
-
10
-
11
- @pytest.mark.parametrize(
12
- "worker,extra_params,expected",
13
- (
14
- pytest.param({}, {}, Exception, id="missing bitrise"),
15
- pytest.param(
16
- {"bitrise": {"workflows": ["foo"]}}, {}, Exception, id="missing app"
17
- ),
18
- pytest.param(
19
- {"bitrise": {"app": "foo"}}, {}, Exception, id="missing workflows"
20
- ),
21
- pytest.param(
22
- {"bitrise": {"app": "foo", "workflows": {"err": "nope"}}},
23
- {},
24
- Exception,
25
- id="wrong workflows format",
26
- ),
27
- pytest.param(
28
- {"bitrise": {"app": "foo", "workflows": [{"nope": ["wut"]}]}},
29
- {},
30
- Exception,
31
- id="wrong workflows format2",
32
- ),
33
- pytest.param(
34
- {"bitrise": {"app": "foo", "workflows": [{"foo": {"bar": ["oops"]}}]}},
35
- {},
36
- Exception,
37
- id="wrong workflows format3",
38
- ),
39
- pytest.param(
40
- {"bitrise": {"app": "some-app", "workflows": ["bar", "baz"]}},
41
- {},
42
- {
43
- "payload": {
44
- "global_params": {
45
- "branch": "default",
46
- "branch_repo_owner": "http://example.com/head/repo",
47
- "commit_hash": "abcdef",
48
- },
49
- },
50
- "scopes": [
51
- "foo:bitrise:app:some-app",
52
- "foo:bitrise:workflow:bar",
53
- "foo:bitrise:workflow:baz",
54
- ],
55
- "tags": {"worker-implementation": "scriptworker"},
56
- },
57
- id="default params",
58
- ),
59
- pytest.param(
60
- {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
61
- {
62
- "tasks_for": "github-pull-request",
63
- "commit_message": "This is a commit",
64
- "pull_request_number": "123",
65
- },
66
- {
67
- "payload": {
68
- "global_params": {
69
- "branch": "default",
70
- "branch_dest": "123456",
71
- "branch_dest_repo_owner": "http://example.com/base/repo",
72
- "branch_repo_owner": "http://example.com/head/repo",
73
- "commit_hash": "abcdef",
74
- "pull_request_author": "some-owner",
75
- "commit_message": "This is a commit",
76
- "pull_request_id": "123",
77
- },
78
- },
79
- "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
80
- "tags": {"worker-implementation": "scriptworker"},
81
- },
82
- id="pull request",
83
- ),
84
- pytest.param(
85
- {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
86
- {
87
- "base_ref": "",
88
- "base_repository": "",
89
- "head_ref": "",
90
- "head_tag": "some-tag",
91
- "tasks_for": "github-pull-request",
92
- "commit_message": "This is a commit",
93
- "pull_request_number": "123",
94
- },
95
- {
96
- "payload": {
97
- "global_params": {
98
- "branch_repo_owner": "http://example.com/head/repo",
99
- "commit_hash": "abcdef",
100
- "pull_request_author": "some-owner",
101
- "tag": "some-tag",
102
- "commit_message": "This is a commit",
103
- "pull_request_id": "123",
104
- }
105
- },
106
- "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
107
- "tags": {"worker-implementation": "scriptworker"},
108
- },
109
- id="opposite params", # this test helps hit other half of if statements
110
- ),
111
- pytest.param(
112
- {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
113
- {
114
- "base_ref": "refs/heads/foo",
115
- "base_repository": "",
116
- "head_ref": "refs/heads/bar",
117
- "head_tag": "refs/tags/some-tag",
118
- "tasks_for": "github-pull-request",
119
- "commit_message": "This is a commit",
120
- "pull_request_number": "123",
121
- },
122
- {
123
- "payload": {
124
- "global_params": {
125
- "branch": "bar",
126
- "branch_dest": "foo",
127
- "branch_repo_owner": "http://example.com/head/repo",
128
- "commit_hash": "abcdef",
129
- "pull_request_author": "some-owner",
130
- "tag": "some-tag",
131
- "commit_message": "This is a commit",
132
- "pull_request_id": "123",
133
- }
134
- },
135
- "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
136
- "tags": {"worker-implementation": "scriptworker"},
137
- },
138
- id="normalize refs",
139
- ),
140
- pytest.param(
141
- {"bitrise": {"app": "some-app", "workflows": ["bar"]}},
142
- {
143
- "base_ref": "refs/tags/foo",
144
- "base_repository": "",
145
- "head_ref": "refs/tags/bar",
146
- "head_tag": "refs/heads/some-tag",
147
- "tasks_for": "github-pull-request",
148
- "commit_message": "This is a commit",
149
- "pull_request_number": "123",
150
- },
151
- {
152
- "payload": {
153
- "global_params": {
154
- "branch_repo_owner": "http://example.com/head/repo",
155
- "commit_hash": "abcdef",
156
- "pull_request_author": "some-owner",
157
- "commit_message": "This is a commit",
158
- "pull_request_id": "123",
159
- }
160
- },
161
- "scopes": ["foo:bitrise:app:some-app", "foo:bitrise:workflow:bar"],
162
- "tags": {"worker-implementation": "scriptworker"},
163
- },
164
- id="normalize refs wrong type",
165
- ),
166
- pytest.param(
167
- {
168
- "bitrise": {
169
- "app": "some-app",
170
- "workflows": [
171
- "foo",
172
- {
173
- "bar": [
174
- {
175
- "FOO": "bar",
176
- "PATH": {
177
- "artifact-reference": "<build/target.zip>"
178
- },
179
- },
180
- {
181
- "FOO": "notbar",
182
- "PATH": {
183
- "artifact-reference": "<build/target.zip>"
184
- },
185
- },
186
- ]
187
- },
188
- {
189
- "bar": [
190
- {
191
- "FOO": "bazzz",
192
- "PATH": {
193
- "artifact-reference": "<build/target.zip>"
194
- },
195
- },
196
- ]
197
- },
198
- ],
199
- }
200
- },
201
- {},
202
- {
203
- "payload": {
204
- "global_params": {
205
- "branch": "default",
206
- "branch_repo_owner": "http://example.com/head/repo",
207
- "commit_hash": "abcdef",
208
- },
209
- "workflow_params": {
210
- "bar": [
211
- {
212
- "environments": [
213
- {"mapped_to": "FOO", "value": "bar"},
214
- {
215
- "mapped_to": "PATH",
216
- "value": {
217
- "artifact-reference": "<build/target.zip>"
218
- },
219
- },
220
- ]
221
- },
222
- {
223
- "environments": [
224
- {"mapped_to": "FOO", "value": "notbar"},
225
- {
226
- "mapped_to": "PATH",
227
- "value": {
228
- "artifact-reference": "<build/target.zip>"
229
- },
230
- },
231
- ]
232
- },
233
- {
234
- "environments": [
235
- {"mapped_to": "FOO", "value": "bazzz"},
236
- {
237
- "mapped_to": "PATH",
238
- "value": {
239
- "artifact-reference": "<build/target.zip>"
240
- },
241
- },
242
- ]
243
- },
244
- ]
245
- },
246
- },
247
- "scopes": [
248
- "foo:bitrise:app:some-app",
249
- "foo:bitrise:workflow:bar",
250
- "foo:bitrise:workflow:foo",
251
- ],
252
- "tags": {"worker-implementation": "scriptworker"},
253
- },
254
- id="environments",
255
- ),
256
- pytest.param(
257
- {
258
- "bitrise": {
259
- "artifact_prefix": "public",
260
- "app": "some-app",
261
- "workflows": ["bar"],
262
- }
263
- },
264
- {},
265
- {
266
- "payload": {
267
- "artifact_prefix": "public",
268
- "global_params": {
269
- "branch": "default",
270
- "branch_repo_owner": "http://example.com/head/repo",
271
- "commit_hash": "abcdef",
272
- },
273
- },
274
- "scopes": [
275
- "foo:bitrise:app:some-app",
276
- "foo:bitrise:workflow:bar",
277
- ],
278
- "tags": {"worker-implementation": "scriptworker"},
279
- },
280
- id="artifact prefix",
281
- ),
282
- ),
283
- )
284
- def test_build_bitrise_payload(
285
- make_graph_config, make_transform_config, parameters, worker, extra_params, expected
286
- ):
287
- schema = payload_builders["scriptworker-bitrise"].schema
288
-
289
- graph_config = make_graph_config(
290
- extra_config={"scriptworker": {"scope-prefix": "foo"}}
291
- )
292
- parameters.update(extra_params)
293
- config = make_transform_config(params=parameters, graph_cfg=graph_config)
294
-
295
- worker.setdefault("implementation", "scriptworker-bitrise")
296
- task = {"worker": worker}
297
- task_def = {"tags": {}}
298
-
299
- if inspect.isclass(expected) and issubclass(expected, Exception):
300
- with pytest.raises(expected):
301
- validate_schema(schema, worker, "schema error")
302
- worker_types.build_bitrise_payload(config, task, task_def)
303
- else:
304
- validate_schema(schema, worker, "schema error")
305
- worker_types.build_bitrise_payload(config, task, task_def)
306
- print("Dumping result:")
307
- pprint(task_def, indent=2)
308
- assert task_def == expected
309
-
310
-
311
- def test_build_shipit_payload():
312
- task = {"worker": {"release-name": "foo"}}
313
- task_def = {"tags": {}}
314
- worker_types.build_shipit_payload(None, task, task_def)
315
- assert task_def == {
316
- "payload": {"release_name": "foo"},
317
- "tags": {"worker-implementation": "scriptworker"},
318
- }