Skip to content

Commit 0501d70

Browse files
authored
Merge pull request #866 from sliverc/pre_commit
Introduce pre-commit to simplify contributions
2 parents c356806 + 80fa5f4 commit 0501d70

File tree

3 files changed

+72
-33
lines changed

3 files changed

+72
-33
lines changed

.pre-commit-config.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: black
5+
stages: [commit]
6+
name: black
7+
language: system
8+
entry: black
9+
types: [python]
10+
- id: isort
11+
stages: [commit]
12+
name: isort
13+
language: system
14+
entry: isort
15+
types: [python]
16+
- id: flake8
17+
stages: [commit]
18+
name: flake8
19+
language: system
20+
entry: flake8
21+
types: [python]

README.rst

-12
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,6 @@ Browse to
142142
* http://localhost:8000/openapi for the schema view's OpenAPI specification document.
143143

144144

145-
Running Tests and linting
146-
^^^^^^^^^^^^^^^^^^^^^^^^^
147-
148-
It is recommended to create a virtualenv for testing. Assuming it is already
149-
installed and activated:
150-
151-
::
152-
153-
$ pip install -Ur requirements.txt
154-
$ flake8
155-
$ pytest
156-
157145
-----
158146
Usage
159147
-----

docs/CONTRIBUTING.md

+51-21
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,60 @@
1-
Contributing
2-
============
1+
# Contributing
32

4-
DJA should be easy to contribute to.
3+
Django REST Framework JSON API (aka DJA) should be easy to contribute to.
54
If anything is unclear about how to contribute,
65
please submit an issue on GitHub so that we can fix it!
76

8-
How
9-
---
7+
Before writing any code, have a conversation on a GitHub issue to see
8+
if the proposed change makes sense for the project.
109

11-
Before writing any code,
12-
have a conversation on a GitHub issue
13-
to see if the proposed change makes sense
14-
for the project.
10+
## Setup development environment
1511

16-
Fork DJA on [GitHub](https://github.com/django-json-api/django-rest-framework-json-api) and
17-
[submit a Pull Request](https://help.github.com/articles/creating-a-pull-request/)
18-
when you're ready.
12+
### Clone
1913

20-
For maintainers
21-
---------------
14+
To start developing on Django REST Framework JSON API you need to first clone the repository:
2215

23-
To upload a release (using version 1.2.3 as the example):
16+
git clone https://github.com/django-json-api/django-rest-framework-json-api.git
2417

25-
```bash
26-
(venv)$ python setup.py sdist bdist_wheel
27-
(venv)$ twine upload dist/*
28-
(venv)$ git tag -a v1.2.3 -m 'Release 1.2.3'
29-
(venv)$ git push --tags
30-
```
18+
### Testing
19+
20+
To run tests clone the repository, and then:
21+
22+
# Setup the virtual environment
23+
python3 -m venv env
24+
source env/bin/activate
25+
pip install -r requirements.txt
26+
27+
# Format code
28+
black .
29+
30+
# Run linting
31+
flake8
32+
33+
# Run tests
34+
pytest
35+
36+
### Running against multiple environments
37+
38+
You can also use the excellent [tox](https://tox.readthedocs.io/en/latest/) testing tool to run the tests against all supported versions of Python and Django. Install `tox` globally, and then simply run:
39+
40+
tox
41+
42+
43+
### Setup pre-commit
44+
45+
pre-commit hooks is an additional option to check linting and formatting of code independent of
46+
an editor before you commit your changes with git.
47+
48+
To setup pre-commit hooks first create a testing environment as explained above before running below commands:
49+
50+
pip install pre-commit
51+
pre-commit install
52+
53+
## For maintainers
54+
55+
To upload a release (using version 1.2.3 as the example) first setup testing environment as above before running below commands:
56+
57+
python setup.py sdist bdist_wheel
58+
twine upload dist/*
59+
git tag -a v1.2.3 -m 'Release 1.2.3'
60+
git push --tags

0 commit comments

Comments
 (0)