Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/taskgraph/run-task/run-task
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ def git_checkout(
]
retry_required_command(b"vcs", args, extra_env=env)

workers = os.environ.get("RUN_TASK_GIT_CHECKOUT_WORKERS", "0")
args = ["git", "config", "--global", "checkout.workers", workers]
retry_required_command(b"vcs", args, extra_env=env)

is_sparse = (
has_repo and _git_config(destination_path, "core.sparseCheckout") == "true"
)
Expand Down
36 changes: 36 additions & 0 deletions test/test_scripts_run_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,42 @@ def test_git_checkout(
assert current_rev == mock_git_repo[hash_key][-1]


@pytest.mark.parametrize(
"env_value,expected",
(
pytest.param(None, "0", id="default"),
pytest.param("1", "1", id="disabled"),
pytest.param("4", "4", id="pinned"),
),
)
def test_git_checkout_enables_parallel_checkout(
monkeypatch, mock_stdin, run_task_mod, mock_git_repo, tmp_path, env_value, expected
):
monkeypatch.delenv("RUN_TASK_GIT_CHECKOUT_WORKERS", raising=False)
if env_value is not None:
monkeypatch.setenv("RUN_TASK_GIT_CHECKOUT_WORKERS", env_value)
destination = tmp_path / "destination"
run_task_mod.git_checkout(
destination_path=destination,
head_repo=mock_git_repo["path"],
base_repo=mock_git_repo["path"],
base_rev=None,
head_ref="main",
head_rev=None,
ssh_key_file=None,
ssh_known_hosts_file=None,
)

workers = subprocess.check_output(
["git", "config", "--global", "--get", "checkout.workers"],
cwd=destination,
universal_newlines=True,
).strip()
# 0 means one worker per logical core, see
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-checkoutworkers
assert workers == expected


@pytest.mark.parametrize(
"head_ref,head_rev_index",
(
Expand Down