From eb41727179765ccecf87dfb68366c927ad929af4 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Mon, 11 Jul 2022 17:02:50 +0100 Subject: [PATCH] Updates from cookiecutter --- .cookiecutter/cookiecutter.json | 6 +++--- .github/dependabot.yml | 2 +- .github/workflows/ci.yml | 2 +- Makefile | 2 +- bin/make_template | 13 ++++++++++--- tests/functional/cli_test.py | 11 +++++++++++ 6 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 tests/functional/cli_test.py diff --git a/.cookiecutter/cookiecutter.json b/.cookiecutter/cookiecutter.json index d02ccea..4398e5b 100644 --- a/.cookiecutter/cookiecutter.json +++ b/.cookiecutter/cookiecutter.json @@ -10,11 +10,11 @@ "python_versions": "3.10.4, 3.9.12, 3.8.13", "github_owner": "hypothesis", "copyright_holder": "Hypothesis", - "public": "no", + "visibility": "private", "console_script": "yes", - "__dependabot_interval": "weekly", + "dependabot_interval": "monthly", "__entry_point": "cookiecutter-pypackage-test", "__github_url": "https://github.com/hypothesis/cookiecutter-pypackage-test", "__pypi_url": "https://pypi.org/project/cookiecutter-pypackage-test" } -} \ No newline at end of file +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6c2ba5f..1c82127 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ updates: - package-ecosystem: "pip" directory: "/" schedule: - interval: "weekly" + interval: "monthly" day: "sunday" time: "00:00" timezone: "Europe/London" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49ef0ca..c584c9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI on: - pull_request: + push: workflow_dispatch: schedule: - cron: '0 1 * * *' diff --git a/Makefile b/Makefile index 1962c05..c8ae2a9 100644 --- a/Makefile +++ b/Makefile @@ -70,7 +70,7 @@ sure: .PHONY: template $(call help,make template,"update from the latest cookiecutter template") template: python - @pyenv exec tox -e template -- $(cookiecutter) + @pyenv exec tox -e template -- $$(if [ -n "$${template+x}" ]; then echo "--template $$template"; fi) $$(if [ -n "$${checkout+x}" ]; then echo "--checkout $$checkout"; fi) $$(if [ -n "$${directory+x}" ]; then echo "--directory $$directory"; fi) .PHONY: clean $(call help,make clean,"delete temporary files etc") diff --git a/bin/make_template b/bin/make_template index 74f5cda..3eb117a 100755 --- a/bin/make_template +++ b/bin/make_template @@ -1,7 +1,7 @@ #!/usr/bin/env python3 +import argparse import json import os -import sys from pathlib import Path from tempfile import TemporaryDirectory @@ -14,10 +14,17 @@ extra_context = config.get("extra_context", {}) extra_context["__ignore__"] = config.get("ignore", []) extra_context["__target_dir__"] = Path(os.getcwd()) +parser = argparse.ArgumentParser(description="Update the project from the cookiecutter template") +parser.add_argument("--template", help="the cookiecutter template to use (default: what's in cookiecutter.json)") +parser.add_argument("--checkout", help="the branch, tag or commit of the cookiecutter template to use (default: what's in cookiecutter.json)") +parser.add_argument("--directory", help="the directory within the cookiecutter repo to use to use (default: what's in cookiecutter.json)") +args = parser.parse_args() + with TemporaryDirectory() as tmpdirname: cookiecutter( - template=sys.argv[1] if len(sys.argv) >= 2 else config["template"], - directory=config["directory"], + template=args.template or config.get("template"), + checkout=args.checkout or config.get("checkout"), + directory=args.directory or config.get("directory"), extra_context=extra_context, no_input=True, overwrite_if_exists=True, diff --git a/tests/functional/cli_test.py b/tests/functional/cli_test.py new file mode 100644 index 0000000..4628074 --- /dev/null +++ b/tests/functional/cli_test.py @@ -0,0 +1,11 @@ +from subprocess import run + + +def test_help(): + """Test the cookiecutter-pypackage-test --help command.""" + run(["cookiecutter-pypackage-test", "--help"], check=True) + + +def test_version(): + """Test the cookiecutter-pypackage-test --version command.""" + run(["cookiecutter-pypackage-test", "--version"], check=True)