Skip to content

Commit

Permalink
Merge trunk.
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban committed Jul 31, 2024
2 parents 1f1a418 + 67c9fd2 commit fbb4cea
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 19 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -252,16 +255,13 @@ jobs:
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install pep517
- 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
# This was tag 1.9.0 on 2024-07-30
Expand Down
16 changes: 9 additions & 7 deletions admin/check_tag_version_match.py
Original file line number Diff line number Diff line change
@@ -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/"
Expand All @@ -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):
Expand All @@ -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)
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[build-system]
requires = [
"hatchling",
"wheel",
]
requires = ["hatchling"]
build-backend = "hatchling.build"


Expand Down
5 changes: 5 additions & 0 deletions src/towncrier/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/629.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed build-time dependency on `wheel`.
Empty file.
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/632.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 23 additions & 0 deletions src/towncrier/test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit fbb4cea

Please sign in to comment.