Skip to content

Commit 764816a

Browse files
authored
bug 1594621 - add cot_product_type map (#454)
* fix cot verify for adhoc * cot_product_type * add coverage * 34.1.0
1 parent 876f14c commit 764816a

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

HISTORY.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ Change Log
44
All notable changes to this project will be documented in this file.
55
This project adheres to `Semantic Versioning <http://semver.org/>`__.
66

7+
[34.1.0] - 2020-05-04
8+
---------------------
9+
10+
Added
11+
~~~~~
12+
- added ``cot_product_type``
13+
14+
Changed
15+
~~~~~~~
16+
- ``populate_jsone_context`` now checks ``cot_product_type`` instead of allowlisting a set of ``cot_products`` as github
17+
18+
Changed
19+
~~~~~~~
20+
- ``check_interactive_docker_worker`` now raises ``CoTError`` on errors, rather
21+
than returning the list of error messages
22+
- ``check_interactive_docker_worker`` now also runs against the chain task, if it's
23+
docker-worker
24+
725
[34.0.0] - 2020-04-17
826
---------------------
927

src/scriptworker/constants.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@
111111
"scriptworker_provisioners": ("scriptworker-prov-v1", "scriptworker-k8s"),
112112
# valid hash algorithms for chain of trust artifacts
113113
"valid_hash_algorithms": ("sha256", "sha512"),
114+
"cot_product_type": immutabledict(
115+
{
116+
"by-cot-product": immutabledict(
117+
{
118+
"firefox": "hg",
119+
"thunderbird": "hg",
120+
"mobile": "github",
121+
"mpd001": "github",
122+
"application-services": "github",
123+
"xpi": "github",
124+
"adhoc": "github",
125+
"scriptworker": "github",
126+
},
127+
),
128+
},
129+
),
114130
# decision task cot
115131
"valid_decision_worker_pools": immutabledict(
116132
{

src/scriptworker/cot/verify.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
12391239
"taskId": None,
12401240
}
12411241

1242-
if chain.context.config["cot_product"] in ("mobile", "mpd001", "application-services", "xpi"):
1242+
if chain.context.config["cot_product_type"] == "github":
12431243
if tasks_for == "github-release":
12441244
jsone_context.update(await _get_additional_github_releases_jsone_context(decision_link))
12451245
elif tasks_for == "cron":
@@ -1251,8 +1251,8 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
12511251
elif tasks_for == "github-push":
12521252
jsone_context.update(await _get_additional_github_push_jsone_context(decision_link))
12531253
else:
1254-
raise CoTError('Unknown tasks_for "{}" for cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
1255-
else:
1254+
raise CoTError('Unknown tasks_for "{}" for github cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
1255+
elif chain.context.config["cot_product_type"] == "hg":
12561256
source_url = get_source_url(decision_link)
12571257
project = await get_project(chain.context, source_url)
12581258
jsone_context["repository"] = {
@@ -1268,7 +1268,11 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
12681268
elif tasks_for == "cron":
12691269
jsone_context.update(await _get_additional_hg_cron_jsone_context(parent_link, decision_link))
12701270
else:
1271-
raise CoTError("Unknown tasks_for {}!".format(tasks_for))
1271+
raise CoTError('Unknown tasks_for "{}" for hg cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
1272+
else:
1273+
raise CoTError(
1274+
'Unknown cot_product_type "{}" for cot_product "{}"!'.format(chain.context.config["cot_product_type"], chain.context.config["cot_product"])
1275+
)
12721276

12731277
log.debug("{} json-e context:".format(parent_link.name))
12741278
# format_json() breaks on lambda values; use pprint.pformat here.

src/scriptworker/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_version_string(version: Union[ShortVerType, LongVerType]) -> str:
5454

5555
# 1}}}
5656
# Semantic versioning 2.0.0 http://semver.org/
57-
__version__ = (34, 0, 0)
57+
__version__ = (34, 1, 0)
5858
__version_string__ = get_version_string(__version__)
5959

6060

tests/test_cot_verify.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,9 @@ async def get_pull_request_mock(pull_request_number, *args, **kwargs):
12701270
async def test_populate_jsone_context_fail(mobile_chain, mobile_github_release_link):
12711271
with pytest.raises(CoTError):
12721272
await cotverify.populate_jsone_context(mobile_chain, mobile_github_release_link, mobile_github_release_link, tasks_for="bad-tasks-for")
1273+
mobile_chain.context.config["cot_product_type"] = "bad-cot-product-type"
1274+
with pytest.raises(CoTError):
1275+
await cotverify.populate_jsone_context(mobile_chain, mobile_github_release_link, mobile_github_release_link, tasks_for="github-push")
12731276

12741277

12751278
@pytest.mark.asyncio

version.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"version":[
33
34,
4-
0,
4+
1,
55
0
66
],
7-
"version_string":"34.0.0"
7+
"version_string":"34.1.0"
88
}

0 commit comments

Comments
 (0)