Skip to content

Commit ceea2f0

Browse files
authored
Merge pull request #56 from invertase/firestore
feat: add support for Firestore 2nd gen triggers
2 parents 08586c8 + c60c860 commit ceea2f0

File tree

15 files changed

+598
-45
lines changed

15 files changed

+598
-45
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
python3.10 -m venv venv
2626
source venv/bin/activate
2727
pip3 install --upgrade pip
28-
python3.10 -m pip install -r requirements.txt
29-
python3.10 setup.py install
28+
python3.10 -m pip install -e ".[dev]"
3029
- name: Test with pytest & coverage
3130
run: |
3231
source venv/bin/activate
@@ -48,8 +47,7 @@ jobs:
4847
python3.10 -m venv venv
4948
source venv/bin/activate
5049
pip3 install --upgrade pip
51-
python3.10 -m pip install -r requirements.txt
52-
python3.10 setup.py install
50+
python3.10 -m pip install -e ".[dev]"
5351
- name: Lint with pylint
5452
run: |
5553
source venv/bin/activate
@@ -72,8 +70,7 @@ jobs:
7270
python3.10 -m venv venv
7371
source venv/bin/activate
7472
pip3 install --upgrade pip
75-
python3.10 -m pip install -r requirements.txt
76-
python3.10 setup.py install
73+
python3.10 -m pip install -e ".[dev]"
7774
- name: Generate Reference Docs
7875
run: |
7976
source venv/bin/activate
@@ -98,8 +95,7 @@ jobs:
9895
python3.10 -m venv venv
9996
source venv/bin/activate
10097
pip3 install --upgrade pip
101-
python3.10 -m pip install -r requirements.txt
102-
python3.10 setup.py install
98+
python3.10 -m pip install -e ".[dev]"
10399
- name: Check Formatting
104100
run: |
105101
source venv/bin/activate

requirements.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "python-functions-testing"
4+
}
5+
}

samples/basic_firestore/.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
firebase-debug.log*
8+
firebase-debug.*.log*
9+
10+
# Firebase cache
11+
.firebase/
12+
13+
# Firebase config
14+
15+
# Uncomment this if you'd like others to create their own Firebase project.
16+
# For a team working on the same Firebase project(s), it is recommended to leave
17+
# it commented so all members can deploy to the same project(s) in .firebaserc.
18+
# .firebaserc
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36+
.grunt
37+
38+
# Bower dependency directory (https://bower.io/)
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons (http://nodejs.org/api/addons.html)
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional REPL history
57+
.node_repl_history
58+
59+
# Output of 'npm pack'
60+
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Required to avoid a 'duplicate modules' mypy error
2+
# in monorepos that have multiple main.py files.
3+
# https://github.com/python/mypy/issues/4008
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"functions": [
3+
{
4+
"source": "functions",
5+
"codebase": "default",
6+
"ignore": [
7+
"venv"
8+
]
9+
}
10+
]
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# pyenv
2+
.python-version
3+
4+
# Installer logs
5+
pip-log.txt
6+
pip-delete-this-directory.txt
7+
8+
# Environments
9+
.env
10+
.venv
11+
venv/
12+
venv.bak/
13+
__pycache__
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Example Firebase Functions for Firestore written in Python
3+
"""
4+
from firebase_functions import firestore_fn, options
5+
from firebase_admin import initialize_app
6+
7+
initialize_app()
8+
9+
options.set_global_options(region=options.SupportedRegion.EUROPE_WEST1)
10+
11+
12+
@firestore_fn.on_document_written(document="hello/{world}")
13+
def onfirestoredocumentwritten(
14+
event: firestore_fn.Event[firestore_fn.Change]) -> None:
15+
print("Hello from Firestore document write event:", event)
16+
17+
18+
@firestore_fn.on_document_created(document="hello/world")
19+
def onfirestoredocumentcreated(event: firestore_fn.Event) -> None:
20+
print("Hello from Firestore document create event:", event)
21+
22+
23+
@firestore_fn.on_document_deleted(document="hello/world")
24+
def onfirestoredocumentdeleted(event: firestore_fn.Event) -> None:
25+
print("Hello from Firestore document delete event:", event)
26+
27+
28+
@firestore_fn.on_document_updated(document="hello/world")
29+
def onfirestoredocumentupdated(
30+
event: firestore_fn.Event[firestore_fn.Change]) -> None:
31+
print("Hello from Firestore document updated event:", event)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Not published yet,
2+
# firebase-functions-python >= 0.0.1
3+
# so we use a relative path during development:
4+
./../../../
5+
# Or switch to git ref for deployment testing:
6+
# git+https://github.com/firebase/firebase-functions-python.git@main#egg=firebase-functions
7+
8+
firebase-admin >= 6.0.1

samples/basic_tasks/functions/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
# git+https://github.com/firebase/firebase-functions-python.git@main#egg=firebase-functions
77

88
firebase-admin >= 6.0.1
9+
google-cloud-tasks >= 2.13.1

0 commit comments

Comments
 (0)