Skip to content

Support git try pushes in the test scheduling endpoint - #7694

Merged
marco-c merged 5 commits into
mozilla:masterfrom
marco-c:git-try-pushes
Dec 3, 2026
Merged

marco-c merged 5 commits into
mozilla:masterfrom
marco-c:git-try-pushes

Conversation

@marco-c

@marco-c marco-c commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

The decision task of pushes to the firefox-dev git try repository requests /push/firefox-dev/<rev>/schedules (e.g. for https://treeherder.mozilla.org/jobs?repo=firefox-dev&revision=042402d29da9a5735e2062c20644cf4da966be95), which fails as the push is looked for on hg.mozilla.org. This adds support for the pushes to firefox-dev and to the private firefox-dev-secure.

For these pushes:

  1. The base revision is read from the try_task_config.json of the push: GitHub reports a null base for a push creating a branch, so mach try records it there (parameters.base_rev).
  2. The commits from the base to the head are fetched from GitHub with git into a repository reused across jobs (BUGBUG_GIT_REPO_DIR). The base is fetched with a depth of 1, so the head fetch stops at it, and only commits and trees are fetched, then the contents of the changed files in a single request. The only ref is to the last base, so that GitHub only sends the trees which changed with the next base (1-3 MB instead of ~35 MB for the whole tree), and git's gc prunes the other commits.
  3. The commits are exported with git format-patch and imported on top of the base (mapped with Lando's git2hg, and pulled from autoland unless it is already local, as for the patch endpoint) in the local Mercurial repository, so they are analyzed exactly like the commits of hg try pushes, including skipping the commits which only add try_task_config.json.

The Pulse listener also requests the scheduling of git try pushes as soon as they are pushed, as it does for hg try pushes, from the push messages Taskcluster publishes on exchange/taskcluster-github/v1/push when it receives them from GitHub (before the decision task runs).

No GitHub API is used. When BUGBUG_GITHUB_TOKEN is set, the requests to GitHub (try_task_config.json and the git fetches) are authenticated with it, which firefox-dev-secure requires: the token needs read access to it. It is given to git through the environment (http.extraheader), so it doesn't appear on command lines, in error messages or in the repository configuration.

Tested on 4 recent firefox-dev pushes, from a new git repository and a mozilla-central clone: the stack contains the commits of the push with the same descriptions (except the blank line after the title, which hg import drops), the same files, and the same contents of the changed files at the head. Getting the patch takes ~4s per push, and the whole import 17-26s, most of it updating the working directory to the base (#7695 removes that). Fetching the file contents at once brings 30 commits of mozilla-firefox/firefox changing 199 files from 28.1s to 12.9s. firefox-dev-secure wasn't tested.

Not supported (the job returns NOK): pushes without base_rev in their try_task_config.json (not pushed with mach try) and, as for the patch endpoint, bases which aren't on autoland (e.g. beta).

The taskgraph also needs firefox-dev and firefox-dev-secure in SUPPORTED_PROJECTS (taskcluster/gecko_taskgraph/util/bugbug.py), as mach try auto pushes to them currently fail before querying bugbug.

@marco-c

marco-c commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

@ahal I'm not expecting you to review all of this, but just a high level review of the approach to make sure it is sound.

@marco-c
marco-c force-pushed the git-try-pushes branch 3 times, most recently from 1704df0 to 875db33 Compare November 27, 2026 12:30
@ahal

ahal commented Nov 27, 2026

Copy link
Copy Markdown
Member

Sweet thanks, I had started an agent on this but it'll be much better with you driving it over me

@ahal

ahal commented Nov 27, 2026

Copy link
Copy Markdown
Member

The base revision is read from the try_task_config.json of the push: GitHub reports a null base for a push creating a branch, so mach try records it there (parameters.base_rev).

I think this works, but it might be better to get this out of the Decision task's parameters.yml file instead. Mainly because in the future I'm planning to replace try_task_config.json with Git notes.. but this doesn't need to block anything.

@ahal ahal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes the overall changes look sound!

Comment thread bugbug/repository.py Outdated
after=tenacity.after_log(logger, logging.DEBUG),
retry=tenacity.retry_if_exception_type(subprocess.CalledProcessError),
)
def _fetch_git_commit(repo_dir: str, url: str, rev: str, depth: int | None) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall a separate conversation about using run-task in reviewbot or similar. Seems like this might be another use case for it. I guess what we really want is a Git equivalent of robustcheckout.py (so just the cloning pieces of run-task without all the other Taskcluster stuff).

Not something to block or anything, just an observation.

Comment thread http_service/bugbug_http/__init__.py Outdated
)

# The git try repositories (as Treeherder projects), with their GitHub repository.
GIT_TRY_REPOSITORIES = {"firefox-dev": "mozilla-firefox/firefox-dev"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well also add mozilla-firefox/firefox-dev-secure while we're at it.

@marco-c

marco-c commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

The base revision is read from the try_task_config.json of the push: GitHub reports a null base for a push creating a branch, so mach try records it there (parameters.base_rev).

I think this works, but it might be better to get this out of the Decision task's parameters.yml file instead. Mainly because in the future I'm planning to replace try_task_config.json with Git notes.. but this doesn't need to block anything.

This wouldn't be possible with the current architecture: the decision task depends on bugbug answer, and so bugbug can't depend on the decision task artifact.

repository.get_git_patch fetches the commits from a base revision to a head
revision of a remote repository into a local repository, and returns them in
git format-patch style, so they can be imported in a Mercurial repository.

Only the commits and trees are fetched (the file contents are fetched when
needed), and the base is fetched with a depth of 1, so that the head fetch
stops at it and doesn't bring its history. The local repository is reused:
the only ref is to the last base, so that only the trees which changed are
fetched with the next base, and the other commits are pruned when the
repository is garbage collected.
As the commits are fetched without the file contents, git format-patch
fetched the contents of the changed files one by one, with a request for each
of them. They are now fetched before generating the patch, with a single
request for up to 500 of them.

On 30 commits of mozilla-firefox/firefox changing 199 files, getting the
patch takes 12.9 seconds instead of 28.1.
The decision task of pushes to the firefox-dev git try repository requests
/push/firefox-dev/<rev>/schedules, which failed as the push was looked for
on hg.mozilla.org.

For these pushes, the commits are fetched from GitHub with git, from the base
revision `mach try` records in the try_task_config.json of the push (as GitHub
reports a null base for a push creating a branch), into a git repository
reused across jobs. They are then imported on top of the base in the local
Mercurial repository, so that they are analyzed in the same way as the commits
of hg try pushes. The base is pulled from autoland unless it is already local,
as for the patch endpoint, with which the code is shared.

Pushes without a base revision in their try_task_config.json, or with a base
which isn't on autoland, are not supported.
The Pulse listener requested the test scheduling of hg try and autoland
pushes when they were pushed, so that it was being computed or already
computed when the decision task requested it, but not the one of git try
pushes.

It now also listens to the pushes Taskcluster publishes for the git try
repositories (on exchange/taskcluster-github/v1/push, when it receives them
from GitHub, before the decision task runs), skipping branch deletions and
tags.
The requests to GitHub for git try pushes (the try_task_config.json of the
push, and the git fetches, including the lazy fetches of file contents when
the patch is generated) are now authenticated with BUGBUG_GITHUB_TOKEN when it
is set, so that the pushes to private repositories can be fetched given a
token with read access to them.

The token is given to git as an HTTP header configured through the
environment, so that it doesn't appear on command lines, in error messages or
in the configuration of the local repository.
@marco-c
marco-c force-pushed the git-try-pushes branch 2 times, most recently from 88c264f to 054b5fd Compare December 3, 2026 14:16
@marco-c
marco-c marked this pull request as ready for review December 3, 2026 14:38
@marco-c
marco-c requested a review from a team as a code owner December 3, 2026 14:38
@marco-c
marco-c merged commit 49ed241 into mozilla:master Dec 3, 2026
13 checks passed
@marco-c
marco-c deleted the git-try-pushes branch December 3, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants