|
| 1 | +# How to contribute |
| 2 | + |
| 3 | +We'd love to accept your patches and contributions to this project. There are |
| 4 | +just a few small guidelines you need to follow. |
| 5 | + |
| 6 | +## Contributor License Agreement |
| 7 | + |
| 8 | +Contributions to this project must be accompanied by a Contributor License |
| 9 | +Agreement. You (or your employer) retain the copyright to your contribution, |
| 10 | +this simply gives us permission to use and redistribute your contributions as |
| 11 | +part of the project. Head over to <https://cla.developers.google.com/> to see |
| 12 | +your current agreements on file or to sign a new one. |
| 13 | + |
| 14 | +You generally only need to submit a CLA once, so if you've already submitted one |
| 15 | +(even if it was for a different project), you probably don't need to do it |
| 16 | +again. |
| 17 | + |
| 18 | +## Code reviews |
| 19 | + |
| 20 | +All submissions, including submissions by project members, require review. We |
| 21 | +use GitHub pull requests for this purpose. Consult [GitHub Help] for more |
| 22 | +information on using pull requests. |
| 23 | + |
| 24 | +## Setup local environment |
| 25 | + |
| 26 | +Clone the project and run the following commands to setup your environment |
| 27 | + |
| 28 | +```sh |
| 29 | +python3.11 -m venv venv |
| 30 | +source venv/bin/activate |
| 31 | +pip3 install --upgrade pip |
| 32 | +python3.11 -m pip install -e ".[dev]" |
| 33 | +``` |
| 34 | + |
| 35 | +(this also applies to setting up samples environment for each sample) |
| 36 | + |
| 37 | +### Running tests |
| 38 | + |
| 39 | +Without coverage: |
| 40 | +```bash |
| 41 | +python3.11 -m pytest |
| 42 | +``` |
| 43 | + |
| 44 | +With coverage: |
| 45 | +```bash |
| 46 | +python3.11 -m pytest --cov=src --cov-report term --cov-report html --cov-report xml -vv |
| 47 | +``` |
| 48 | + |
| 49 | +### Formatting code |
| 50 | + |
| 51 | +```bash |
| 52 | +yapf -i -r -p . |
| 53 | +``` |
| 54 | + |
| 55 | +### Running lints & type checking |
| 56 | + |
| 57 | +```bash |
| 58 | +# Type checking |
| 59 | +python3.11 -m mypy . |
| 60 | +# Linting |
| 61 | +python3.11 -m pylint $(git ls-files '*.py') |
| 62 | +``` |
| 63 | + |
| 64 | +### Generating Docs |
| 65 | + |
| 66 | +Prerequisites: |
| 67 | + - On OSX, install getopt: |
| 68 | + - `brew install gnu-getopt` |
| 69 | + |
| 70 | +```sh |
| 71 | +./docs/generate.sh --out=./docs/build/ --pypath=src/ |
| 72 | +``` |
| 73 | + |
| 74 | +### Deploying a sample for testing |
| 75 | + |
| 76 | +Example: |
| 77 | + |
| 78 | +```sh |
| 79 | +cd samples/basic_https |
| 80 | +firebase deploy --only=functions |
| 81 | +``` |
| 82 | + |
| 83 | +Note to test your local changes of `firebase-functions` when deploying you should push your changes to a branch on GitHub and then locally in the `sample/*/requirements.txt` change `firebase-functions` dependency line to instead come from git, e.g. : |
| 84 | + |
| 85 | +``` |
| 86 | +git+https://github.com/YOUR_USERNAME/firebase-functions-python.git@YOURBRANCH#egg=firebase-functions |
| 87 | +``` |
| 88 | + |
| 89 | +[github help]: https://help.github.com/articles/about-pull-requests/ |
0 commit comments