Skip to content

Commit

Permalink
Update to modern build / package practices
Browse files Browse the repository at this point in the history
* define pyproject.toml with tool configuration
* define setuptools dependencies for test extras
* update to a moder tox config based on attrs
* configure RTD and coverage in standard ways
* switch to an RST changelog and towncrier
* check the manifest on CI

The marquee change here is a switch to github actions, instead of
Travis. While this commit won't turn off Travis, the one after it will.
  • Loading branch information
offbyone committed Oct 21, 2020
1 parent ae3666d commit e539290
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 111 deletions.
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

101 changes: 101 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
name: CI

on:
push:
branches: ["master", "ci-testing"]

pull_request:
branches: ["master"]

workflow_dispatch:

jobs:
tests:
name: "Python ${{ matrix.python-version }}"
runs-on: "ubuntu-latest"
env:
USING_COVERAGE: "3.7,3.8"

strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "pypy2"
# disabled due to one failing test
# - "pypy3"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
set -xe
python -VV
python -msite
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"

# We always use a modern Python version for combining coverage to prevent
# parsing errors in older versions for modern code.
- uses: "actions/setup-python@v2"
with:
python-version: "3.8"

- name: "Combine coverage"
run: |
set -xe
python -m pip install coverage[toml]
python -m coverage combine
python -m coverage xml
if: "contains(env.USING_COVERAGE, matrix.python-version)"
- name: "Upload coverage to Codecov"
if: "contains(env.USING_COVERAGE, matrix.python-version)"
uses: "codecov/codecov-action@v1"
with:
fail_ci_if_error: true

package:
name: "Build & verify package"
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.8"

- name: "Install pep517 and twine"
run: "python -m pip install pep517 twine"
- name: "Build package"
run: "python -m pep517.build --source --binary ."
- name: "List result"
run: "ls -l dist"
- name: "Check long_description"
run: "python -m twine check dist/*"

install-dev:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]

name: "Verify dev env"
runs-on: "${{ matrix.os }}"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: "3.8"
- name: "Install in dev mode"
run: "python -m pip install -e .[dev]"
- name: "Import package"
run: "python -c 'import hamcrest; print(hamcrest.__version__)'"
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ repos:
hooks:
- id: flake8
exclude: >-
(?x)^examples/.*\.py$
(?x)^(
examples/.*\.py$
| doc/.*\.py$
)
- repo: https://github.com/psf/black
rev: 19.10b0
Expand Down
11 changes: 11 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 2
python:
# Keep version in sync with tox.ini (docs and gh-actions).
version: 3.7

install:
- method: pip
path: .
extra_requirements:
- docs
60 changes: 41 additions & 19 deletions CHANGES.txt → CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
=== Version 2.0.2 ===
Changelog
=========

Version 2.0.2
-------------

Various type hint bug fixes.

=== Version 2.0.1 ===
Version 2.0.1
-------------

* Make hamcrest package PEP 561 compatible, i.e. supply type hints for external use.

=== Version 2.0.0 ==
Version 2.0.0
-------------

Drop formal support for 2.x
Drop formal support for 3.x < 3.5
Expand All @@ -18,44 +24,52 @@ Fix #128 - raises() grows support for additional matchers on exception object.
* Type fixes.
* Remove obsolete dependencies.

=== Version 1.10.1 ==
Version 1.10.1
--------------

Add support up to Python 3.8

Fix #66 - deprecate contains() in favour of contains_exactly().
Fix #72 - make has_properties mismatch description less verbose by adding option to AllOf not to include matcher description in its mismatch messages.
Fix #82 - include exception details in mismatch description.

=== Version 1.9.0 ==
Version 1.9.0
-------------

Drop formal support for 2.x < 2.7
Drop formal support for 3.x < 3.4

Fix #62 - Return result of a deferred call

=== Version 1.8.5 ===
Version 1.8.5
-------------

Fix #56 - incorrect handling of () in is_ matcher
Fix #60 - correct calling API call with args

=== Version 1.8.4 ==
Version 1.8.4
-------------

* Fix #54 - Make instance_of work with tuple like isinstance and unittest's assertIsInstance

=== Version 1.8.3 ===
Version 1.8.3
-------------

* Fix #52 - bad handling when reporting mismatches for byte arrays in Python 3

=== Version 1.8.2 ===
Version 1.8.2
-------------

* [Bug] Fix unicode syntax via u() introduction (puppsman)

=== Version 1.8.1 ===
Version 1.8.1
-------------

* Added not_ alias for is_not [Matteo Bertini]
* Added doc directory to the sdist [Alex Brandt]

=== Version 1.8 ==
Version 1.8
-----------

* Supported versions
- Support for Python 2.5 and Jython 2.5 has been dropped. They may still work, but no promises.
Expand All @@ -67,7 +81,8 @@ Fix #60 - correct calling API call with args
- Support for numpy numeric values in iscloseto (Alexander Beedie)
- A matcher targeting exceptions and call results (Per Fagrell)

=== Version 1.7 ==
Version 1.7
-----------

2 Sep 2013 (Version 1.7.2)
* Supported versions
Expand Down Expand Up @@ -100,7 +115,8 @@ Fix #60 - correct calling API call with args
- README enhancements by ming13


=== Version 1.6 ==
Version 1.6
-----------

27 Sep 2011
(All changes by Chris Rose unless otherwise noted.)
Expand All @@ -119,7 +135,8 @@ Fix #60 - correct calling API call with args
- Rewrote documentation. (Jon Reid)


== Version 1.5 ==
Version 1.5
-----------

29 Apr 2011
* Packaging:
Expand All @@ -138,7 +155,8 @@ Fix #60 - correct calling API call with args
None.


== Version 1.4 ==
Version 1.4
-----------

13 Feb 2011
* New matchers:
Expand All @@ -152,7 +170,8 @@ Fix #60 - correct calling API call with args
- Consistently use articles to begin descriptions, such as "a sequence containing" instead of "sequence containing".


== Version 1.3 ==
Version 1.3
-----------

04 Feb 2011
* PyHamcrest is now compatible with Python 3! To install PyHamcrest on Python 3:
Expand All @@ -171,7 +190,8 @@ Fix #60 - correct calling API call with args
- Improved readability of several matchers.


== Version 1.2.1 ==
Version 1.2.1
-------------

04 Jan 2011
* Fixed "assert_that" to describe the diagnosis of the mismatch, not just the
Expand All @@ -188,7 +208,8 @@ mismatched value. PyHamcrest will now give even more useful information.
- Corrected manifest so install works. Thanks to: Jeong-Min Lee


== Version 1.1 ==
Version 1.1
-----------

28 Dec 2010
* New matchers:
Expand All @@ -198,7 +219,8 @@ mismatched value. PyHamcrest will now give even more useful information.
* Added Sphinx documentation support.


== Version 1.0 ==
Version 1.0
-----------

04 Dec 2010
* First official release
Expand Down
29 changes: 25 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
include CHANGES.txt
include LICENSE.txt
include README.md
include LICENSE.txt *.rst *.md *.toml *.yml *.yaml *.ini
include requirements-*
graft .github

# Tests
include tox.ini conftest.py
recursive-include tests *.py
recursive-include tests *.yml

# Documentation
include doc/Makefile doc/docutils.conf
recursive-include examples *.py
recursive-include doc *
recursive-include doc *.png
recursive-include doc *.svg
recursive-include doc *.py
recursive-include doc *.rst
prune doc/_build

# remove some of the random source
prune docker
exclude release.sh

# Just to keep check-manifest happy; on releases those files are gone.
# Last rule wins!
exclude changelog.d/*.rst
include changelog.d/towncrier_template.rst
20 changes: 20 additions & 0 deletions changelog.d/towncrier_template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% for section, _ in sections.items() %} {% set underline = underlines[0] %}{% if section %}{{section}} {{ underline * section|length }}{% set underline = underlines[1] %}

{% endif %}

{% if sections[section] %} {% for category, val in definitions.items() if category in sections[section]%} {{ definitions[category]['name'] }} {{ underline * definitions[category]['name']|length }}

{% if definitions[category]['showcontent'] %} {% for text, values in sections[section][category].items() %} - {{ text }}

{{ values|join(',n ') }}
{% endfor %}

{% else %} - {{ sections[section][category]['']|join(', ') }}

{% endif %} {% if sections[section][category]|length == 0 %} No significant changes.

{% else %} {% endif %}

{% endfor %} {% else %} No significant changes.

{% endif %} {% endfor %} ----
Loading

0 comments on commit e539290

Please sign in to comment.