Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce towncrier #1201

Merged
merged 25 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6134831
Introduce towncrier with basic configuration
Gitznik Jan 11, 2024
c7fc62e
Format changelog according to keep a changelog
Gitznik Jan 11, 2024
c4475fb
Add pre-commit hook
Gitznik Jan 11, 2024
e2da3c2
Add changelog entry
Gitznik Jan 11, 2024
d35749f
Update PR template
Gitznik Jan 11, 2024
c08ba9e
Switch to default fragment types
Gitznik Jan 12, 2024
24c3c42
Update .github/PULL_REQUEST_TEMPLATE.md
gaborbernat Jan 12, 2024
7b35d0e
Update news contribution docs
Gitznik Jan 12, 2024
4fbe258
Update bump changelog workflow
Gitznik Jan 12, 2024
7d12bf6
Merge remote-tracking branch 'refs/remotes/origin/introduce_towncrier…
Gitznik Jan 12, 2024
5888008
Merge branch 'main' into introduce_towncrier
Gitznik Jan 12, 2024
c932544
Remove redundant news fragments
Gitznik Jan 12, 2024
8def969
Add empty gitignore file to make sure changelog.d folder is tracked
Gitznik Jan 12, 2024
7b3532e
Apply suggestions from code review
Gitznik Jan 13, 2024
a977247
Add changelog entry
Gitznik Jan 12, 2024
a085950
Build changelog during `build_docs` nox command
Gitznik Jan 13, 2024
30b5113
Moved towncrier changelog entry to docs block
Gitznik Jan 13, 2024
cdcff25
Stop adding version number to top of changelog via mkdocs script
Gitznik Jan 13, 2024
cce41eb
Render current newsfragments cleanly during build docs
Gitznik Jan 13, 2024
efc1df6
Remove extra stdout lines from towncrier build step
Gitznik Jan 13, 2024
cfdd130
Add draft changelog file to gitignore
Gitznik Jan 13, 2024
0e4f166
Add upcoming changes to prod changelog
Gitznik Jan 13, 2024
7512219
Remove draft changelog in site after build
Gitznik Jan 14, 2024
60d0290
Merge branch 'main' into introduce_towncrier
Gitznik Jan 14, 2024
87c7720
Create news fragment for current dev changelog
Gitznik Jan 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- add an 'x' in the brackets below -->

- [ ] I have added an entry to `docs/changelog.md`
- [ ] I have added a news fragment under `changelog.d/` (if the patch affects the end users)

## Summary of changes

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
- name: Create pull request branch
run: git switch -c "bump-changelog-for-${RELEASE_VERSION}"
- name: Update changelog
run: echo -e "## dev\n\n## $RELEASE_VERSION\n$(tail -n +2 CHANGELOG.md)" > CHANGELOG.md
run: pipx run towncrier build --yes --version $RELEASE_VERSION
- name: Commit and push change
run: |
git config --global user.name 'github-actions[bot]'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ __pycache__
build
*.whl
/pipx.1
/docs/_draft_changelog.md
251 changes: 158 additions & 93 deletions CHANGELOG.md

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@ Thanks for your interest in contributing to pipx!
Everyone who interacts with the pipx project via codebase, issue tracker, chat rooms, or otherwise is expected to follow
the [PSF Code of Conduct](https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md).


## Submitting changes

1. Fork [the GitHub repository](https://github.com/pypa/pipx).
2. Make a branch off of `main` and commit your changes to it.
3. Add a changelog entry.
4. Submit a pull request to the `main` branch on GitHub, referencing an
open issue.

### Changelog entries

The `CHANGELOG.md` file is built by
[towncrier](https://pypi.org/project/towncrier/) from news fragments in the
`changelog.d/` directory. To add an entry, create a news fragment in that directory
named `{number}.{type}.md`, where `{number}` is the issue number,
and `{type}` is one of `feature`, `bugfix`, `doc`, `removal`, or `misc`.

For example, if your issue number is 1234 and it's fixing a bug, then you
would create `changelog.d/1234.bugfix.md`. PRs can span multiple
categories by creating multiple files: if you added a feature and
deprecated/removed an old feature for issue #5678, you would create
`changelog.d/5678.feature.md` and `changelog.d/5678.removal.md`.

A changelog entry is meant for end users and should only contain details
relevant to them. In order to maintain a consistent style, please keep
the entry to the point, in sentence case, shorter than 80 characters,
and in an imperative tone. An entry should complete the sentence "This
change will ...". If one line is not enough, use a summary line in an
imperative tone, followed by a description of the change in one or more
paragraphs, each wrapped at 80 characters and separated by blank lines.

You don't need to reference the pull request or issue number in a
changelog entry, since towncrier will add a link using the number in the
file name. Similarly, you don't need to add your name to the entry,
since that will be associated with the pull request.

## Running pipx For Development

To develop `pipx`, either create a [developer environment](#creating-a-developer-environment), or perform an editable
Expand Down
1 change: 1 addition & 0 deletions changelog.d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
1 change: 1 addition & 0 deletions changelog.d/1161.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Introduce towncrier for managing the changelog
1 change: 1 addition & 0 deletions changelog.d/1198.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add workaround for using pipx applications in shebang under macOS
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ plugins:
- gen-files:
scripts:
- scripts/gen_doc_pages.py
- macros
25 changes: 24 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import subprocess
import sys
from pathlib import Path
Expand All @@ -6,7 +7,7 @@

PYTHON_ALL_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
PYTHON_DEFAULT_VERSION = "3.12"
DOC_DEPENDENCIES = ["jinja2", "mkdocs", "mkdocs-material", "mkdocs-gen-files"]
DOC_DEPENDENCIES = ["jinja2", "mkdocs", "mkdocs-material", "mkdocs-gen-files", "mkdocs-macros-plugin", "towncrier"]
MAN_DEPENDENCIES = ["argparse-manpage[setuptools]"]
TEST_DEPENDENCIES = ["pytest", "pypiserver[passlib]", 'setuptools; python_version>="3.12"', "pytest-cov"]
# Packages whose dependencies need an intact system PATH to compile
Expand Down Expand Up @@ -55,6 +56,22 @@ def tests_with_options(session: nox.Session, *, net_pypiserver: bool) -> None:
session.notify("cover")


def create_upcoming_changelog(session: nox.Session) -> Path:
draft_changelog_content = session.run("towncrier", "build", "--version", "Upcoming", "--draft", silent=True)
draft_changelog = Path("docs", "_draft_changelog.md")
if draft_changelog_content and "No significant changes" not in draft_changelog_content:
lines_to_keep = draft_changelog_content.split("\n")
changelog_start = 0
for i, line in enumerate(lines_to_keep):
if line.startswith("##"):
changelog_start = i
break
lines_to_keep[changelog_start] = "## Planned for next release"
clean_changelog_content = "\n".join(lines_to_keep[changelog_start:])
draft_changelog.write_text(clean_changelog_content)
return draft_changelog


@nox.session(python=PYTHON_ALL_VERSIONS)
def tests(session: nox.Session) -> None:
"""Tests using local pypiserver only"""
Expand Down Expand Up @@ -112,13 +129,19 @@ def build_docs(session: nox.Session) -> None:
site_dir = session.posargs or ["site/"]
session.install(*DOC_DEPENDENCIES, ".")
session.env["PIPX__DOC_DEFAULT_PYTHON"] = "typically the python used to execute pipx"
upcoming_changelog = create_upcoming_changelog(session)
session.run("mkdocs", "build", "--strict", "--site-dir", *site_dir)
upcoming_changelog.unlink(missing_ok=True)
for site in site_dir:
shutil.rmtree(Path(site, "_draft_changelog"))


@nox.session(python=PYTHON_DEFAULT_VERSION)
def watch_docs(session: nox.Session) -> None:
session.install(*DOC_DEPENDENCIES, ".")
upcoming_changelog = create_upcoming_changelog(session)
session.run("mkdocs", "serve", "--strict")
upcoming_changelog.unlink(missing_ok=True)


@nox.session(python=PYTHON_DEFAULT_VERSION)
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ lint.mccabe.max-complexity = 15
[tool.pytest.ini_options]
markers = ["all_packages: test install with maximum number of packages"]

[tool.towncrier]
directory = "changelog.d"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
underlines = ["", "", ""]
title_format = "## [{version}](https://github.com/pypa/pipx/tree/{version}) - {project_date}"
issue_format = "[#{issue}](https://github.com/pypa/pipx/issues/{issue})"
package = "pipx"

[[tool.mypy.overrides]]
module = ["pipx.version", "pycowsay.*"]
ignore_missing_imports = true
5 changes: 0 additions & 5 deletions scripts/gen_doc_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@ def get_help(cmd: Optional[str]) -> str:
with mkdocs_gen_files.open("docs.md", "wt") as file_handler:
file_handler.write(env.get_template("docs.md").render(**params))
file_handler.write("\n")

with mkdocs_gen_files.open("changelog.md", "rt") as file_handler:
text = file_handler.read()
with mkdocs_gen_files.open("changelog.md", "wt") as file_handler:
file_handler.write(f"## {__version__}" + text[len("## dev") :])