Skip to content

Commit

Permalink
FEAT: add --no-cd flag (#437)
Browse files Browse the repository at this point in the history
* ENH: remove release drafter if `--no-cd`
  • Loading branch information
redeboer authored Oct 16, 2024
1 parent a890e79 commit ada34d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
15 changes: 14 additions & 1 deletion src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def main(argv: Sequence[str] | None = None) -> int:
doc_apt_packages=_to_list(args.doc_apt_packages),
github_pages=args.github_pages,
keep_pr_linting=args.keep_pr_linting,
no_cd=args.no_cd,
no_macos=args.no_macos,
no_milestones=args.no_milestones,
no_pypi=args.no_pypi,
Expand All @@ -109,7 +110,13 @@ def main(argv: Sequence[str] | None = None) -> int:
if args.no_ruff:
do(black.main, precommit_config, has_notebooks)
if not args.no_github_actions:
do(release_drafter.main, repo_name, repo_title, args.repo_organization)
do(
release_drafter.main,
args.no_cd,
repo_name,
repo_title,
args.repo_organization,
)
do(mypy.main)
do(pyproject.main, args.excluded_python_versions, no_pypi=args.no_pypi)
do(pyright.main, package_manager, precommit_config)
Expand Down Expand Up @@ -227,6 +234,12 @@ def _create_argparse() -> ArgumentParser:
default=False,
help="Run tox command through pixi",
)
parser.add_argument(
"--no-cd",
action="store_true",
default=False,
help="Do not add any GitHub workflows for continuous deployment",
)
parser.add_argument(
"--no-cspell-update",
action="store_true",
Expand Down
6 changes: 5 additions & 1 deletion src/compwa_policy/check_dev_files/github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def main(
doc_apt_packages: list[str],
github_pages: bool,
keep_pr_linting: bool,
no_cd: bool,
no_macos: bool,
no_milestones: bool,
no_pypi: bool,
Expand All @@ -51,7 +52,10 @@ def main(
test_extras: list[str],
) -> None:
with Executor() as do:
do(_update_cd_workflow, no_milestones, no_pypi, no_version_branches)
if no_cd:
remove_workflow("cd.yml")
else:
do(_update_cd_workflow, no_milestones, no_pypi, no_version_branches)
do(
_update_ci_workflow,
precommit,
Expand Down
18 changes: 15 additions & 3 deletions src/compwa_policy/check_dev_files/release_drafter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml


def main(repo_name: str, repo_title: str, organization: str) -> None:
update_file(CONFIG_PATH.release_drafter_workflow)
_update_draft(repo_name, repo_title, organization)
def main(no_cd: bool, repo_name: str, repo_title: str, organization: str) -> None:
if no_cd:
paths_to_remove = [
CONFIG_PATH.release_drafter_workflow,
CONFIG_PATH.release_drafter_config,
]
paths_to_remove = [p for p in paths_to_remove if p.is_file()]
if paths_to_remove:
for path in paths_to_remove:
path.unlink()
msg = f"Removed {', '.join(map(str, paths_to_remove))}"
raise PrecommitError(msg)
else:
update_file(CONFIG_PATH.release_drafter_workflow)
_update_draft(repo_name, repo_title, organization)


def _update_draft(repo_name: str, repo_title: str, organization: str) -> None:
Expand Down

0 comments on commit ada34d1

Please sign in to comment.