summaryrefslogtreecommitdiffstats
path: root/third_party/python/pytest/tasks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/python/pytest/tasks
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/pytest/tasks')
-rw-r--r--third_party/python/pytest/tasks/__init__.py10
-rw-r--r--third_party/python/pytest/tasks/generate.py118
-rw-r--r--third_party/python/pytest/tasks/release.minor.rst27
-rw-r--r--third_party/python/pytest/tasks/release.patch.rst17
-rw-r--r--third_party/python/pytest/tasks/requirements.txt6
5 files changed, 178 insertions, 0 deletions
diff --git a/third_party/python/pytest/tasks/__init__.py b/third_party/python/pytest/tasks/__init__.py
new file mode 100644
index 0000000000..ea5b1293e3
--- /dev/null
+++ b/third_party/python/pytest/tasks/__init__.py
@@ -0,0 +1,10 @@
+"""
+Invoke tasks to help with pytest development and release process.
+"""
+
+import invoke
+
+from . import generate
+
+
+ns = invoke.Collection(generate)
diff --git a/third_party/python/pytest/tasks/generate.py b/third_party/python/pytest/tasks/generate.py
new file mode 100644
index 0000000000..398af70c94
--- /dev/null
+++ b/third_party/python/pytest/tasks/generate.py
@@ -0,0 +1,118 @@
+"""
+Invoke development tasks.
+"""
+from pathlib import Path
+from subprocess import check_output, check_call
+
+import invoke
+
+
+@invoke.task(help={"version": "version being released"})
+def announce(ctx, version):
+ """Generates a new release announcement entry in the docs."""
+ # Get our list of authors
+ stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
+ stdout = stdout.decode("utf-8")
+ last_version = stdout.strip()
+
+ stdout = check_output(
+ ["git", "log", "{}..HEAD".format(last_version), "--format=%aN"]
+ )
+ stdout = stdout.decode("utf-8")
+
+ contributors = set(stdout.splitlines())
+
+ template_name = "release.minor.rst" if version.endswith(
+ ".0"
+ ) else "release.patch.rst"
+ template_text = Path(__file__).parent.joinpath(template_name).read_text(
+ encoding="UTF-8"
+ )
+
+ contributors_text = "\n".join(
+ "* {}".format(name) for name in sorted(contributors)
+ ) + "\n"
+ text = template_text.format(version=version, contributors=contributors_text)
+
+ target = Path(__file__).parent.joinpath(
+ "../doc/en/announce/release-{}.rst".format(version)
+ )
+ target.write_text(text, encoding="UTF-8")
+ print("[generate.announce] Generated {}".format(target.name))
+
+ # Update index with the new release entry
+ index_path = Path(__file__).parent.joinpath("../doc/en/announce/index.rst")
+ lines = index_path.read_text(encoding="UTF-8").splitlines()
+ indent = " "
+ for index, line in enumerate(lines):
+ if line.startswith("{}release-".format(indent)):
+ new_line = indent + target.stem
+ if line != new_line:
+ lines.insert(index, new_line)
+ index_path.write_text("\n".join(lines) + "\n", encoding="UTF-8")
+ print("[generate.announce] Updated {}".format(index_path.name))
+ else:
+ print(
+ "[generate.announce] Skip {} (already contains release)".format(
+ index_path.name
+ )
+ )
+ break
+
+ check_call(["git", "add", str(target)])
+
+
+@invoke.task()
+def regen(ctx):
+ """Call regendoc tool to update examples and pytest output in the docs."""
+ print("[generate.regen] Updating docs")
+ check_call(["tox", "-e", "regen"])
+
+
+@invoke.task()
+def make_tag(ctx, version):
+ """Create a new, local tag for the release, only if the repository is clean."""
+ from git import Repo
+
+ repo = Repo(".")
+ if repo.is_dirty():
+ print("Current repository is dirty. Please commit any changes and try again.")
+ raise invoke.Exit(code=2)
+
+ tag_names = [x.name for x in repo.tags]
+ if version in tag_names:
+ print("[generate.make_tag] Delete existing tag {}".format(version))
+ repo.delete_tag(version)
+
+ print("[generate.make_tag] Create tag {}".format(version))
+ repo.create_tag(version)
+
+
+@invoke.task(help={"version": "version being released"})
+def pre_release(ctx, version):
+ """Generates new docs, release announcements and creates a local tag."""
+ announce(ctx, version)
+ regen(ctx)
+ changelog(ctx, version, write_out=True)
+
+ msg = "Preparing release version {}".format(version)
+ check_call(["git", "commit", "-a", "-m", msg])
+
+ make_tag(ctx, version)
+
+ print()
+ print("[generate.pre_release] Please push your branch and open a PR.")
+
+
+@invoke.task(
+ help={
+ "version": "version being released",
+ "write_out": "write changes to the actual changelog",
+ }
+)
+def changelog(ctx, version, write_out=False):
+ if write_out:
+ addopts = []
+ else:
+ addopts = ["--draft"]
+ check_call(["towncrier", "--yes", "--version", version] + addopts)
diff --git a/third_party/python/pytest/tasks/release.minor.rst b/third_party/python/pytest/tasks/release.minor.rst
new file mode 100644
index 0000000000..bdd8282cfa
--- /dev/null
+++ b/third_party/python/pytest/tasks/release.minor.rst
@@ -0,0 +1,27 @@
+pytest-{version}
+=======================================
+
+The pytest team is proud to announce the {version} release!
+
+pytest is a mature Python testing tool with more than a 2000 tests
+against itself, passing on many different interpreters and platforms.
+
+This release contains a number of bugs fixes and improvements, so users are encouraged
+to take a look at the CHANGELOG:
+
+ http://doc.pytest.org/en/latest/changelog.html
+
+For complete documentation, please visit:
+
+ http://docs.pytest.org
+
+As usual, you can upgrade from pypi via:
+
+ pip install -U pytest
+
+Thanks to all who contributed to this release, among them:
+
+{contributors}
+
+Happy testing,
+The Pytest Development Team
diff --git a/third_party/python/pytest/tasks/release.patch.rst b/third_party/python/pytest/tasks/release.patch.rst
new file mode 100644
index 0000000000..1982dc353c
--- /dev/null
+++ b/third_party/python/pytest/tasks/release.patch.rst
@@ -0,0 +1,17 @@
+pytest-{version}
+=======================================
+
+pytest {version} has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+ pip install --upgrade pytest
+
+The full changelog is available at http://doc.pytest.org/en/latest/changelog.html.
+
+Thanks to all who contributed to this release, among them:
+
+{contributors}
+
+Happy testing,
+The pytest Development Team
diff --git a/third_party/python/pytest/tasks/requirements.txt b/third_party/python/pytest/tasks/requirements.txt
new file mode 100644
index 0000000000..db54e76e85
--- /dev/null
+++ b/third_party/python/pytest/tasks/requirements.txt
@@ -0,0 +1,6 @@
+-e .
+gitpython
+invoke
+towncrier
+tox
+wheel