diff --git a/template/.github/workflows/check_modified_history.yml b/template/.github/workflows/check_modified_history.yml new file mode 100644 index 0000000..f743574 --- /dev/null +++ b/template/.github/workflows/check_modified_history.yml @@ -0,0 +1,26 @@ +name : modified_history_check + +on : + pull_request: + types: + - opened + - synchronize + +jobs: + check-history: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check if HISTORY.rst was modified or created + run: | + git diff origin/${{ github.base_ref }} HEAD \ + --diff-filter=AMR \ + --name-only \ + -- HISTORY.rst | grep -q . || { + echo "ERROR: HISTORY.rst was not modified" + exit 1 + } + diff --git a/template/HISTORY.rst.jinja b/template/HISTORY.rst.jinja new file mode 100644 index 0000000..dad2dc0 --- /dev/null +++ b/template/HISTORY.rst.jinja @@ -0,0 +1,28 @@ +======= +History +======= + +[Unreleased] +------------ + +Added +^^^^^ + +Changed +^^^^^^^ + +Deprecated +^^^^^^^^^^ + +Removed +^^^^^^^ + +Fixed +^^^^^ + +{{ version }} ({{ '%Y-%m-%d' | strftime }}) +------------------ + +Added +^^^^^ +* First release on PyPI. \ No newline at end of file diff --git a/tests/test_copier.py b/tests/test_copier.py index 9916393..8ad43f4 100644 --- a/tests/test_copier.py +++ b/tests/test_copier.py @@ -1,4 +1,5 @@ import pytest +from datetime import date def test_project_folder(default_project): assert default_project.exit_code == 0 @@ -13,6 +14,8 @@ def test_project_folder(default_project): "pyproject.toml", "my_project/__init__.py", "my_project/my_project.py", + "HISTORY.rst", + ".github/workflows/check_modified_history.yml", ]) def test_generated_file_exists(default_project, file_name): assert default_project.project_dir.joinpath(file_name).exists() @@ -110,3 +113,10 @@ def test_content_project_slug_init(default_project, desired): content = default_project.project_dir.joinpath('my_project').joinpath( "__init__.py").read_text() assert desired in content, f"{desired!r} is not in content" + + +def test_content_history(default_project): + content = default_project.project_dir.joinpath( + "HISTORY.rst").read_text() + desired = f"0.1.0 ({date.today().strftime('%Y-%m-%d')})" + assert desired in content