Skip to content

Commit 2dfc848

Browse files
committed
Merge branch 'invertase-db-event-rename'
2 parents 5d654c7 + b29f99c commit 2dfc848

File tree

20 files changed

+701
-28
lines changed

20 files changed

+701
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ jobs:
2222
python-version: ${{ matrix.python }}
2323
- name: Install dependencies
2424
run: |
25-
python setup.py install
26-
python -m pip install --upgrade pip
27-
pip install -r requirements.txt
25+
python3.10 -m venv venv
26+
source venv/bin/activate
27+
pip3 install --upgrade pip
28+
python3.10 -m pip install -r requirements.txt
29+
python3.10 setup.py install
2830
- name: Test with pytest & coverage
29-
run: python -m pytest --cov=src --cov-report term --cov-report html --cov-report xml
31+
run: |
32+
source venv/bin/activate
33+
python3.10 -m pytest --cov=src --cov-report term --cov-report html --cov-report xml -vv
3034
# TODO requires activation for this repository on codecov website first.
3135
# - name: Upload coverage to Codecov
3236
# uses: codecov/codecov-action@v3
@@ -41,9 +45,16 @@ jobs:
4145
python-version: "3.10"
4246
- name: Install dependencies
4347
run: |
44-
python -m pip install --upgrade pip
45-
pip install -r requirements.txt
48+
python3.10 -m venv venv
49+
source venv/bin/activate
50+
pip3 install --upgrade pip
51+
python3.10 -m pip install -r requirements.txt
52+
python3.10 setup.py install
4653
- name: Lint with pylint
47-
run: pylint $(git ls-files '*.py')
54+
run: |
55+
source venv/bin/activate
56+
python3.10 -m pylint $(git ls-files '*.py')
4857
- name: Lint with mypy
49-
run: python -m mypy .
58+
run: |
59+
source venv/bin/activate
60+
python3.10 -m mypy .

.pylintrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,6 @@ valid-metaclass-classmethod-first-arg=mcs
424424

425425
# Exceptions that will emit a warning when being caught. Defaults to
426426
# "Exception"
427-
overgeneral-exceptions=StandardError,
428-
Exception,
429-
BaseException
427+
overgeneral-exceptions=builtins.StandardError,
428+
builtins.Exception,
429+
builtins.BaseException

example/functions/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
reference="hello",
1818
region=options.SupportedRegion.EUROPE_WEST1,
1919
)
20-
def on_write_example(event: db.DatabaseEvent[db.Change[object]]) -> None:
20+
def on_write_example(event: db.Event[db.Change[object]]) -> None:
2121
print("Hello from db write event:", event)
2222

2323

2424
@db.on_value_created(reference="hello/{any_thing_here}/bar")
25-
def on_created_example(event: db.DatabaseEvent[object]) -> None:
25+
def on_created_example(event: db.Event[object]) -> None:
2626
print("Hello from db create event:", event)
2727

2828

2929
@db.on_value_deleted(reference="hello/{any_thing_here}/bar")
30-
def on_deleted_example(event: db.DatabaseEvent[object]) -> None:
30+
def on_deleted_example(event: db.Event[object]) -> None:
3131
print("Hello from db delete event:", event)
3232

3333

3434
@db.on_value_updated(reference="hello")
35-
def on_updated_example(event: db.DatabaseEvent[db.Change[object]]) -> None:
35+
def on_updated_example(event: db.Event[db.Change[object]]) -> None:
3636
print("Hello from db updated event:", event)
3737

3838

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
exclude = build|setup.py
2+
exclude = build|setup.py|venv
33

44
# cloudevents package has no types
55
ignore_missing_imports = True

samples/basic_storage/.firebaserc

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_storage/.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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"functions": [
3+
{
4+
"source": "functions",
5+
"codebase": "default"
6+
}
7+
]
8+
}
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: 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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Example Firebase Functions for Storage triggers.
3+
"""
4+
5+
from firebase_functions import storage
6+
from firebase_functions.storage import StorageObjectData, CloudEvent
7+
from firebase_admin import initialize_app
8+
9+
initialize_app()
10+
11+
12+
@storage.on_object_finalized()
13+
def on_object_finalized_example(event: CloudEvent[StorageObjectData]):
14+
"""
15+
This function will be triggered when a new object is created in the bucket.
16+
"""
17+
print(event)
18+
19+
20+
@storage.on_object_archived()
21+
def on_object_archived_example(event: CloudEvent[StorageObjectData]):
22+
"""
23+
This function will be triggered when an object is archived in the bucket.
24+
"""
25+
print(event)
26+
27+
28+
@storage.on_object_deleted()
29+
def on_object_deleted_example(event: CloudEvent[StorageObjectData]):
30+
"""
31+
This function will be triggered when an object is deleted in the bucket.
32+
"""
33+
print(event)
34+
35+
36+
@storage.on_object_metadata_updated()
37+
def on_object_metadata_updated_example(event: CloudEvent[StorageObjectData]):
38+
"""
39+
This function will be triggered when an object's metadata is updated in the bucket.
40+
"""
41+
print(event)

0 commit comments

Comments
 (0)