Skip to content

Bug 1957113 - ingest firefox-ios and staging-firefox-ios release branches. DO NOT MERGE #8610

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 13 additions & 8 deletions treeherder/etl/management/commands/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def repo_meta(project):
}


def query_data(repo_meta, commit):
def query_data(repo_meta, commit, branch):
"""Find the right event base sha to get the right list of commits

This is not an issue in GithubPushTransformer because the PushEvent from Taskcluster
Expand All @@ -271,7 +271,7 @@ def query_data(repo_meta, commit):
# First we try with `master` being the base sha
# e.g. https://api.github.com/repos/servo/servo/compare/master...1418c0555ff77e5a3d6cf0c6020ba92ece36be2e
compare_response = github.compare_shas(
repo_meta["owner"], repo_meta["repo"], repo_meta["branch"], commit
repo_meta["owner"], repo_meta["repo"], branch or repo_meta["branch"], commit
)
merge_base_commit = compare_response.get("merge_base_commit")
if merge_base_commit:
Expand Down Expand Up @@ -319,8 +319,8 @@ def query_data(repo_meta, commit):
return event_base_sha, commits


def github_push_to_pulse(repo_meta, commit):
event_base_sha, commits = query_data(repo_meta, commit)
def github_push_to_pulse(repo_meta, commit, branch):
event_base_sha, commits = query_data(repo_meta, commit, branch)

return {
"exchange": "exchange/taskcluster-github/v1/push",
Expand All @@ -329,7 +329,7 @@ def github_push_to_pulse(repo_meta, commit):
"organization": repo_meta["owner"],
"details": {
"event.head.repo.url": "{}.git".format(repo_meta["url"]),
"event.base.repo.branch": repo_meta["branch"],
"event.base.repo.branch": branch or repo_meta["branch"],
"event.base.sha": event_base_sha,
"event.head.sha": commit,
},
Expand All @@ -341,10 +341,10 @@ def github_push_to_pulse(repo_meta, commit):
}


def ingest_push(project, revision, fetch_push_id=None):
def ingest_push(project, revision, branch=None, fetch_push_id=None):
_repo = repo_meta(project)
if _repo["url"].startswith("https://github.com"):
pulse = github_push_to_pulse(_repo, revision)
pulse = github_push_to_pulse(_repo, revision, branch)
PushLoader().process(pulse["payload"], pulse["exchange"], _repo["tc_root_url"])
else:
_ingest_hg_push(project, revision)
Expand Down Expand Up @@ -417,6 +417,11 @@ def add_arguments(self, parser):
"ingestion_type", nargs=1, help="Type of ingestion to do: [task|hg-push|git-commit|pr]"
)
parser.add_argument("-p", "--project", help="Hg repository to query (e.g. autoland)")
parser.add_argument(
"-b",
"--branch",
help="branch to query (e.g. release/vXXX) - required if repository accepts more than one branch",
)
parser.add_argument("-c", "--commit", "-r", "--revision", help="Commit/revision to import")
parser.add_argument(
"--enable-eager-celery",
Expand Down Expand Up @@ -474,7 +479,7 @@ def handle(self, *args, **options):
"If you don't set up GITHUB_TOKEN you might hit Github's rate limiting. See docs for info."
)
if type_of_ingestion == "git-push":
ingest_push(options["project"], options["commit"])
ingest_push(options["project"], options["commit"], options["branch"])
elif type_of_ingestion == "git-pushes":
ingest_git_pushes(options["project"], options["dryRun"])
elif type_of_ingestion == "push":
Expand Down
8 changes: 7 additions & 1 deletion treeherder/etl/push_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ def process(self, message_body, exchange, root_url):
newrelic.agent.add_custom_attribute("branch", transformer.branch)
repos = Repository.objects
if transformer.branch:
repos = repos.filter(branch__regex=f"(^|,){transformer.branch}($|,)")
if "/" in transformer.branch:
branch_domain = transformer.branch.split("/")[0] + "\\/\\*"
repos = repos.filter(
branch__regex=f"(^|,){transformer.branch}($|,)|(^|,){branch_domain}($|,)"
)
else:
repos = repos.filter(branch__regex=f"(^|,){transformer.branch}($|,)")
else:
repos = repos.filter(branch=None)
repo = repos.get(url=transformer.repo_url, active_status="active")
Expand Down
4 changes: 2 additions & 2 deletions treeherder/model/fixtures/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@
"dvcs_type": "git",
"name": "firefox-ios",
"url": "https://github.com/mozilla-mobile/firefox-ios",
"branch": "main",
"branch": "main,release/*",
"active_status": "active",
"codebase": "firefox-ios",
"repository_group": 11,
Expand Down Expand Up @@ -1954,7 +1954,7 @@
"dvcs_type": "git",
"name": "staging-firefox-ios",
"url": "https://github.com/mozilla-mobile/staging-firefox-ios",
"branch": "main",
"branch": "main,release/*",
"active_status": "active",
"codebase": "firefox-ios",
"repository_group": 11,
Expand Down