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

Manage changelog #5

Merged
merged 4 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .azure-pipelines/stage-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ stages:
versionSpec: "3.7"
architecture: "x64"

- bash: |
RELEASE_VERSION=`git describe --exact-match $(Build.SourceBranch) | cut -b2-`
grep -q "## Aiolimiter $RELEASE_VERSION (.*)$" CHANGELOG.md
displayName: Check for release in the changelog

- bash: |
if [[ $(git ls-tree -r --name-only $(Build.SourceBranch) changelog.d/ | sort | tail -n+2) ]]; then
exit 1;
fi
displayName: Verify there are no towncrier fragments

- bash: |
curl -sSL https://github.com/raw/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python
echo "##vso[task.prependpath]$HOME/.poetry/bin/"
Expand All @@ -32,6 +43,9 @@ stages:
- bash: poetry install
displayName: Install dependencies

- bash: if [[ $(ls -A) ]]; then
displayName:

- bash: poetry build
displayName: 'Make tarball and universal wheel'

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
fix problems like typo corrections or such.
To add a new change log entry, please see
https://pip.pypa.io/en/latest/development/contributing/#news-entries
we named the news folder "changelog.d".
we named the news folder "changelog.d", and use Markdown to format
entries.

WARNING: Don't drop the next directive!
-->
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Corrected build process to ensure CHANGELOG.md is updated on release.
51 changes: 44 additions & 7 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path

from doit.action import CmdAction
from doit.exceptions import TaskFailed
from doit.tools import Interactive, run_once

DOIT_CONFIG = {"default_tasks": ["all"], "minversion": "0.31.0"}
Expand All @@ -26,15 +27,29 @@ def _path_sortkey(p):
return (p.is_dir(), *p.parts)


def is_towncrier_fragment(path):
parts = path.name.split(".")
return (
len(parts) > 1
and parts[0].isdigit()
and parts[0].isascii()
and parts[1] in {"feature", "bugfix", "doc", "removal", "misc"}
)


# source files
THIS = Path(__file__).resolve()
HERE = THIS.parent
PYPROJECT = HERE / "pyproject.toml"
SRC_PATH = HERE / "src"
SRC_FILES = sorted(SRC_PATH.rglob("*.py"), key=_path_sortkey)
TESTS_PATH = HERE / "tests"
TESTS_FILES = sorted(TESTS_PATH.rglob("*.py"), key=_path_sortkey)
DOC_PATH = HERE / "docs"
RST_FILES = sorted(DOC_PATH.rglob("*.rst"), key=_path_sortkey)
CHANGELOG_PATH = HERE / "changelog.d"
CHANGELOG_TEMPLATE = CHANGELOG_PATH / "towncrier_template.md"
CHANGELOG_FRAGMENTS = sorted(filter(is_towncrier_fragment, CHANGELOG_PATH.iterdir()))

ALL_PY_FILES = sorted(
[THIS, *SRC_FILES, *TESTS_FILES, *DOC_PATH.glob("*.py")], key=_path_sortkey
Expand All @@ -50,8 +65,7 @@ def _path_sortkey(p):
DIST_FILES = sorted(
[*DIST_PATH.glob("*.tar.gz"), *DIST_PATH.glob("*.whl")], key=_path_sortkey
)

# File lists
CHANGELOG = HERE / "CHANGELOG.md"


def with_poetry(*actions):
Expand Down Expand Up @@ -149,10 +163,11 @@ def task_tox():
}


def task_docs_spelling():
"""Check documentation spelling"""
def task_docs_checks():
"""Check documentation spelling and towncrier handling"""
make_cmd = with_poetry(["make", "spelling"])[0]
return {
yield {
"name": "docs_spelling",
"setup": ["devsetup"],
"actions": [CmdAction(make_cmd, cwd=DOC_PATH, shell=False)],
"file_dep": [
Expand All @@ -166,12 +181,34 @@ def task_docs_spelling():
"clean": True,
}

def check_towncrier_fragments(changed):
for path in map(Path, changed):
if not (is_towncrier_fragment(path) or path == CHANGELOG_TEMPLATE):
return TaskFailed(
f"{CHANGELOG_PATH.name}/{path.name} is not a valid towncrier "
f"fragment name."
)

yield {
"name": "towncrier_fragments",
"actions": [check_towncrier_fragments],
"file_dep": sorted(CHANGELOG_PATH.iterdir()),
}
yield {
"name": "towncrier",
"task_dep": ["docs_checks:towncrier_fragments"],
"setup": ["devsetup"],
"actions": with_poetry(["towncrier", "--draft"]),
"file_dep": [PYPROJECT, CHANGELOG_TEMPLATE, *CHANGELOG_FRAGMENTS],
}


def task_docs():
"""Build the documentation"""
make_cmd = with_poetry(["make", "html"])[0]
return {
"setup": ["devsetup"],
"task_dep": ["docs_checks"],
"actions": [CmdAction(make_cmd, cwd=DOC_PATH, shell=False)],
"file_dep": [
*SRC_FILES,
Expand All @@ -191,7 +228,7 @@ def task_build():
"setup": ["devsetup"],
"actions": ["poetry build"],
"task_dep": ["test", "docs"],
"file_dep": [HERE / "pyproject.toml", *ALL_PY_FILES],
"file_dep": [PYPROJECT, *ALL_PY_FILES],
"targets": [DIST_PATH, *DIST_FILES],
"clean": True,
}
Expand All @@ -205,4 +242,4 @@ def task_build():

def task_all():
"""Run all checks, then build the docs and release"""
return {"actions": [], "task_dep": ["tox", "docs_spelling", "docs", "build"]}
return {"actions": [], "task_dep": ["tox", "docs", "build"]}