blob: f95b1f1dc45a17222af4ed9a3447577518d43b17 [file] [log] [blame]
Jon Wayne Parrott377f2932016-10-04 10:20:36 -07001Contributing
2============
3
4#. **Please sign one of the contributor license agreements below.**
5#. Fork the repo, develop and test your code changes, add docs.
6#. Make sure that your commit messages clearly describe the changes.
7#. Send a pull request.
8
9Here are some guidelines for hacking on ``google-auth-library-python``.
10
11Making changes
12--------------
13
Bu Sun Kim65e33c02019-10-25 10:45:00 -070014A few notes on making changes to ``google-auth-library-python``.
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070015
16- If you've added a new feature or modified an existing feature, be sure to
17 add or update any applicable documentation in docstrings and in the
18 documentation (in ``docs/``). You can re-generate the reference documentation
Bu Sun Kim65e33c02019-10-25 10:45:00 -070019 using ``nox -s docgen``.
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070020
21- The change must work fully on the following CPython versions: 2.7,
Bu Sun Kim65e33c02019-10-25 10:45:00 -070022 3.5, 3.6, 3.7 across macOS, Linux, and Windows.
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070023
24- The codebase *must* have 100% test statement coverage after each commit.
Bu Sun Kim65e33c02019-10-25 10:45:00 -070025 You can test coverage via ``nox -e cover``.
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070026
27Testing changes
28---------------
29
Bu Sun Kim65e33c02019-10-25 10:45:00 -070030To test your changes, run unit tests with ``nox``::
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070031
Bu Sun Kim65e33c02019-10-25 10:45:00 -070032 $ nox -s unit
33
34
35Running system tests
36--------------------
37
38You can run the system tests with ``nox``::
39
40 $ nox -f system_tests/noxfile.py
41
42To run a single session, specify it with ``nox -s``::
43
44 $ nox -f system_tests/noxfile.py -s service_account
45
46To run system tests locally, you will need to set up a data directory ::
47
48 $ mkdir system_tests/data
49
50Add a service account file and authorized user file to the data directory.
51Your directory should look like this ::
52
53 system_tests/
54 data/
55 service_account.json
56 authorized_user.json
57
58The files must be named exactly ``service_account.json``
59and ``authorized_user.json``. See `Creating and Managing Service Account Keys`_ for how to
60obtain a service account.
61
62Use the `gcloud CLI`_ to get an authorized user file ::
63
64 $ gcloud auth application-default login --scopes=https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/cloud-platform,openid
65
66You will see something like::
67
68 Credentials saved to file: [/usr/local/home/.config/gcloud/application_default_credentials.json]```
69
70Copy the contents of the file to ``authorized_user.json``.
71
72.. _Creating and Managing Service Account Keys: https://cloud.google.com/iam/docs/creating-managing-service-account-keys
73.. _gcloud CLI: https://cloud.google.com/sdk/gcloud/
74
75App Engine System Tests
76^^^^^^^^^^^^^^^^^^^^^^^
77
78To run the App Engine tests, you wil need to deploy a default App Engine service.
79If you already have a default service associated with your project, you can skip this step.
80
81Edit ``app.yaml`` so ``service`` is ``default`` instead of ``google-auth-system-tests``.
82From ``system_tests/app_engine_test_app`` run the following commands ::
83
84 $ pip install --target-lib -r requirements.txt
85 $ gcloud app deploy -q app.yaml
86
87After the app is deployed, change ``service`` in ``app.yaml`` back to ``google-auth-system-tests``.
88You can now run the App Engine tests: ::
89
90 $ nox -f system_tests/noxfile.py -s app_engine
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070091
92Coding Style
93------------
94
95This library is PEP8 & Pylint compliant. Our Pylint config is defined at
96``pylintrc`` for package code and ``pylintrc.tests`` for test code. Use
Bu Sun Kim65e33c02019-10-25 10:45:00 -070097``nox`` to check for non-compliant code::
Jon Wayne Parrott377f2932016-10-04 10:20:36 -070098
Bu Sun Kim65e33c02019-10-25 10:45:00 -070099 $ nox -s lint
Jon Wayne Parrott377f2932016-10-04 10:20:36 -0700100
101Documentation Coverage and Building HTML Documentation
102------------------------------------------------------
103
104If you fix a bug, and the bug requires an API or behavior modification, all
105documentation in this package which references that API or behavior must be
106changed to reflect the bug fix, ideally in the same commit that fixes the bug
107or adds the feature.
108
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700109To build and review docs use ``nox``::
Jon Wayne Parrott377f2932016-10-04 10:20:36 -0700110
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700111 $ nox -s docs
Jon Wayne Parrott377f2932016-10-04 10:20:36 -0700112
113The HTML version of the docs will be built in ``docs/_build/html``
114
115Versioning
116----------
117
118This library follows `Semantic Versioning`_.
119
120.. _Semantic Versioning: http://semver.org/
121
122It is currently in major version zero (``0.y.z``), which means that anything
123may change at any time and the public API should not be considered
124stable.
125
126Contributor License Agreements
127------------------------------
128
129Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
130
131- **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need to sign an `individual CLA <https://developers.google.com/open-source/cla/individual>`__.
132- **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a `corporate CLA <https://developers.google.com/open-source/cla/corporate>`__.
133
134You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.