From 11f9297fade954a3b74c3765159f66303eb49fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Wed, 31 Jul 2024 08:28:08 +0200 Subject: [PATCH 1/3] Remove unused `wheel` build dependency (#629) Remove the `wheel` dependency as it is not used anywhere. Hatchling does not use `wheel` (and setuptools either bundled it or pulled it in automatically). --- .github/workflows/ci.yml | 2 +- pyproject.toml | 1 - src/towncrier/newsfragments/629.misc | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 src/towncrier/newsfragments/629.misc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 050f37b7..ad8f354c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -254,7 +254,7 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade pip python -m pip install pep517 - name: Display structure of files to be pushed diff --git a/pyproject.toml b/pyproject.toml index 01f99241..133ee710 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] requires = [ "hatchling", - "wheel", ] build-backend = "hatchling.build" diff --git a/src/towncrier/newsfragments/629.misc b/src/towncrier/newsfragments/629.misc new file mode 100644 index 00000000..0a4215f8 --- /dev/null +++ b/src/towncrier/newsfragments/629.misc @@ -0,0 +1 @@ +Removed build-time dependency on `wheel`. From 68a7a3b7e2f04a32a2eea670a5ad5c38913ff470 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 31 Jul 2024 09:06:50 +0200 Subject: [PATCH 2/3] Stop using deprecated packages in CI (#630) * Stop using deprecated packages in CI pep517 has been deprecated for a long time and we don't need it anymore, courtesy of importlib.metadata. * News fragment * Try a fake version to look at the output * Silence pip version warnings The default pip versions are good enought, nowadays. * Add debug output & give better name * Revert "Try a fake version to look at the output" This reverts commit 3aadb6a2f105125c48e3e18fe19493b764cad4b2. --- .github/workflows/ci.yml | 16 ++++++++-------- admin/check_tag_version_match.py | 16 +++++++++------- pyproject.toml | 4 +--- src/towncrier/newsfragments/630.misc.rst | 0 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 src/towncrier/newsfragments/630.misc.rst diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad8f354c..697d578d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ defaults: run: shell: bash +env: + PIP_DISABLE_PIP_VERSION_CHECK: "1" + jobs: build: name: ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }} @@ -250,18 +253,15 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.11 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pep517 + python-version: 3.12 - name: Display structure of files to be pushed run: ls --recursive dist/ - - name: Check matched tag version and branch version - on tag - run: python admin/check_tag_version_match.py "${{ github.ref }}" + - name: Ensure tag and package versions match. + run: | + python -Im pip install dist/*.whl + python -I admin/check_tag_version_match.py "${{ github.ref }}" - name: Publish to PyPI - on tag uses: pypa/gh-action-pypi-publish@a56da0b891b3dc519c7ee3284aff1fad93cc8598 diff --git a/admin/check_tag_version_match.py b/admin/check_tag_version_match.py index f340e040..25ae1809 100644 --- a/admin/check_tag_version_match.py +++ b/admin/check_tag_version_match.py @@ -1,15 +1,16 @@ # # Used during the release process to make sure that we release based on a -# tag that has the same version as the current twisted.__version. +# tag that has the same version as the current packaging metadata. # # Designed to be conditionally called inside GitHub Actions release job. # Tags should use PEP440 version scheme. # -# To be called as: admin/check_tag_version_match.py refs/tags/twisted-20.3.0 +# To be called as: admin/check_tag_version_match.py refs/tags/20.3.0 # + import sys -import pep517.meta +from importlib import metadata TAG_PREFIX = "refs/tags/" @@ -18,7 +19,8 @@ print("No tag check requested.") sys.exit(0) -branch_version = pep517.meta.load(".").version +pkg_version = metadata.version("towncrier") +print(f"Package version is {pkg_version}.") run_version = sys.argv[1] if not run_version.startswith(TAG_PREFIX): @@ -27,9 +29,9 @@ run_version = run_version[len(TAG_PREFIX) :] # noqa: E203 -if run_version != branch_version: - print(f"Branch is at '{branch_version}' while tag is '{run_version}'") +if run_version != pkg_version: + print(f"Package is at '{pkg_version}' while tag is '{run_version}'") exit(1) -print(f"All good. Branch and tag versions match for '{branch_version}'.") +print(f"All good. Package and tag versions match for '{pkg_version}'.") sys.exit(0) diff --git a/pyproject.toml b/pyproject.toml index 133ee710..4e46bdc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,5 @@ [build-system] -requires = [ - "hatchling", -] +requires = ["hatchling"] build-backend = "hatchling.build" diff --git a/src/towncrier/newsfragments/630.misc.rst b/src/towncrier/newsfragments/630.misc.rst new file mode 100644 index 00000000..e69de29b From 67c9fd2012da1b0cd4ea06de2bfcc4f4b582cf03 Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Wed, 31 Jul 2024 15:33:56 +0300 Subject: [PATCH 3/3] automatically ignore template files (#633) * automatically ignore template files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix cr * changelog * revert * CR fix * Update src/towncrier/_builder.py Co-authored-by: Adi Roiban * Update src/towncrier/newsfragments/632.bugfix.rst Co-authored-by: Adi Roiban * CR * Update src/towncrier/_builder.py * Update src/towncrier/_builder.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Adi Roiban --- docs/configuration.rst | 2 +- src/towncrier/_builder.py | 5 +++++ src/towncrier/newsfragments/632.bugfix.rst | 1 + src/towncrier/test/test_build.py | 23 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/towncrier/newsfragments/632.bugfix.rst diff --git a/docs/configuration.rst b/docs/configuration.rst index 955f62e2..4f253cd8 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -135,7 +135,7 @@ Top level keys ``towncrier check`` will fail if there are any news fragment files that have invalid filenames, except for those in the list. ``towncrier build`` will likewise fail, but only if this list has been configured (set to an empty list if there are no files to ignore). - Some filenames such as ``.gitignore`` and ``README`` are automatically ignored. However, if a custom template is stored in the news fragment directory, you should add it to this list. + Some filenames such as .gitignore, README.rst. README.md, and the template file, are automatically ignored. ``None`` by default. diff --git a/src/towncrier/_builder.py b/src/towncrier/_builder.py index 62a7d3f3..4192942a 100644 --- a/src/towncrier/_builder.py +++ b/src/towncrier/_builder.py @@ -115,6 +115,11 @@ def find_fragments( If strict, raise ClickException if any fragments have an invalid name. """ ignored_files = {".gitignore", ".keep", "readme", "readme.md", "readme.rst"} + if isinstance(config.template, str): + # Template can be a tuple of (package_name, resource_name). + # + # See https://github.com/twisted/towncrier/issues/634 + ignored_files.add(config.template) if config.ignore: ignored_files.update(filename.lower() for filename in config.ignore) diff --git a/src/towncrier/newsfragments/632.bugfix.rst b/src/towncrier/newsfragments/632.bugfix.rst new file mode 100644 index 00000000..ea6b68ca --- /dev/null +++ b/src/towncrier/newsfragments/632.bugfix.rst @@ -0,0 +1 @@ +When the template file is stored in the same directory with the news fragments, it is automatically ignored when checking for valid fragment file names. diff --git a/src/towncrier/test/test_build.py b/src/towncrier/test/test_build.py index c14fd582..aa989fd2 100644 --- a/src/towncrier/test/test_build.py +++ b/src/towncrier/test/test_build.py @@ -1631,6 +1631,29 @@ def test_invalid_fragment_name(self, runner): self.assertEqual(1, result.exit_code, result.output) self.assertIn("Invalid news fragment name: feature.124", result.output) + @with_project( + config=""" + [tool.towncrier] + package = "foo" + template = "foo/newsfragments/template.jinja" + """ + ) + def test_ignored_template_string(self, runner): + """ + Files used in `template` are automatically ignored. + """ + with open("foo/newsfragments/123.feature", "w") as f: + f.write("This has valid filename (control case)") + with open("foo/newsfragments/template.jinja", "w") as f: + f.write("Template file should be automatically ignored") + with open("foo/newsfragments/.gitignore", "w") as f: + f.write("gitignore is automatically ignored") + + result = runner.invoke( + _main, ["--draft", "--date", "01-01-2001", "--version", "1.0.0"] + ) + self.assertEqual(0, result.exit_code, result.output) + @with_project() def test_no_ignore_configured(self, runner): """