Skip to content

Commit

Permalink
Remove the release workflow when publish_to=none and mkdocs=n (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpgmaas authored Feb 14, 2023
1 parent c9614b1 commit 537ea66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def remove_dir(filepath: str) -> None:
if __name__ == "__main__":
if "{{cookiecutter.include_github_actions}}" != "y":
remove_dir(".github")
else:
if "{{cookiecutter.mkdocs}}" != "y" and "{{cookiecutter.publish_to}}" == "none":
remove_file(".github/workflows/on-release-main.yml")

if "{{cookiecutter.mkdocs}}" != "y":
remove_dir("docs")
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cookiecutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,14 @@ def test_not_codecov(cookies, tmp_path):
assert result.exit_code == 0
assert not os.path.isfile(f"{result.project_path}/codecov.yaml")
assert not os.path.isfile(f"{result.project_path}/.github/workflows/validate-codecov-config.yml")


def test_remove_release_workflow(cookies, tmp_path):
with run_within_dir(tmp_path):
result = cookies.bake(extra_context={"publish_to": "none", "mkdocs": "y"})
assert result.exit_code == 0
assert os.path.isfile(f"{result.project_path}/.github/workflows/on-release-main.yml")

result = cookies.bake(extra_context={"publish_to": "none", "mkdocs": "n"})
assert result.exit_code == 0
assert not os.path.isfile(f"{result.project_path}/.github/workflows/on-release-main.yml")

0 comments on commit 537ea66

Please sign in to comment.