1.. Generated by synthtool. DO NOT EDIT!
2############
3Contributing
4############
5
6#. **Please sign one of the contributor license agreements below.**
7#. Fork the repo, develop and test your code changes, add docs.
8#. Make sure that your commit messages clearly describe the changes.
9#. Send a pull request. (Please Read: `Faster Pull Request Reviews`_)
10
11.. _Faster Pull Request Reviews: https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
12
13.. contents:: Here are some guidelines for hacking on the Google Cloud Client libraries.
14
15***************
16Adding Features
17***************
18
19In order to add a feature:
20
21- The feature must be documented in both the API and narrative
22  documentation.
23
24- The feature must work fully on the following CPython versions:
25  3.6, 3.7, 3.8, 3.9 and 3.10 on both UNIX and Windows.
26
27- The feature must not add unnecessary dependencies (where
28  "unnecessary" is of course subjective, but new dependencies should
29  be discussed).
30
31****************************
32Using a Development Checkout
33****************************
34
35You'll have to create a development environment using a Git checkout:
36
37- While logged into your GitHub account, navigate to the
38  ``google-api-python-client`` `repo`_ on GitHub.
39
40- Fork and clone the ``google-api-python-client`` repository to your GitHub account by
41  clicking the "Fork" button.
42
43- Clone your fork of ``google-api-python-client`` from your GitHub account to your local
44  computer, substituting your account username and specifying the destination
45  as ``hack-on-google-api-python-client``.  E.g.::
46
47   $ cd ${HOME}
48   $ git clone [email protected]:USERNAME/google-api-python-client.git hack-on-google-api-python-client
49   $ cd hack-on-google-api-python-client
50   # Configure remotes such that you can pull changes from the googleapis/google-api-python-client
51   # repository into your local repository.
52   $ git remote add upstream [email protected]:googleapis/google-api-python-client.git
53   # fetch and merge changes from upstream into main
54   $ git fetch upstream
55   $ git merge upstream/main
56
57Now your local repo is set up such that you will push changes to your GitHub
58repo, from which you can submit a pull request.
59
60To work on the codebase and run the tests, we recommend using ``nox``,
61but you can also use a ``virtualenv`` of your own creation.
62
63.. _repo: https://github.com/googleapis/google-api-python-client
64
65Using ``nox``
66=============
67
68We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
69
70- To test your changes, run unit tests with ``nox``::
71    $ nox -s unit
72
73- To run a single unit test::
74
75    $ nox -s unit-3.10 -- -k <name of test>
76
77
78  .. note::
79
80    The unit tests and system tests are described in the
81    ``noxfile.py`` files in each directory.
82
83.. nox: https://pypi.org/project/nox/
84
85*****************************************
86I'm getting weird errors... Can you help?
87*****************************************
88
89If the error mentions ``Python.h`` not being found,
90install ``python-dev`` and try again.
91On Debian/Ubuntu::
92
93  $ sudo apt-get install python-dev
94
95************
96Coding Style
97************
98- We use the automatic code formatter ``black``. You can run it using
99  the nox session ``blacken``. This will eliminate many lint errors. Run via::
100
101   $ nox -s blacken
102
103- PEP8 compliance is required, with exceptions defined in the linter configuration.
104  If you have ``nox`` installed, you can test that you have not introduced
105  any non-compliant code via::
106
107   $ nox -s lint
108
109- In order to make ``nox -s lint`` run faster, you can set some environment
110  variables::
111
112   export GOOGLE_CLOUD_TESTING_REMOTE="upstream"
113   export GOOGLE_CLOUD_TESTING_BRANCH="main"
114
115  By doing this, you are specifying the location of the most up-to-date
116  version of ``google-api-python-client``. The
117  remote name ``upstream`` should point to the official ``googleapis``
118  checkout and the branch should be the default branch on that remote (``main``).
119
120- This repository contains configuration for the
121  `pre-commit <https://pre-commit.com/>`__ tool, which automates checking
122  our linters during a commit.  If you have it installed on your ``$PATH``,
123  you can enable enforcing those checks via:
124
125.. code-block:: bash
126
127   $ pre-commit install
128   pre-commit installed at .git/hooks/pre-commit
129
130Exceptions to PEP8:
131
132- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
133  "Function-Under-Test"), which is PEP8-incompliant, but more readable.
134  Some also use a local variable, ``MUT`` (short for "Module-Under-Test").
135
136********************
137Running System Tests
138********************
139
140- To run system tests, you can execute::
141
142   # Run all system tests
143   $ nox -s system
144
145   # Run a single system test
146   $ nox -s system-3.8 -- -k <name of test>
147
148
149  .. note::
150
151      System tests are only configured to run under Python 3.8.
152      For expediency, we do not run them in older versions of Python 3.
153
154  This alone will not run the tests. You'll need to change some local
155  auth settings and change some configuration in your project to
156  run all the tests.
157
158- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication <https://cloud.google.com/docs/authentication/best-practices-applications#local_development_and_testing_with_the>`__. Some tests require a service account. For those tests see `Authenticating as a service account <https://cloud.google.com/docs/authentication/production>`__.
159
160*************
161Test Coverage
162*************
163
164- The codebase *must* have 100% test statement coverage after each commit.
165  You can test coverage via ``nox -s cover``.
166
167******************************************************
168Documentation Coverage and Building HTML Documentation
169******************************************************
170
171If you fix a bug, and the bug requires an API or behavior modification, all
172documentation in this package which references that API or behavior must be
173changed to reflect the bug fix, ideally in the same commit that fixes the bug
174or adds the feature.
175
176Build the docs via:
177
178   $ nox -s docs
179
180*************************
181Samples and code snippets
182*************************
183
184Code samples and snippets live in the `samples/` catalogue. Feel free to
185provide more examples, but make sure to write tests for those examples.
186Each folder containing example code requires its own `noxfile.py` script
187which automates testing. If you decide to create a new folder, you can
188base it on the `samples/snippets` folder (providing `noxfile.py` and
189the requirements files).
190
191The tests will run against a real Google Cloud Project, so you should
192configure them just like the System Tests.
193
194- To run sample tests, you can execute::
195
196   # Run all tests in a folder
197   $ cd samples/snippets
198   $ nox -s py-3.8
199
200   # Run a single sample test
201   $ cd samples/snippets
202   $ nox -s py-3.8 -- -k <name of test>
203
204********************************************
205Note About ``README`` as it pertains to PyPI
206********************************************
207
208The `description on PyPI`_ for the project comes directly from the
209``README``. Due to the reStructuredText (``rst``) parser used by
210PyPI, relative links which will work on GitHub (e.g. ``CONTRIBUTING.rst``
211instead of
212``https://github.com/googleapis/google-api-python-client/blob/main/CONTRIBUTING.rst``)
213may cause problems creating links or rendering the description.
214
215.. _description on PyPI: https://pypi.org/project/google-api-python-client
216
217
218*************************
219Supported Python Versions
220*************************
221
222We support:
223
224-  `Python 3.6`_
225-  `Python 3.7`_
226-  `Python 3.8`_
227-  `Python 3.9`_
228-  `Python 3.10`_
229
230.. _Python 3.6: https://docs.python.org/3.6/
231.. _Python 3.7: https://docs.python.org/3.7/
232.. _Python 3.8: https://docs.python.org/3.8/
233.. _Python 3.9: https://docs.python.org/3.9/
234.. _Python 3.10: https://docs.python.org/3.10/
235
236
237Supported versions can be found in our ``noxfile.py`` `config`_.
238
239.. _config: https://github.com/googleapis/google-api-python-client/blob/main/noxfile.py
240
241
242We also explicitly decided to support Python 3 beginning with version 3.6.
243Reasons for this include:
244
245-  Encouraging use of newest versions of Python 3
246-  Taking the lead of `prominent`_ open-source `projects`_
247-  `Unicode literal support`_ which allows for a cleaner codebase that
248   works in both Python 2 and Python 3
249
250.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
251.. _projects: http://flask.pocoo.org/docs/0.10/python3/
252.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/
253
254**********
255Versioning
256**********
257
258This library follows `Semantic Versioning`_.
259
260.. _Semantic Versioning: http://semver.org/
261
262Some packages are currently in major version zero (``0.y.z``), which means that
263anything may change at any time and the public API should not be considered
264stable.
265
266******************************
267Contributor License Agreements
268******************************
269
270Before we can accept your pull requests you'll need to sign a Contributor
271License Agreement (CLA):
272
273- **If you are an individual writing original source code** and **you own the
274  intellectual property**, then you'll need to sign an
275  `individual CLA <https://developers.google.com/open-source/cla/individual>`__.
276- **If you work for a company that wants to allow you to contribute your work**,
277  then you'll need to sign a
278  `corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.
279
280You can sign these electronically (just scroll to the bottom). After that,
281we'll be able to accept your pull requests.
282