Skip to content

Commit 49a36a4

Browse files
authored
Use pre-commit to streamline development (#229)
* Use pre-commit to streamline development * Specify linting stage in travis config
1 parent b69dde5 commit 49a36a4

File tree

6 files changed

+99
-40
lines changed

6 files changed

+99
-40
lines changed

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
3+
- repo: https://github.com/psf/black
4+
rev: stable
5+
hooks:
6+
- id: black
7+
args: [--safe, --quiet]
8+
language_version: python3
9+
10+
- repo: https://gitlab.com/pycqa/flake8
11+
rev: 3.7.7
12+
hooks:
13+
- id: flake8
14+
exclude: docs
15+
language_version: python3

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ jobs:
88
script: grunt test
99

1010
-
11+
name: Linting
1112
python: 3.7
1213
dist: xenial
1314
sudo: required
14-
env: TOXENV=flake8
15-
16-
-
17-
python: 3.7
18-
dist: xenial
19-
sudo: required
20-
env: TOXENV=black
15+
env: TOXENV=linting
16+
cache:
17+
directories:
18+
- $HOME/.cache/pre-commit
2119

2220
-
2321
python: 2.7

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pytest = "*"
88
tox = "*"
99
flake8 = "*"
1010
black = "*"
11+
pre-commit = "*"
1112

1213
[packages]
1314
pytest-html = {editable = true,path = "."}

README.rst

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -253,28 +253,9 @@ Screenshots
253253
Contributing
254254
------------
255255

256-
Fork the repository and submit PRs with bug fixes and enhancements, contributions are very welcome.
256+
We welcome contributions.
257257

258-
Tests can be run locally with `tox`_, for example to execute tests for Python 2.7 and 3.6 execute::
259-
260-
tox -e py27,py36
261-
262-
263-
.. _`tox`: https://tox.readthedocs.org/en/latest/
264-
265-
Releasing a new version
266-
-----------------------
267-
268-
Follow these steps to release a new version of the project:
269-
270-
1. Update your local master with the upstream master (``git pull --rebase upstream master``)
271-
2. Create a new branch and update ``CHANGES.rst`` with the new version, today's date, and all changes/new features
272-
3. Commit and push the new branch and then create a new pull request
273-
4. Wait for tests and reviews and then merge the branch
274-
5. Once merged, update your local master again (``git pull --rebase upstream master``)
275-
6. Tag the release with the new release version (``git tag v<new tag>``)
276-
7. Push the tag (``git push upstream --tags``)
277-
8. Done. You can monitor the progress on `Travis <https://travis-ci.org/pytest-dev/pytest-html/>`_
258+
To learn more, see `Development <https://github.com/pytest-dev/pytest-html/blob/master/development.rst>`_
278259

279260
Resources
280261
---------

developtment.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Development
2+
===========
3+
4+
To contribute to `pytest-html` you can use `Pipenv`_ to manage
5+
a python virtual environment and `pre-commit <https://pre-commit.com/>`_ to help you with
6+
styling and formatting.
7+
8+
To setup the virtual environment and pre-commit, run:
9+
10+
.. code-block:: bash
11+
12+
$ pipenv install --dev
13+
$ pipenv run pre-commit install
14+
15+
If you're not using `Pipenv`_, to install `pre-commit`, run:
16+
17+
.. code-block:: bash
18+
19+
$ pip install pre-commit
20+
$ pre-commit install
21+
22+
23+
Automated Testing
24+
-----------------
25+
26+
All pull requests and merges are tested in `Travis CI <https://travis-ci.org/>`_
27+
based on the ``.travis.yml`` file.
28+
29+
Usually, a link to your specific travis build appears in pull requests, but if
30+
not, you can find it on the
31+
`pull requests page <https://travis-ci.org/pytest-dev/pytest-html/pull_requests>`_
32+
33+
The only way to trigger Travis CI to run again for a pull request, is to submit
34+
another change to the pull branch.
35+
36+
You can do this with `git commit --allow-empty`
37+
38+
Running Tests
39+
-------------
40+
41+
You will need `Tox <http://tox.testrun.org/>`_ installed to run the tests
42+
against the supported Python versions. If you're using `Pipenv`_ it will be
43+
installed for you.
44+
45+
With `Pipenv`_, run:
46+
47+
.. code-block:: bash
48+
49+
$ pipenv run tox
50+
51+
Otherwise, to install and run, do:
52+
53+
.. code-block:: bash
54+
55+
$ pip install tox
56+
$ tox
57+
58+
Releasing a new version
59+
-----------------------
60+
61+
Follow these steps to release a new version of the project:
62+
63+
1. Update your local master with the upstream master (``git pull --rebase upstream master``)
64+
2. Create a new branch and update ``CHANGES.rst`` with the new version, today's date, and all changes/new features
65+
3. Commit and push the new branch and then create a new pull request
66+
4. Wait for tests and reviews and then merge the branch
67+
5. Once merged, update your local master again (``git pull --rebase upstream master``)
68+
6. Tag the release with the new release version (``git tag v<new tag>``)
69+
7. Push the tag (``git push upstream --tags``)
70+
8. Done. You can monitor the progress on `Travis <https://travis-ci.org/pytest-dev/pytest-html/>`_

tox.ini

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# and then run "tox" from this directory.
55

66
[tox]
7-
envlist = py{27,36,37,py,py3}{,-ansi2html}, flake8, black
7+
envlist = py{27,36,37,py,py3}{,-ansi2html}, linting
88

99
[testenv]
1010
setenv = PYTHONDONTWRITEBYTECODE=1
@@ -15,17 +15,11 @@ deps =
1515
py{27,36,py,py3}-ansi2html: ansi2html
1616
commands = pytest -v -r a {posargs}
1717

18-
[testenv:flake8]
19-
skip_install = true
20-
basepython = python
21-
deps = flake8
22-
commands = flake8 {posargs:.}
23-
24-
[testenv:black]
25-
skip_install = true
26-
basepython = python
27-
deps = black
28-
commands = black --check {posargs:.}
18+
[testenv:linting]
19+
skip_install = True
20+
basepython = python3
21+
deps = pre-commit
22+
commands = pre-commit run --all-files --show-diff-on-failure
2923

3024
[flake8]
3125
max-line-length = 88

0 commit comments

Comments
 (0)