Bug 1731178 - [taskgraph] Explicitly set base revision in tgdiff task, r=taskgraph-reviewers,bhearsum

Since all commits on non-try branches are public, vcs.base_ref was returning
the current revision each time and the diff task was always diffing against the
same revision twice.

By using 'json-automationrelevance' to determine the parent push, we can be
sure we're always diffing against the proper revision.

Depends on D125974

Differential Revision: https://phabricator.services.mozilla.com/D125975
This commit is contained in:
Andrew Halberstadt 2021-09-17 16:07:17 +00:00
Родитель 762e6e7de4
Коммит a3df98cacf
2 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -27,7 +27,7 @@ diff:
cwd: '{checkout}'
command: >-
mkdir -p /builds/worker/artifacts/diffs &&
./mach taskgraph target --fast -p "taskcluster/test/params" -o "/builds/worker/artifacts/diffs/diff_{params}.txt" --diff
./mach taskgraph target --fast -p "taskcluster/test/params" -o "/builds/worker/artifacts/diffs/diff.txt" --diff {base_rev}
when:
files-changed:
- 'taskcluster/ci/**'

Просмотреть файл

@ -10,9 +10,11 @@ treeherder configuration and attributes for that platform.
import copy
import os
import taskgraph
from taskgraph.transforms.base import TransformSequence
from taskgraph.transforms.job import job_description_schema
from taskgraph.util.attributes import keymatch
from taskgraph.util.hg import get_json_automationrelevance
from taskgraph.util.schema import (
resolve_keyed_by,
optionally_keyed_by,
@ -243,3 +245,25 @@ def set_code_review_env(config, jobs):
env["CODE_REVIEW"] = "1"
yield job
@transforms.add
def set_base_revision_in_tgdiff(config, jobs):
# Don't attempt to download 'json-automation' locally as the revision may
# not exist in the repository.
if not os.environ.get("MOZ_AUTOMATION") or taskgraph.fast:
yield from jobs
return
data = get_json_automationrelevance(
config.params["head_repository"], config.params["head_rev"]
)
for job in jobs:
if job["name"] != "taskgraph-diff":
yield job
continue
job["run"]["command-context"] = {
"base_rev": data["changesets"][0]["parents"][0]
}
yield job