|
| 1 | +# Contributing | Firebase Admin Python SDK |
| 2 | + |
| 3 | +Thank you for contributing to the Firebase community! |
| 4 | + |
| 5 | + - [Have a usage question?](#question) |
| 6 | + - [Think you found a bug?](#issue) |
| 7 | + - [Have a feature request?](#feature) |
| 8 | + - [Want to submit a pull request?](#submit) |
| 9 | + - [Need to get set up locally?](#local-setup) |
| 10 | + |
| 11 | + |
| 12 | +## <a name="question"></a>Have a usage question? |
| 13 | + |
| 14 | +We get lots of those and we love helping you, but GitHub is not the best place for them. Issues |
| 15 | +which just ask about usage will be closed. Here are some resources to get help: |
| 16 | + |
| 17 | +- Go through the [guides](https://firebase.google.com/docs/admin/setup/) |
| 18 | +- Read the full [API reference](https://firebase.google.com/docs/reference/admin/python/) |
| 19 | + |
| 20 | +If the official documentation doesn't help, try asking a question on the |
| 21 | +[Firebase Google Group](https://groups.google.com/forum/#!forum/firebase-talk/) or one of our |
| 22 | +other [official support channels](https://firebase.google.com/support/). |
| 23 | + |
| 24 | +**Please avoid double posting across multiple channels!** |
| 25 | + |
| 26 | + |
| 27 | +## <a name="issue"></a>Think you found a bug? |
| 28 | + |
| 29 | +Yeah, we're definitely not perfect! |
| 30 | + |
| 31 | +Search through [old issues](https://github.com/firebase/firebase-admin-python/issues) before |
| 32 | +submitting a new issue as your question may have already been answered. |
| 33 | + |
| 34 | +If your issue appears to be a bug, and hasn't been reported, |
| 35 | +[open a new issue](https://github.com/firebase/firebase-admin-python/issues/new). Please use the |
| 36 | +provided bug report template and include a minimal repro. |
| 37 | + |
| 38 | +If you are up to the challenge, [submit a pull request](#submit) with a fix! |
| 39 | + |
| 40 | + |
| 41 | +## <a name="feature"></a>Have a feature request? |
| 42 | + |
| 43 | +Great, we love hearing how we can improve our products! Share you idea through our |
| 44 | +[feature request support channel](https://firebase.google.com/support/contact/bugs-features/). |
| 45 | + |
| 46 | + |
| 47 | +## <a name="submit"></a>Want to submit a pull request? |
| 48 | + |
| 49 | +Sweet, we'd love to accept your contribution! |
| 50 | +[Open a new pull request](https://github.com/firebase/firebase-admin-python/pull/new/master) and fill |
| 51 | +out the provided template. |
| 52 | + |
| 53 | +**If you want to implement a new feature, please open an issue with a proposal first so that we can |
| 54 | +figure out if the feature makes sense and how it will work.** |
| 55 | + |
| 56 | +Make sure your changes pass our linter and the tests all pass on your local machine. |
| 57 | +Most non-trivial changes should include some extra test coverage. If you aren't sure how to add |
| 58 | +tests, feel free to submit regardless and ask us for some advice. |
| 59 | + |
| 60 | +Finally, you will need to sign our |
| 61 | +[Contributor License Agreement](https://cla.developers.google.com/about/google-individual) |
| 62 | +before we can accept your pull request. |
| 63 | + |
| 64 | + |
| 65 | +## <a name="local-setup"></a>Need to get set up locally? |
| 66 | + |
| 67 | + |
| 68 | +### Initial Setup |
| 69 | + |
| 70 | +We recommend using [pip](https://pypi.python.org/pypi/pip) for installing the necessary tools and |
| 71 | +project dependencies. Most recent versions of Python ship with pip. If your development environment |
| 72 | +does not already have pip, use the software package manager of your platform (e.g. apt-get, brew) |
| 73 | +to download and install it. Alternatively you may also follow the official |
| 74 | +[pip installation guide](https://pip.pypa.io/en/stable/installing/). |
| 75 | + |
| 76 | +Once pip is installed, run the following commands from the command line to get your local |
| 77 | +environment set up: |
| 78 | + |
| 79 | +```bash |
| 80 | +$ git clone https://github.com/firebase/firebase-admin-python.git |
| 81 | +$ cd firebase-admin-python # go to the firebase-admin-python directory |
| 82 | +$ pip install -r requirements.txt # Install additional tools and dependencies |
| 83 | +``` |
| 84 | + |
| 85 | +### Running Linters |
| 86 | + |
| 87 | +We use [pylint](https://pylint.org/) for verifying source code format, and |
| 88 | +enforcing other Python programming best practices. |
| 89 | +There is a pylint configuration file ([`.pylintrc`](../.pylintrc)) at the root of this Git |
| 90 | +repository. This enables you to invoke pylint directly from the command line: |
| 91 | + |
| 92 | +``` |
| 93 | +pylint firebase |
| 94 | +``` |
| 95 | + |
| 96 | +However, it is recommended that you use the [`lint.sh`](../lint.sh) bash script to invoke |
| 97 | +pylint. This script will run the linter on both `firebase` and the corresponding |
| 98 | +`tests` module. It suprresses some of the noisy warnings that get generated |
| 99 | +when running pylint on test code. Note that by default `lint.sh` will only |
| 100 | +validate the locally modified source files. To validate all source files, |
| 101 | +pass `all` as an argument. |
| 102 | + |
| 103 | +``` |
| 104 | +./lint.sh # Lint locally modified source files |
| 105 | +./lint.sh all # Lint all source files |
| 106 | +``` |
| 107 | + |
| 108 | +Ideally you should not see any pylint errors or warnings when you run the |
| 109 | +linter. This means source files are properly formatted, and the linter has |
| 110 | +not found any issues. If you do observe any errors, fix them before |
| 111 | +committing or sending a pull request. Details on how to interpret pylint |
| 112 | +errors are available |
| 113 | +[here](https://pylint.readthedocs.io/en/latest/user_guide/output.html). |
| 114 | + |
| 115 | +Our configuration files suppress the verbose reports usually generated |
| 116 | +by pylint, and only output the detected issues. If you wish to obtain the |
| 117 | +comprehensive reports, run pylint from command-line with the `-r` flag. |
| 118 | + |
| 119 | +``` |
| 120 | +pylint -r yes firebase |
| 121 | +``` |
| 122 | + |
| 123 | +### Unit Testing |
| 124 | + |
| 125 | +We use [pytest](http://doc.pytest.org/en/latest/) for writing and executing |
| 126 | +unit tests. All source files containing test code is located in the `tests/` |
| 127 | +directory. Simply launch pytest from the root of the Git repository, or from |
| 128 | +within the `tests/` directory to execute all test cases. |
| 129 | + |
| 130 | +``` |
| 131 | +pytest |
| 132 | +``` |
| 133 | + |
| 134 | +Refer to the pytest [usage and invocations guide](http://doc.pytest.org/en/latest/usage.html) |
| 135 | +to learn how to run a subset of all test cases. |
| 136 | + |
| 137 | +### Testing in Different Environments |
| 138 | + |
| 139 | +Sometimes we may want to run unit tests in multiple environments (e.g. different |
| 140 | +Python versions), and ensure that the SDK works as expected in each of them. |
| 141 | +We use [tox](https://tox.readthedocs.io/en/latest/) for this purpose. |
| 142 | +You can execute the following command from the root of the repository to |
| 143 | +launch tox: |
| 144 | + |
| 145 | +``` |
| 146 | +tox |
| 147 | +``` |
| 148 | + |
| 149 | +This command will read a list of target environments from the [`tox.ini`](../tox.ini) |
| 150 | +file in the Git repository, and execute test cases in each of those environments. |
| 151 | + |
| 152 | +### Repo Organization |
| 153 | + |
| 154 | +Here are some highlights of the directory structure and notable source files |
| 155 | + |
| 156 | +* `firebase/` - Source directory for the `firebase` module. |
| 157 | +* `tests/` - Unit tests. |
| 158 | + * `data/` - Provides mocks for several variables as well as mock service account keys. |
| 159 | +* `.github/` - Contribution instructions as well as issue and pull request templates. |
| 160 | +* `lint.sh` - Runs pylint to check for code quality. |
| 161 | +* `.pylintrc` - Default configuration for pylint. |
| 162 | +* `requirements.txt` - Requirements specification for installing project dependencies via pip. |
| 163 | +* `setup.py` - Python setup script for building distribution artifacts. |
| 164 | +* `tox.ini` - Tox configuration for running tests on different environments. |
0 commit comments