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
This commit is contained in:
David Riazati
2021-09-07 15:14:05 -07:00
committed by Facebook GitHub Bot
parent a48d83a575
commit 7e88d0b370
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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)
path = REPO_ROOT.joinpath(relative_file)
if not fnmatch.fnmatch(path.name, args.filter_gha):
touched_files.append(path)
path.unlink()
path.resolve().unlink()
if args.make_commit:
jobs_str = '\n'.join([f" * {job}" for job in args.job])