Skip to content

Return the first coverage task we find in the task group #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions events/code_coverage_events/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ async def run(self):
)

def is_coverage_task(self, task):
name = task["task"]["metadata"]["name"]
return name.startswith("build-") and "ccov" in name.split("/")[0].split("-")
return "ccov" in task["task"]["metadata"]["name"].split("/")[0].split("-")

async def get_build_task_in_group(self, group_id):
async def get_coverage_task_in_group(self, group_id):
if group_id in self.triggered_groups:
logger.info(
"Received duplicated groupResolved notification", group=group_id
Expand Down Expand Up @@ -118,11 +117,11 @@ async def parse(self, body):
)
return None

build_task = await self.get_build_task_in_group(taskGroupId)
if build_task is None:
coverage_task = await self.get_coverage_task_in_group(taskGroupId)
if coverage_task is None:
return None

repository = build_task["task"]["payload"]["env"]["GECKO_HEAD_REPOSITORY"]
repository = coverage_task["task"]["payload"]["env"]["GECKO_HEAD_REPOSITORY"]

if repository not in [
"https://hg.mozilla.org/mozilla-central",
Expand All @@ -134,19 +133,16 @@ async def parse(self, body):
)
return None

revision = coverage_task["task"]["payload"]["env"]["GECKO_HEAD_REV"]

logger.info(
"Received groupResolved notification for coverage builds",
repository=repository,
revision=build_task["task"]["payload"]["env"]["GECKO_HEAD_REV"],
revision=revision,
group=taskGroupId,
)

return [
{
"REPOSITORY": repository,
"REVISION": build_task["task"]["payload"]["env"]["GECKO_HEAD_REV"],
}
]
return [{"REPOSITORY": repository, "REVISION": revision}]


class Events(object):
Expand Down
6 changes: 3 additions & 3 deletions events/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ def test_is_coverage_task(mock_taskcluster):
assert hook.is_coverage_task(cov_task)

nocov_task = {"task": {"metadata": {"name": "test-linux64-ccov/opt-mochitest-1"}}}
assert not hook.is_coverage_task(nocov_task)
assert hook.is_coverage_task(nocov_task)

nocov_task = {"task": {"metadata": {"name": "test-linux64/opt-mochitest-1"}}}
assert not hook.is_coverage_task(nocov_task)


@pytest.mark.asyncio
async def test_get_build_task_in_group(mock_taskcluster):
async def test_get_coverage_task_in_group(mock_taskcluster):
bus = MessageBus()
hook = CodeCoverage("services-staging-codecoverage/bot", "project-test", bus)

hook.triggered_groups.add("already-triggered-group")

assert await hook.get_build_task_in_group("already-triggered-group") is None
assert await hook.get_coverage_task_in_group("already-triggered-group") is None


@pytest.mark.asyncio
Expand Down