Debian Codegraph @

CONTRIBUTING.rst

raw
1 How to Contribute
2 =================
3
4 CLI Helpers would love your help! We appreciate your time and always give credit.
5
6 Development Setup
7 -----------------
8
9 Ready to contribute? Here's how to set up CLI Helpers for local development.
10
11 1. `Fork the repository <https://github.com/dbcli/cli_helpers>`_ on GitHub.
12 2. Clone your fork locally::
13
14 $ git clone <url-for-your-fork>
15
16 3. Add the official repository (``upstream``) as a remote repository::
17
18 $ git remote add upstream [email protected]:dbcli/cli_helpers.git
19
20 4. Set up a `virtual environment <http://docs.python-guide.org/en/latest/dev/virtualenvs>`_
21 for development::
22
23 $ cd cli_helpers
24 $ pip install virtualenv
25 $ virtualenv cli_helpers_dev
26
27 We've just created a virtual environment called ``cli_helpers_dev``
28 that we'll use to install all the dependencies and tools we need to work on CLI Helpers.
29 Whenever you want to work on CLI Helpers, you need to activate the virtual environment::
30
31 $ source cli_helpers_dev/bin/activate
32
33 When you're done working, you can deactivate the virtual environment::
34
35 $ deactivate
36
37 5. From within the virtual environment, install the dependencies and development tools::
38
39 $ pip install -r requirements-dev.txt
40 $ pip install --editable .
41
42 6. Create a branch for your bugfix or feature based off the ``main`` branch::
43
44 $ git checkout -b <name-of-bugfix-or-feature> main
45
46 7. While you work on your bugfix or feature, be sure to pull the latest changes from ``upstream``.
47 This ensures that your local codebase is up-to-date::
48
49 $ git pull upstream main
50
51 8. When your work is ready for the CLI Helpers team to review it,
52 make sure to add an entry to CHANGELOG file, and add your name to the AUTHORS file.
53 Then, push your branch to your fork::
54
55 $ git push origin <name-of-bugfix-or-feature>
56
57 9. `Create a pull request <https://help.github.com/articles/creating-a-pull-request-from-a-fork/>`_
58 on GitHub.
59
60
61 Running the Tests
62 -----------------
63
64 While you work on CLI Helpers, it's important to run the tests to make sure your code
65 hasn't broken any existing functionality. To run the tests, just type in::
66
67 $ pytest
68
69 CLI Helpers supports Python 3.6+. You can test against multiple versions of
70 Python by running::
71
72 $ tox
73
74 You can also measure CLI Helper's test coverage by running::
75
76 $ pytest --cov-report= --cov=cli_helpers
77 $ coverage report
78
79
80 Coding Style
81 ------------
82
83 When you submit a PR, the changeset is checked for pep8 compliance using
84 `black <https://github.com/psf/black>`_. If you see a build failing because
85 of these checks, install ``black`` and apply style fixes:
86
87 ::
88
89 $ pip install black
90 $ black .
91
92 Then commit and push the fixes.
93
94 To enforce ``black`` applied on every commit, we also suggest installing ``pre-commit`` and
95 using the ``pre-commit`` hooks available in this repo:
96
97 ::
98
99 $ pip install pre-commit
100 $ pre-commit install
101
102 Git blame
103 ---------
104
105 Use ``git blame my_file.py --ignore-revs-file .git-blame-ignore-revs`` to exclude irrelevant commits
106 (specifically Black) from ``git blame``. For more information,
107 see `here <https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame>`_.
108
109 Documentation
110 -------------
111
112 If your work in CLI Helpers requires a documentation change or addition, you can
113 build the documentation by running::
114
115 $ make -C docs clean html
116 $ open docs/build/html/index.html
117
118 That will build the documentation and open it in your web browser.