Skip to content

Commit

Permalink
bug 1594621 - add cot_product_type map (#454)
Browse files Browse the repository at this point in the history
* fix cot verify for adhoc

* cot_product_type

* add coverage

* 34.1.0
  • Loading branch information
escapewindow authored May 4, 2020
1 parent 876f14c commit 764816a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
18 changes: 18 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`__.

[34.1.0] - 2020-05-04
---------------------

Added
~~~~~
- added ``cot_product_type``

Changed
~~~~~~~
- ``populate_jsone_context`` now checks ``cot_product_type`` instead of allowlisting a set of ``cot_products`` as github

Changed
~~~~~~~
- ``check_interactive_docker_worker`` now raises ``CoTError`` on errors, rather
than returning the list of error messages
- ``check_interactive_docker_worker`` now also runs against the chain task, if it's
docker-worker

[34.0.0] - 2020-04-17
---------------------

Expand Down
16 changes: 16 additions & 0 deletions src/scriptworker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@
"scriptworker_provisioners": ("scriptworker-prov-v1", "scriptworker-k8s"),
# valid hash algorithms for chain of trust artifacts
"valid_hash_algorithms": ("sha256", "sha512"),
"cot_product_type": immutabledict(
{
"by-cot-product": immutabledict(
{
"firefox": "hg",
"thunderbird": "hg",
"mobile": "github",
"mpd001": "github",
"application-services": "github",
"xpi": "github",
"adhoc": "github",
"scriptworker": "github",
},
),
},
),
# decision task cot
"valid_decision_worker_pools": immutabledict(
{
Expand Down
12 changes: 8 additions & 4 deletions src/scriptworker/cot/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
"taskId": None,
}

if chain.context.config["cot_product"] in ("mobile", "mpd001", "application-services", "xpi"):
if chain.context.config["cot_product_type"] == "github":
if tasks_for == "github-release":
jsone_context.update(await _get_additional_github_releases_jsone_context(decision_link))
elif tasks_for == "cron":
Expand All @@ -1251,8 +1251,8 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
elif tasks_for == "github-push":
jsone_context.update(await _get_additional_github_push_jsone_context(decision_link))
else:
raise CoTError('Unknown tasks_for "{}" for cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
else:
raise CoTError('Unknown tasks_for "{}" for github cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
elif chain.context.config["cot_product_type"] == "hg":
source_url = get_source_url(decision_link)
project = await get_project(chain.context, source_url)
jsone_context["repository"] = {
Expand All @@ -1268,7 +1268,11 @@ async def populate_jsone_context(chain, parent_link, decision_link, tasks_for):
elif tasks_for == "cron":
jsone_context.update(await _get_additional_hg_cron_jsone_context(parent_link, decision_link))
else:
raise CoTError("Unknown tasks_for {}!".format(tasks_for))
raise CoTError('Unknown tasks_for "{}" for hg cot_product "{}"!'.format(tasks_for, chain.context.config["cot_product"]))
else:
raise CoTError(
'Unknown cot_product_type "{}" for cot_product "{}"!'.format(chain.context.config["cot_product_type"], chain.context.config["cot_product"])
)

log.debug("{} json-e context:".format(parent_link.name))
# format_json() breaks on lambda values; use pprint.pformat here.
Expand Down
2 changes: 1 addition & 1 deletion src/scriptworker/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_version_string(version: Union[ShortVerType, LongVerType]) -> str:

# 1}}}
# Semantic versioning 2.0.0 http://semver.org/
__version__ = (34, 0, 0)
__version__ = (34, 1, 0)
__version_string__ = get_version_string(__version__)


Expand Down
3 changes: 3 additions & 0 deletions tests/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,9 @@ async def get_pull_request_mock(pull_request_number, *args, **kwargs):
async def test_populate_jsone_context_fail(mobile_chain, mobile_github_release_link):
with pytest.raises(CoTError):
await cotverify.populate_jsone_context(mobile_chain, mobile_github_release_link, mobile_github_release_link, tasks_for="bad-tasks-for")
mobile_chain.context.config["cot_product_type"] = "bad-cot-product-type"
with pytest.raises(CoTError):
await cotverify.populate_jsone_context(mobile_chain, mobile_github_release_link, mobile_github_release_link, tasks_for="github-push")


@pytest.mark.asyncio
Expand Down
4 changes: 2 additions & 2 deletions version.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version":[
34,
0,
1,
0
],
"version_string":"34.0.0"
"version_string":"34.1.0"
}

0 comments on commit 764816a

Please sign in to comment.