From 7e88d0b370b63b510af5962c103babd9967669d8 Mon Sep 17 00:00:00 2001 From: David Riazati Date: Tue, 7 Sep 2021 15:14:05 -0700 Subject: [PATCH] Update explicit_ci_jobs to work with GHA (#64598) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64598 This adds a filter option rather than an all-or-nothing so it's easier to iterate on a specific job. ```bash python tools/testing/explicit_ci_jobs.py --filter-gha '*generated-linux-*gcc5.4*' ``` See #64600 for an example usage NB: If you regenerate the worfklows you will need to re-run that command to re-delete everything. Test Plan: Imported from OSS Reviewed By: janeyx99 Differential Revision: D30788850 Pulled By: driazati fbshipit-source-id: a32c266bbd876c396665bceef9a0a961b4586564 --- CONTRIBUTING.md | 3 ++- tools/testing/explicit_ci_jobs.py | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e102de7be633..eeaae1d74427 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -451,8 +451,9 @@ You can generate a commit that limits the CI to only run a specific job by using ```bash # --job: specify one or more times to filter to a specific job + its dependencies +# --filter-gha: specify github actions worklfows to keep # --make-commit: commit CI changes to git with a message explaining the change -python tools/testing/explicit_ci_jobs.py --job binary_linux_manywheel_3_6m_cpu_devtoolset7_nightly_test --make-commit +python tools/testing/explicit_ci_jobs.py --job binary_linux_manywheel_3_6m_cpu_devtoolset7_nightly_test --filter-gha '*generated*gcc5.4*' --make-commit # Make your changes diff --git a/tools/testing/explicit_ci_jobs.py b/tools/testing/explicit_ci_jobs.py index ee0bc4d6768a..67d7a798691c 100755 --- a/tools/testing/explicit_ci_jobs.py +++ b/tools/testing/explicit_ci_jobs.py @@ -5,6 +5,7 @@ import textwrap import subprocess import pathlib import argparse +import fnmatch from typing import Dict, List, Any @@ -107,7 +108,7 @@ if __name__ == "__main__": ) parser.add_argument("--job", action="append", help="job name", default=[]) parser.add_argument( - "--keep-gha", action="store_true", help="don't delete GitHub actions" + "--filter-gha", help="keep only these github actions (glob match)", default='' ) parser.add_argument( "--make-commit", action="store_true", help="add change to git with to a do-not-merge commit" @@ -123,11 +124,12 @@ if __name__ == "__main__": with open(CONFIG_YML, "w") as f: yaml.dump(config_yml, f) - if not args.keep_gha: + if args.filter_gha: for relative_file in WORKFLOWS_DIR.iterdir(): - path = WORKFLOWS_DIR.joinpath(relative_file) - touched_files.append(path) - path.unlink() + path = REPO_ROOT.joinpath(relative_file) + if not fnmatch.fnmatch(path.name, args.filter_gha): + touched_files.append(path) + path.resolve().unlink() if args.make_commit: jobs_str = '\n'.join([f" * {job}" for job in args.job])