diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a36fb9d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Publish package to PyPI + +on: + release: + types: + - published + +jobs: + build: + name: Build distribution packages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install pypa/build + run: | + python -m pip install --user build + - name: Build packages + run: | + pyproject-build + - uses: actions/upload-artifact@v3 + with: + name: dist + path: dist/ + if-no-files-found: error + publish-to-test-pypi: + name: Publish packages to Test PyPI + runs-on: ubuntu-latest + needs: [build] + environment: test-pypi + steps: + - uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + - name: Publish packages to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: '${{ secrets.TEST_PYPI_API_TOKEN }}' + repository_url: https://test.pypi.org/legacy/ + print_hash: true + publish-to-pypi: + name: Publish packages to PyPI + runs-on: ubuntu-latest + needs: [build] + environment: pypi + steps: + - uses: actions/download-artifact@v3 + with: + name: dist + path: dist/ + - name: Publish packages to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: '${{ secrets.PYPI_API_TOKEN }}' + print_hash: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a864d51..9101a3c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: '${{ matrix.os }}' # https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/ if: > github.event_name != 'pull_request' @@ -15,17 +15,25 @@ jobs: matrix: # Not all Python versions are available for linux AND x64 # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json - python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11.0-beta - 3.11', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9'] + os: ['ubuntu-latest'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9'] extra: ['', '-smtp'] # The forced pytest versions correspond with the lower bounds in tox.ini pytest-version: ['', '--force-dep pytest==4', '--force-dep pytest==6.2.4'] + include: + - os: 'ubuntu-20.04' + python-version: '3.5' + pytest-version: '' + - os: 'ubuntu-20.04' + python-version: '3.5' + pytest-version: '--force-dep pytest==4' + - os: 'ubuntu-20.04' + python-version: '3.6' exclude: - - python-version: '3.5' - pytest-version: '--force-dep pytest==6.2.4' - - python-version: '3.10' - pytest-version: '--force-dep pytest==4' - - python-version: '3.11.0-beta - 3.11' - pytest-version: '--force-dep pytest==4' + - python-version: '3.10' + pytest-version: '--force-dep pytest==4' + - python-version: '3.11' + pytest-version: '--force-dep pytest==4' fail-fast: false steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e08632..3cb4030 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,6 +43,6 @@ repos: args: [--py3-plus] - repo: https://github.com/rhysd/actionlint - rev: v1.6.15 + rev: v1.6.23 hooks: - id: actionlint-docker diff --git a/AUTHORS b/AUTHORS index 1e3c288..9fb0982 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,7 +1,15 @@ Sebastian Rahlf (maintainer) Muhammad Hallaj Subery Thomas Weißschuh +Ulrich Petri +Yuya Kusakabe +Bruno Oliveira Benjamin Wohlwend -Jason R. Coombs +Jason R. Coombs David Zaslavsky (maintainer) Corey Oordt (maintainer) +Kian-Meng Ang +Michał Górny +Hasan Ramezani +Felix Yan +Henri Hulski diff --git a/CHANGES b/CHANGES index 1ecf38b..30088ef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +0.7.1 (2023-01-29) +------------------ + +Update SMTP server code to work with aiosmtpd >=1.4.3 +Fix GitHub Actions configuration for Python 3.5 and 3.6 +Add support for Python 3.11 (or at least, list it explicitly in the classifiers) +Update the AUTHORS file +Add a workflow to push packages to PyPI using GitHub Actions + 0.7.0 (2022-08-30) ------------------ diff --git a/README.rst b/README.rst index 69cabb7..aa6cbb9 100644 --- a/README.rst +++ b/README.rst @@ -218,18 +218,26 @@ Preparing a release For package maintainers, here is how we release a new version: #. Ensure that the ``CHANGES`` file is up to date with the latest changes. -#. Create a tag whose name is the `PEP 440`_-compliant version number prefixed - by ``v``, making sure to include at least three version number components - (e.g. ``v0.6.0``). -#. Make sure that all tests pass on the tagged version. -#. Push the tag to Github. -#. Make a fresh clone of the repository, and in the root directory of the new - clone, run ``pyproject-build`` (from the `build`_ package). This will create - source and wheel packages under ``dist/``. -#. Upload the source and wheel to PyPI using ``twine upload`` (see `twine`_). -#. Using the `new release form on Github`_, prepare notes for the new release - following the pattern of previous releases. The "Auto-generate release notes" - button will be useful in summarizing the changes since the last release. +#. Make sure that all tests pass on the version you want to release. +#. Use the `new release form on Github`_ (or some other equivalent method) to + create a new release, following the pattern of previous releases. + + * Each release has to be based on a tag. You can either create the tag first + (e.g. using ``git tag``) and then make a release from that tag, or you can + have Github create the tag as part of the process of making a release; + either way works. + * The tag name **must** be the `PEP 440`_-compliant version number prefixed + by ``v``, making sure to include at least three version number components + (e.g. ``v0.6.0``). + * The "Auto-generate release notes" button will be useful in summarizing + the changes since the last release. + +#. Using either the `release workflows page`_ or the link in the email you + received about a "Deployment review", go to the workflow run created for + the new release and click "Review deployments", then either approve or reject + the two deployments, one to Test PyPI and one to real PyPI. (It should not be + necessary to reject a deployment unless something really weird happens.) + Once the deployment is approved, Github will automatically upload the files. ---- @@ -254,3 +262,4 @@ For package maintainers, here is how we release a new version: .. _build: https://pypa-build.readthedocs.io/en/latest/ .. _twine: https://twine.readthedocs.io/en/stable/ .. _new release form on Github: https://github.com/pytest-dev/pytest-localserver/releases/new +.. _release workflows page: https://github.com/pytest-dev/pytest-localserver/actions/workflows/release.yml diff --git a/pytest_localserver/smtp.py b/pytest_localserver/smtp.py index ac247b1..7779efb 100644 --- a/pytest_localserver/smtp.py +++ b/pytest_localserver/smtp.py @@ -130,7 +130,11 @@ def stop(self, timeout=None): # be called more than once safely # - It passes the timeout argument to Thread.join() if self.loop.is_running(): - self.loop.call_soon_threadsafe(self._stop) + try: + self.loop.call_soon_threadsafe(self.cancel_tasks) + except AttributeError: + # for aiosmtpd < 1.4.3 + self.loop.call_soon_threadsafe(self._stop) if self._thread is not None: self._thread.join(timeout) self._thread = None diff --git a/setup.py b/setup.py index bb5277f..aba3966 100644 --- a/setup.py +++ b/setup.py @@ -65,6 +65,7 @@ def run(self): "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Software Development :: Testing", ], )