From 45ea3a2932cafd2b99a9f946bbdd06b175161a35 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 20 Nov 2020 01:50:10 +0100 Subject: [PATCH] bot: Use hg.mozilla.org instead of local instance of hgmo as we can't rely on if for push data --- bot/code_coverage_bot/hooks/cron.py | 5 ++--- bot/code_coverage_bot/trigger_missing.py | 4 ++-- bot/tests/test_trigger_missing.py | 7 +++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bot/code_coverage_bot/hooks/cron.py b/bot/code_coverage_bot/hooks/cron.py index 355325cb3..6e510eeb3 100644 --- a/bot/code_coverage_bot/hooks/cron.py +++ b/bot/code_coverage_bot/hooks/cron.py @@ -3,7 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. - import structlog from code_coverage_bot import commit_coverage @@ -35,9 +34,9 @@ def __init__(self, *args, **kwargs): super().__init__(config.MOZILLA_CENTRAL_REPOSITORY, revision, *args, **kwargs) def run(self) -> None: - self.retrieve_source_and_artifacts() + trigger_missing.trigger_missing(config.MOZILLA_CENTRAL_REPOSITORY) - trigger_missing.trigger_missing(self.repo_dir) + self.retrieve_source_and_artifacts() commit_coverage.generate(self.repo_dir) diff --git a/bot/code_coverage_bot/trigger_missing.py b/bot/code_coverage_bot/trigger_missing.py index f84a38344..d5ad22820 100644 --- a/bot/code_coverage_bot/trigger_missing.py +++ b/bot/code_coverage_bot/trigger_missing.py @@ -42,7 +42,7 @@ def trigger_task(task_group_id: str, revision: str) -> None: ) -def trigger_missing(repo_dir: str, out_dir: str = ".") -> None: +def trigger_missing(server_address: str, out_dir: str = ".") -> None: triggered_revisions_path = os.path.join(out_dir, "triggered_revisions.zst") url = f"https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/project.relman.code-coverage.{secrets[secrets.APP_CHANNEL]}.cron.latest/artifacts/public/triggered_revisions.zst" # noqa @@ -62,7 +62,7 @@ def trigger_missing(repo_dir: str, out_dir: str = ".") -> None: # Get all mozilla-central revisions from the past year. days = 365 if secrets[secrets.APP_CHANNEL] == "production" else 30 a_year_ago = datetime.utcnow() - timedelta(days=days) - with hgmo.HGMO(repo_dir=repo_dir) as hgmo_server: + with hgmo.HGMO(server_address=server_address) as hgmo_server: data = hgmo_server.get_pushes( startDate=a_year_ago.strftime("%Y-%m-%d"), full=False, tipsonly=True ) diff --git a/bot/tests/test_trigger_missing.py b/bot/tests/test_trigger_missing.py index f802e8483..7234f18f7 100644 --- a/bot/tests/test_trigger_missing.py +++ b/bot/tests/test_trigger_missing.py @@ -5,6 +5,7 @@ import responses import zstandard +from code_coverage_bot import hgmo from code_coverage_bot import taskcluster from code_coverage_bot import trigger_missing from code_coverage_bot import uploader @@ -187,7 +188,8 @@ def get_tasks_in_group(group_id): monkeypatch.setattr(taskcluster, "get_tasks_in_group", get_tasks_in_group) - trigger_missing.trigger_missing(local, out_dir=tmp_path) + with hgmo.HGMO(repo_dir=local) as hgmo_server: + trigger_missing.trigger_missing(hgmo_server.server_address, out_dir=tmp_path) assert gcp_covdir_exists_calls == 4 assert trigger_hook_calls == 2 @@ -335,7 +337,8 @@ def get_tasks_in_group(group_id): monkeypatch.setattr(taskcluster, "get_tasks_in_group", get_tasks_in_group) - trigger_missing.trigger_missing(local, out_dir=tmp_path) + with hgmo.HGMO(repo_dir=local) as hgmo_server: + trigger_missing.trigger_missing(hgmo_server.server_address, out_dir=tmp_path) assert gcp_covdir_exists_calls == 1 assert trigger_hook_calls == 1