diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..6a3c3c48 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,89 @@ +# How to contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +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 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. + +## Code reviews + +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. + +## Setup local environment + +Clone the project and run the following commands to setup your environment + +```sh +python3.11 -m venv venv +source venv/bin/activate +pip3 install --upgrade pip +python3.11 -m pip install -e ".[dev]" +``` + +(this also applies to setting up samples environment for each sample) + +### Running tests + +Without coverage: +```bash +python3.11 -m pytest +``` + +With coverage: +```bash +python3.11 -m pytest --cov=src --cov-report term --cov-report html --cov-report xml -vv +``` + +### Formatting code + +```bash +yapf -i -r -p . +``` + +### Running lints & type checking + +```bash +# Type checking +python3.11 -m mypy . +# Linting +python3.11 -m pylint $(git ls-files '*.py') +``` + +### Generating Docs + +Prerequisites: + - On OSX, install getopt: + - `brew install gnu-getopt` + +```sh +./docs/generate.sh --out=./docs/build/ --pypath=src/ +``` + +### Deploying a sample for testing + +Example: + +```sh +cd samples/basic_https +firebase deploy --only=functions +``` + +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. : + +``` +git+https://github.com/YOUR_USERNAME/firebase-functions-python.git@YOURBRANCH#egg=firebase-functions +``` + +[github help]: https://help.github.com/articles/about-pull-requests/ \ No newline at end of file diff --git a/README.md b/README.md index 01260251..c3cbedb7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,39 @@ -# Firebase Functions Python SDK +# Cloud Functions for Firebase Python SDK (Public Preview) -Welcome GitHub lurker! This repository is a work in progress. It will eventually let users create Cloud Functions for Firebase in Python. This feature is under very early development and not ready for testing. When it is ready, you can get first access by signing up for the [Firebase Alpha Program](https://services.google.cn/fb/forms/firebasealphaprogram/). +The [`firebase-functions`](https://pypi.org/project/firebase-functions/) package provides an SDK for defining Cloud Functions for Firebase in Python. -While you wait for us to get this feature ready for the public, we'd really appreciate you not blowing this up. Let's keep things on the down low for now. 🤫 +Cloud Functions provides hosted, private, and scalable environment where you can run server code. The Firebase SDK for Cloud Functions integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features. + +## Learn more + +Learn more about the Firebase SDK for Cloud Functions in the [Firebase documentation](https://firebase.google.com/docs/functions/) or [check out our samples](https://github.com/firebase/functions-samples). + +Here are some resources to get help: + +- Start with the quickstart: https://firebase.google.com/docs/functions/get-started +- Go through the guide: https://firebase.google.com/docs/functions/ +- Read the full API reference: https://firebase.google.com/docs/reference/functions/2nd-gen/python +- Browse some examples: https://github.com/firebase/functions-samples + +If the official documentation doesn't help, try asking through our official support channels: https://firebase.google.com/support/ + +## Usage + +```python +# functions/main.py +from firebase_functions import db_fn +from notify_users import api + +@db_fn.on_value_created(reference="/posts/{post_id}") +def new_post(event): + print(f"Received new post with ID: {event.params.get('post_id')}") + return notifyUsers(event.data) +``` + +## Contributing + +To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md). + +## License + +© Google, 2023. Licensed under [Apache License](LICENSE). \ No newline at end of file