We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.
Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
This project follows Google's Open Source Community Guidelines.
All Python samples should follow the best practices defined in the PEP 8 style guide and the Google Python Style Guide. The automated linting process for Python samples uses flake8 to verify conformance to common Python coding standards, so the use of flake8 is recommended.
If you prefer to use pylint, note that Python samples for this repo are not required to conform to pylint’s default settings outside the scope of PEP 8, such as the “too many arguments” or “too many local variables” warnings.
The use of Black to standardize code formatting and simplify diffs is recommended.
The default noxfile defines a blacken
session for convenience. If you have
pyenv configured, you can check and format all files in google-analytics-admin
or google-analytics-data
using the following command:
nox -s lint blacken
-
Configure your environment and credentials as described in the README.
-
Change into the directory of the project you want to test (either
google-analytics-admin
orgoogle-analytics-data
). -
Configure environment variables required by tests using the following commands:
# These values are required by Admin and Data API samples tests. export GOOGLE_CLOUD_PROJECT= export GA_TEST_PROPERTY_ID= # These values are only required by Admin API samples tests. export GA_TEST_ACCOUNT_ID= export GA_TEST_WEB_DATA_STREAM_ID= export GA_TEST_WEB_DATA_SECRET_ID= export GA_TEST_KEY_EVENT_ID= export GA_TEST_ACCOUNT_ACCESS_BINDING_ID= export GA_TEST_PROPERTY_ACCESS_BINDING_ID=
-
Execute tests from the
google-analytics-admin
orgoogle-analytics-data
directory, using eithernox
orpytest
. Usingnox
provides the additional benefit of formatting all files, and also automatically creates a virtual environment to test samples using different versions of Python.-
Using
nox
:nox
-
Using
pytest
:pytest
-