From 67e52a120b210f70b7a5de06996d9036f9f68011 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 12 May 2026 13:17:59 -0400 Subject: [PATCH] run_tests: leverage cipd when available for help2man This tool isn't installed on CI bot images so we've been skipping it, but this is causing people to not run tests locally, and ignore errors. Use cipd to pull the tool in when available. Then revert a recent man change that the tool rejects. Change-Id: I1030d0070fd5a624656eba7434ae6ec99b2e3f2d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/582401 Reviewed-by: Greg Edelston Tested-by: Mike Frysinger --- .gitignore | 1 + cipd_manifest.txt | 32 ++++++++++++++++++++++++++++++++ cipd_manifest.versions | 18 ++++++++++++++++++ man/repo-manifest.1 | 4 ++-- release/update_manpages.py | 10 +++++++--- run_tests | 21 ++++++++++++++++----- 6 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 cipd_manifest.txt create mode 100644 cipd_manifest.versions diff --git a/.gitignore b/.gitignore index 4e91be94c..4326a4ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__ /dist .repopickle_* /repoc +/.cipd_bin /.tox /.venv diff --git a/cipd_manifest.txt b/cipd_manifest.txt new file mode 100644 index 000000000..da6dd8e02 --- /dev/null +++ b/cipd_manifest.txt @@ -0,0 +1,32 @@ +# Copyright (C) 2026 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains version pins of a few tools used by run_tests. + +# Pin resolved versions in the repo, to reduce trust in the CIPD backend. +# +# Most of these tools are generated via builders at +# https://ci.chromium.org/p/infra/g/infra/console +# +# For these, the git revision is the one of +# https://chromium.googlesource.com/infra/infra.git. +# +# To regenerate them (after modifying this file): +# cipd ensure-file-resolve -ensure-file cipd_manifest.txt +$ResolvedVersions cipd_manifest.versions + +# Supported platforms. Feel free to add more as long as the tools work. +$VerifiedPlatform linux-amd64 linux-arm64 mac-amd64 mac-arm64 + +infra/3pp/tools/help2man/${platform} version:3@1.47.8.chromium.1 diff --git a/cipd_manifest.versions b/cipd_manifest.versions new file mode 100644 index 000000000..135f54048 --- /dev/null +++ b/cipd_manifest.versions @@ -0,0 +1,18 @@ +# This file is auto-generated by 'cipd ensure-file-resolve'. +# Do not modify manually. All changes will be overwritten. + +infra/3pp/tools/help2man/linux-amd64 + version:3@1.47.8.chromium.1 + Ftn7OHsJBffbIuK3KERGGF21oKqMmnV00B6ZKmjxKe4C + +infra/3pp/tools/help2man/linux-arm64 + version:3@1.47.8.chromium.1 + _7lsBiY7fUeLXx1UJc_LEE8H9DG7CGGM9M2gjyqB9T4C + +infra/3pp/tools/help2man/mac-amd64 + version:3@1.47.8.chromium.1 + E7Dldyd8BvjuW2ZuZy3ILNt7KNN2Cs_F_5dkwRfaL8IC + +infra/3pp/tools/help2man/mac-arm64 + version:3@1.47.8.chromium.1 + K5qjjtmIDBnibI_76qoEEgsbwzkQUGrZxbBsaUgOeisC diff --git a/man/repo-manifest.1 b/man/repo-manifest.1 index 35c7d0216..75c9fa9e1 100644 --- a/man/repo-manifest.1 +++ b/man/repo-manifest.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH REPO "1" "May 2026" "repo manifest" "Repo Manual" +.TH REPO "1" "April 2026" "repo manifest" "Repo Manual" .SH NAME repo \- repo manifest - manual page for repo manifest .SH SYNOPSIS @@ -697,7 +697,7 @@ default to which all projects in the included manifest belong. This recurses, meaning it will apply to all projects in all manifests included as a result of this element. .PP -Local Manifests +Local Manifests .PP Additional remotes and projects may be added through local manifest files stored in `$TOP_DIR/.repo/local_manifests/*.xml`. diff --git a/release/update_manpages.py b/release/update_manpages.py index 8bd69b6a7..ecf51bb7a 100644 --- a/release/update_manpages.py +++ b/release/update_manpages.py @@ -66,7 +66,11 @@ def main(argv: List[str]) -> int: parser = get_parser() opts = parser.parse_args(argv) - if not shutil.which("help2man"): + help2man = ["help2man"] + cipd_help2man = TOPDIR / ".cipd_bin/bin/help2man" + if cipd_help2man.exists(): + help2man = ["perl", cipd_help2man] + elif not shutil.which("help2man"): sys.exit("Please install help2man to continue.") # Let repo know we're generating man pages so it can avoid some dynamic @@ -81,7 +85,7 @@ def main(argv: List[str]) -> int: version = RepoSourceVersion() cmdlist = [ [ - "help2man", + *help2man, "-N", "-n", f"repo {cmd} - manual page for repo {cmd}", @@ -100,7 +104,7 @@ def main(argv: List[str]) -> int: ] cmdlist.append( [ - "help2man", + *help2man, "-N", "-n", "repository management tool built on top of git", diff --git a/run_tests b/run_tests index 7491ec5ae..33311f03d 100755 --- a/run_tests +++ b/run_tests @@ -157,11 +157,6 @@ def run_check_metadata(): def run_update_manpages() -> int: """Returns the exit code from release/update-manpages.""" - # Allow this to fail on CI, but not local devs. - if is_ci() and not shutil.which("help2man"): - print("update-manpages: help2man not found; skipping test") - return 0 - argv = ["--check"] log_cmd("release/update-manpages", argv) return subprocess.run( @@ -171,8 +166,24 @@ def run_update_manpages() -> int: ).returncode +def cipd_bootstrap() -> None: + """Install packages via cipd if available.""" + argv = ["ensure", "-root", ".cipd_bin", "-ensure-file", "cipd_manifest.txt"] + log_cmd("cipd", argv) + try: + subprocess.run( + ["cipd"] + argv, + check=True, + cwd=ROOT_DIR, + ) + except FileNotFoundError: + # Skip if the user doesn't have cipd from depot_tools. + return + + def main(argv): """The main entry.""" + cipd_bootstrap() checks = ( functools.partial(run_pytest, argv), functools.partial(run_pytest_py38, argv),