Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert uglification of CLI options #1668

Merged
merged 8 commits into from
Sep 16, 2024
Merged
Changes from 5 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
40 changes: 17 additions & 23 deletions ci/scripts/towncrier_automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
from __future__ import annotations

import argparse
import re
import subprocess
from typing import TYPE_CHECKING

from packaging import version
from packaging.version import VERSION_PATTERN as _VP

if TYPE_CHECKING:
from collections.abc import Sequence


VERSION = re.compile(_VP, re.VERBOSE | re.IGNORECASE)


class Args(argparse.Namespace):
version: str
dry_run: bool
Expand Down Expand Up @@ -40,11 +44,12 @@ def parse_args(argv: Sequence[str] | None = None) -> Args:
action="store_true",
)
args = parser.parse_args(argv, Args())
if len(version.Version(args.version).release) != 3:
raise ValueError(
f"Version argument {args.version} must contain major, minor, and patch version."
)
version.parse(args.version) # validate
if (match := VERSION.fullmatch(args.version)) is None:
msg = f"Version argument {args.version} is not a valid version."
raise ValueError(msg)
if len(match["release"].split(".")) < 3:
msg = f"Version argument {args.version} must contain major, minor, and patch version."
raise ValueError(msg)
flying-sheep marked this conversation as resolved.
Show resolved Hide resolved
return args


Expand Down Expand Up @@ -77,14 +82,7 @@ def main(argv: Sequence[str] | None = None) -> None:
# push
if not args.dry_run:
subprocess.run(
[
"git",
"push",
"--set-upstream",
"origin",
branch_name,
],
check=True,
["git", "push", "--set-upstream=origin", branch_name], check=True
)
else:
print("Dry run, not pushing")
Expand All @@ -95,15 +93,11 @@ def main(argv: Sequence[str] | None = None) -> None:
"gh",
"pr",
"create",
"--base",
base_branch,
"--title",
pr_title,
"--body",
pr_description,
"--label",
"skip-gpu-ci",
*(["--label", "no milestone"] if base_branch == "main" else []),
f"--base={base_branch}",
f"--title={pr_title}",
f"--body={pr_description}",
"--label=skip-gpu-ci",
*(["--label=no milestone"] if base_branch == "main" else []),
*(["--dry-run"] if args.dry_run else []),
],
check=True,
Expand Down
Loading