Skip to content

Commit b9f7d7c

Browse files
committed
Modernize test and deploy workflows
* Use dedicated workflow for publishing. * Update RELEASING and DEVELOPER docs. * Rename `CHANGES` to `CHANGELOG`, more commonly used in pytest-dev.
1 parent dbdf7c2 commit b9f7d7c

File tree

8 files changed

+132
-215
lines changed

8 files changed

+132
-215
lines changed

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: deploy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version'
8+
required: true
9+
default: '1.2.3'
10+
11+
jobs:
12+
13+
package:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Build and Check Package
20+
uses: hynek/build-and-inspect-python-package@v2.10
21+
22+
deploy:
23+
needs: package
24+
runs-on: ubuntu-latest
25+
permissions:
26+
id-token: write # For PyPI trusted publishers.
27+
contents: write # For tag.
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Download Package
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: Packages
36+
path: dist
37+
38+
- name: Publish package to PyPI
39+
uses: pypa/gh-action-pypi-publish@v1.12.2
40+
with:
41+
attestations: true
42+
43+
- name: GitHub Release
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
gh release create v${{ github.event.inputs.version }} --target=${{ github.ref_name }} --title v${{ github.event.inputs.version }}
48+
gh pr merge ${{ github.ref_name }} --merge

.github/workflows/test.yml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
name: Test
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "test-me-*"
8+
9+
pull_request:
10+
branches:
11+
- "*"
412

513
env:
614
FORCE_COLOR: 1
715

16+
# Cancel running jobs for the same workflow and branch.
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
821
jobs:
22+
package:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Build and Check Package
27+
uses: hynek/build-and-inspect-python-package@v2.10
28+
929
test:
30+
needs: [package]
1031
runs-on: ${{ matrix.os }}
1132
strategy:
1233
fail-fast: false
@@ -18,31 +39,23 @@ jobs:
1839
steps:
1940
- uses: actions/checkout@v4
2041

42+
- name: Download Package
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: Packages
46+
path: dist
47+
2148
- name: Set up Python ${{ matrix.python-version }}
2249
uses: actions/setup-python@v5
2350
with:
2451
python-version: ${{ matrix.python-version }}
2552

26-
- name: Get pip cache dir
27-
id: pip-cache
28-
run: |
29-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
30-
31-
- name: Cache
32-
uses: actions/cache@v4
33-
with:
34-
path: ${{ steps.pip-cache.outputs.dir }}
35-
key:
36-
${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/tox.ini') }}
37-
restore-keys: |
38-
${{ matrix.os }}-${{ matrix.python-version }}-v1-
39-
40-
- name: Install dependencies
53+
- name: Install tox
4154
run: |
4255
python -m pip install --upgrade pip
43-
python -m pip install -e .
44-
python -m pip install -r tests/requirements.txt
56+
python -m pip install --upgrade tox
4557
4658
- name: Test
59+
shell: bash
4760
run: |
48-
pytest -vv
61+
tox run -e py --installpkg `find dist/*.tar.gz`
File renamed without changes.

DEVELOPER.rst

Lines changed: 1 addition & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ https://github.com/pytest-dev/unittest2pytest/actions.
88
Prior to pushing a pull request to GitHub, please test locally::
99

1010
pip install tox pytest
11-
tox # or tox -e py37,py38,py39
11+
tox -e py
1212

1313

1414
Version Scheme
@@ -20,196 +20,6 @@ This basically means that releases will look like `0.3`, `0.3.1`,
2020
`0.3.1.dev0`.
2121

2222

23-
How to Release
24-
=================
25-
26-
27-
Preparation
28-
-----------------
29-
30-
1. Get yourself an account at PyPI_ and TestPyPI_. Fill both
31-
credentials in your `~/.pypirc` file, as `described in the Python
32-
Wiki <https://wiki.python.org/moin/TestPyPI>`_.
33-
34-
* In difference to that description, list `pypitest` *first*. This
35-
will make `zest.releaser` push the release there first giving you
36-
a chance for last minute fixes.
37-
38-
2. Install `docutils` and `zest.releaser`, a helper for automating
39-
releasing a Python project::
40-
41-
pip install --user docutils zest.releaser
42-
43-
44-
Full Release Process
45-
---------------------
46-
47-
1. Prepare (see above).
48-
49-
2. Implement and close all issues and pull requests in a specific
50-
milestone.
51-
52-
3. Ensure everything relevant is committed and tested. ``git stash``
53-
your local changes which should not go into the release.
54-
55-
4. Be sure that the current code passes tests locally::
56-
57-
tox -e py37,py38,py39
58-
59-
5. Be sure `CI tests
60-
<https://github.com/pytest-dev/unittest2pytest/actions>`_ pass.
61-
62-
63-
Now we start with the main release process.
64-
65-
6. Set shell variables to be able to copy-and-paste the remaining
66-
snippets, e.g.::
67-
68-
version=0.3
69-
prev_version=0.2
70-
71-
7. Create the **release branch**::
72-
73-
git checkout -b release/$version
74-
75-
8. **Update versions** in source-code, Changelog, etc.::
76-
77-
prerelease # zest.releaser command
78-
79-
This will
80-
81-
- ask you a few questions - required version, etc.
82-
- remove `.devN` from the version string
83-
- update date and version in `CHANGES.rst`
84-
85-
9. Update **``CHANGES.rst``** and **``AUTHORS``**.
86-
87-
Where to look for possible changes? You can look in pull requests,
88-
issues, commits, mailing list or even the tool's cli options
89-
(new/removed options).
90-
91-
Authors should be updated based on merged pull requests::
92-
93-
git shortlog --numbered --summary --email v${prev_version}..HEAD
94-
95-
a. Check if the files are valid reStructuredText by running::
96-
97-
rst2html CHANGES.rst > /tmp/CHANGES.html
98-
xdg-open /tmp/CHANGES.html # opens file in your web-browser
99-
100-
b. If everything is fine, commit::
101-
102-
git commit -m "Update CHANGES and AUTHORS for release $version" \
103-
CHANGES.rst AUTHORS.txt
104-
105-
106-
10. In the **README**, update the versions in the badge-images and
107-
related links.
108-
109-
a. Verify the result be running::
110-
111-
git diff --color-words='.' README.rst
112-
113-
b. Again, check if the files are valid reStructuredText by running::
114-
115-
rst2html README.rst > /tmp/README.html
116-
xdg-open /tmp/README.html # opens file in your web-browser
117-
118-
c. If everything is fine, commit::
119-
120-
git commit -m 'Update versions in README.' README.rst
121-
README_CHANGE=$(git rev-parse --short HEAD) # remember this commit
122-
123-
11. Adjust whatever else is required for the release *now*.
124-
125-
126-
12. Complete the release:
127-
128-
a. Merge into branch `master`::
129-
130-
git checkout master
131-
git merge --no-ff -X theirs -m "Finished release $version." \
132-
release/$version
133-
134-
b. In case of a merge-conflict, resolve it using::
135-
136-
git gui # In the context-menu select "Use Local Version"
137-
git commit -m "Release $version."
138-
139-
140-
13. Run the release script ``release`` and it will do:
141-
142-
- create a signed tag for the released version
143-
- create and sign source archives
144-
- uploads them to PyPI
145-
146-
::
147-
148-
release # zest.releaser command
149-
150-
Submit to `testpypi` first! You can not change any file after
151-
you've uploaded it to PyPI!
152-
153-
14. Push the changes::
154-
155-
git push --follow-tags origin master
156-
157-
15. Create release on GitHub:
158-
159-
a. Go to the `unittest2pytest release page
160-
<https://github.com/pytest-dev/unittest2pytest/releases>`_
161-
162-
b. Edit the latest `tag` details.
163-
164-
c. Copy there changelog for the current release. This should look
165-
like `this one
166-
<https://github.com/pytest-dev/unittest2pytest/releases/tag/v0.3>`_
167-
168-
d. Upload the `.tar.gz`- and `.zip`-archives and GPG-signatures
169-
that where uploaded to |unittest2pytest@PyPI|_
170-
171-
Note: If you are using stuff like RequestBlocker or NoScript in
172-
your web-browser, mind to allow some additional access.
173-
174-
175-
Now we are going to perform some **post-release** steps:
176-
177-
16. Forward the release-branch to master and check it out::
178-
179-
git checkout master
180-
git branch -f release/$version master
181-
git checkout release/$version
182-
183-
17. Revert the version-related to the README (using the commit we
184-
remembered earlier)::
185-
186-
git revert $README_CHANGE
187-
188-
18. Run the release script ``postrelease``::
189-
190-
postrelease # zest.releaser command
191-
192-
This will
193-
194-
- increment version string for a new release: `3.0 -> 3.1.dev0`
195-
- prepare `CHANGES.rst` for the next release.
196-
197-
You need to manually check the `README` and the version in
198-
`CHANGES`.
199-
200-
19. Merge into branch `develop`::
201-
202-
git checkout develop
203-
git merge --no-ff -m "Finished release $version." release/$version
204-
205-
20. Check the diffs: it should only be version related stuff::
206-
207-
git diff origin/develop
208-
209-
21. Push the changes and delete the local release branch::
210-
211-
git push --follow-tags origin develop master
212-
git branch -d release/$version
21323

21424

21525
.. _PyPI: https://pypi.python.org/

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include CHANGES.rst
1+
include CHANGELOG.rst
22
include COPYING-GPLv3.txt
33
include README.rst
44

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Helps converting unittest test-cases to pytest
88

99
:Author: Hartmut Goebel <h.goebel@crazy-compilers.com>
1010
:Version: 0.5.dev0
11-
:Copyright: 2015-2019 by Hartmut Goebel
11+
:Copyright: 2015 by Hartmut Goebel
1212
:Licence: GNU Public Licence v3 or later (GPLv3+)
1313
:Homepage: https://github.com/pytest-dev/unittest2pytest
1414

RELEASING.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
=========================
2+
Releasing unittest2pytest
3+
=========================
4+
5+
This document describes the steps to make a new ``unittest2pytest`` release.
6+
7+
Version
8+
-------
9+
10+
``main`` should always be green and a potential release candidate. ``unittest2pytest`` follows
11+
semantic versioning, so given that the current version is ``X.Y.Z``, to find the next version number
12+
one needs to look at the ``CHANGELOG.rst`` file:
13+
14+
- If there any new feature, then we must make a new **minor** release: next
15+
release will be ``X.Y+1.0``.
16+
17+
- Otherwise it is just a **bug fix** release: ``X.Y.Z+1``.
18+
19+
20+
Steps
21+
-----
22+
23+
To publish a new release ``X.Y.Z``, the steps are as follows:
24+
25+
#. Create a new branch named ``release-X.Y.Z`` from the latest ``main``.
26+
27+
#. Update the version in ``unittest2pytest/__init__.py``.
28+
29+
#. Update the ``CHANGELOG.rst`` file with the new release information.
30+
31+
#. Commit and push the branch to ``upstream`` and open a PR.
32+
33+
#. Once the PR is **green** and **approved**, start the ``deploy`` workflow:
34+
35+
.. code-block:: console
36+
37+
gh workflow run deploy.yml -R pytest-dev/unittest2pytest --ref release-VERSION --field version=VERSION
38+
39+
The PR will be automatically merged.
40+
41+
#. Update the version in ``unittest2pytest/__init__.py`` and ``CHANGELOG.rst`` for the next release (usually use "minor+1" with the ``.dev0`` suffix).
42+

0 commit comments

Comments
 (0)