Skip to content

Commit

Permalink
bot: Use hg.mozilla.org instead of local instance of hgmo as we can't…
Browse files Browse the repository at this point in the history
… rely on if for push data
  • Loading branch information
marco-c committed Nov 20, 2020
1 parent 80ab1c7 commit 45ea3a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions bot/code_coverage_bot/hooks/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions bot/code_coverage_bot/trigger_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
7 changes: 5 additions & 2 deletions bot/tests/test_trigger_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 45ea3a2

Please sign in to comment.