Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 1 | Contributing |
| 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 | |
| 9 | Here are some guidelines for hacking on ``google-auth-library-python``. |
| 10 | |
| 11 | Making changes |
| 12 | -------------- |
| 13 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 14 | A few notes on making changes to ``google-auth-library-python``. |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 15 | |
| 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 Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 19 | using ``nox -s docgen``. |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | - The change must work fully on the following CPython versions: 2.7, |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 22 | 3.5, 3.6, 3.7 across macOS, Linux, and Windows. |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 23 | |
| 24 | - The codebase *must* have 100% test statement coverage after each commit. |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 25 | You can test coverage via ``nox -e cover``. |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | Testing changes |
| 28 | --------------- |
| 29 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 30 | To test your changes, run unit tests with ``nox``:: |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 31 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 32 | $ nox -s unit |
| 33 | |
| 34 | |
| 35 | Running system tests |
| 36 | -------------------- |
| 37 | |
| 38 | You can run the system tests with ``nox``:: |
| 39 | |
| 40 | $ nox -f system_tests/noxfile.py |
| 41 | |
| 42 | To run a single session, specify it with ``nox -s``:: |
| 43 | |
| 44 | $ nox -f system_tests/noxfile.py -s service_account |
| 45 | |
| 46 | To run system tests locally, you will need to set up a data directory :: |
| 47 | |
| 48 | $ mkdir system_tests/data |
| 49 | |
| 50 | Add a service account file and authorized user file to the data directory. |
| 51 | Your directory should look like this :: |
| 52 | |
| 53 | system_tests/ |
| 54 | data/ |
| 55 | service_account.json |
| 56 | authorized_user.json |
| 57 | |
| 58 | The files must be named exactly ``service_account.json`` |
| 59 | and ``authorized_user.json``. See `Creating and Managing Service Account Keys`_ for how to |
| 60 | obtain a service account. |
| 61 | |
| 62 | Use 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 | |
| 66 | You will see something like:: |
| 67 | |
| 68 | Credentials saved to file: [/usr/local/home/.config/gcloud/application_default_credentials.json]``` |
| 69 | |
| 70 | Copy 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 | |
| 75 | App Engine System Tests |
| 76 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 77 | |
| 78 | To run the App Engine tests, you wil need to deploy a default App Engine service. |
| 79 | If you already have a default service associated with your project, you can skip this step. |
| 80 | |
| 81 | Edit ``app.yaml`` so ``service`` is ``default`` instead of ``google-auth-system-tests``. |
| 82 | From ``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 | |
| 87 | After the app is deployed, change ``service`` in ``app.yaml`` back to ``google-auth-system-tests``. |
| 88 | You can now run the App Engine tests: :: |
| 89 | |
| 90 | $ nox -f system_tests/noxfile.py -s app_engine |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | Coding Style |
| 93 | ------------ |
| 94 | |
| 95 | This 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 Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 97 | ``nox`` to check for non-compliant code:: |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 98 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 99 | $ nox -s lint |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 100 | |
| 101 | Documentation Coverage and Building HTML Documentation |
| 102 | ------------------------------------------------------ |
| 103 | |
| 104 | If you fix a bug, and the bug requires an API or behavior modification, all |
| 105 | documentation in this package which references that API or behavior must be |
| 106 | changed to reflect the bug fix, ideally in the same commit that fixes the bug |
| 107 | or adds the feature. |
| 108 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 109 | To build and review docs use ``nox``:: |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 110 | |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame^] | 111 | $ nox -s docs |
Jon Wayne Parrott | 377f293 | 2016-10-04 10:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | The HTML version of the docs will be built in ``docs/_build/html`` |
| 114 | |
| 115 | Versioning |
| 116 | ---------- |
| 117 | |
| 118 | This library follows `Semantic Versioning`_. |
| 119 | |
| 120 | .. _Semantic Versioning: http://semver.org/ |
| 121 | |
| 122 | It is currently in major version zero (``0.y.z``), which means that anything |
| 123 | may change at any time and the public API should not be considered |
| 124 | stable. |
| 125 | |
| 126 | Contributor License Agreements |
| 127 | ------------------------------ |
| 128 | |
| 129 | Before 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 | |
| 134 | You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests. |