Skip to content

Commit 9790763

Browse files
authored
Merge branch 'master' into add-py-typed
2 parents a0cc6c3 + bde3fb0 commit 9790763

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3711
-487
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
29 Bytes
Binary file not shown.

.github/scripts/publish_preflight_check.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
7171
fi
7272

7373
echo_info "Extracted release version: ${RELEASE_VERSION}"
74-
echo "::set-output name=version::v${RELEASE_VERSION}"
74+
echo "version=v${RELEASE_VERSION}" >> $GITHUB_OUTPUT
7575

7676

7777
echo_info ""
@@ -169,12 +169,13 @@ readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
169169
echo "$CHANGELOG"
170170

171171
# Parse and preformat the text to handle multi-line output.
172-
# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870
172+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
173+
# and https://github.com/github/docs/issues/21529#issue-1418590935
173174
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"`
174-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//'%'/'%25'}"
175-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\n'/'%0A'}"
176-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\r'/'%0D'}"
177-
echo "::set-output name=changelog::${FILTERED_CHANGELOG}"
175+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\''/'"'}"
176+
echo "changelog<<CHANGELOGEOF" >> $GITHUB_OUTPUT
177+
echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT
178+
echo "CHANGELOGEOF" >> $GITHUB_OUTPUT
178179

179180

180181
echo ""

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
python: ['3.7', '3.8', '3.9', '3.10', 'pypy3.8']
11+
python: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9']
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python }}
16-
uses: actions/setup-python@v4
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python }}
1919
- name: Install dependencies
@@ -22,10 +22,10 @@ jobs:
2222
pip install -r requirements.txt
2323
- name: Test with pytest
2424
run: pytest
25-
- name: Set up Node.js 16
26-
uses: actions/setup-node@v1
25+
- name: Set up Node.js 20
26+
uses: actions/setup-node@v4
2727
with:
28-
node-version: 16.x
28+
node-version: 20
2929
- name: Run integration tests against emulator
3030
run: |
3131
npm install -g firebase-tools
@@ -34,11 +34,11 @@ jobs:
3434
lint:
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@v3
38-
- name: Set up Python 3.7
39-
uses: actions/setup-python@v4
37+
- uses: actions/checkout@v4
38+
- name: Set up Python 3.8
39+
uses: actions/setup-python@v5
4040
with:
41-
python-version: 3.7
41+
python-version: 3.8
4242
- name: Install dependencies
4343
run: |
4444
python -m pip install --upgrade pip

.github/workflows/nightly.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ jobs:
2929

3030
steps:
3131
- name: Checkout source for staging
32-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
3333
with:
3434
ref: ${{ github.event.client_payload.ref || github.ref }}
3535

3636
- name: Set up Python
37-
uses: actions/setup-python@v4
37+
uses: actions/setup-python@v5
3838
with:
39-
python-version: 3.7
39+
python-version: 3.8
4040

4141
- name: Install dependencies
4242
run: |
@@ -62,7 +62,7 @@ jobs:
6262
# Attach the packaged artifacts to the workflow output. These can be manually
6363
# downloaded for later inspection if necessary.
6464
- name: Archive artifacts
65-
uses: actions/upload-artifact@v1
65+
uses: actions/upload-artifact@v4
6666
with:
6767
name: dist
6868
path: dist

.github/workflows/release.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ jobs:
4040
# via the 'ref' client parameter.
4141
steps:
4242
- name: Checkout source for staging
43-
uses: actions/checkout@v2
43+
uses: actions/checkout@v4
4444
with:
4545
ref: ${{ github.event.client_payload.ref || github.ref }}
4646

4747
- name: Set up Python
48-
uses: actions/setup-python@v4
48+
uses: actions/setup-python@v5
4949
with:
50-
python-version: 3.7
50+
python-version: 3.8
5151

5252
- name: Install dependencies
5353
run: |
@@ -73,7 +73,7 @@ jobs:
7373
# Attach the packaged artifacts to the workflow output. These can be manually
7474
# downloaded for later inspection if necessary.
7575
- name: Archive artifacts
76-
uses: actions/upload-artifact@v1
76+
uses: actions/upload-artifact@v4
7777
with:
7878
name: dist
7979
path: dist
@@ -87,45 +87,43 @@ jobs:
8787
# 3. with the label 'release:publish', and
8888
# 4. the title prefix '[chore] Release '.
8989
if: github.event.pull_request.merged &&
90-
github.ref == 'master' &&
90+
github.ref == 'refs/heads/master' &&
9191
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
9292
startsWith(github.event.pull_request.title, '[chore] Release ')
9393

9494
runs-on: ubuntu-latest
95+
permissions:
96+
# Used to create a short-lived OIDC token which is given to PyPi to identify this workflow job
97+
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
98+
# and https://docs.pypi.org/trusted-publishers/using-a-publisher/
99+
id-token: write
100+
contents: write
95101

96102
steps:
97103
- name: Checkout source for publish
98-
uses: actions/checkout@v2
104+
uses: actions/checkout@v4
99105

100106
# Download the artifacts created by the stage_release job.
101107
- name: Download release candidates
102-
uses: actions/download-artifact@v1
108+
uses: actions/download-artifact@v4.1.7
103109
with:
104110
name: dist
111+
path: dist
105112

106113
- name: Publish preflight check
107114
id: preflight
108115
run: ./.github/scripts/publish_preflight_check.sh
109116

110-
# We pull this action from a custom fork of a contributor until
111-
# https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of
112-
# this action does not support the "body" parameter.
117+
# See: https://cli.github.com/manual/gh_release_create
113118
- name: Create release tag
114-
uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
115119
env:
116120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117-
with:
118-
tag_name: ${{ steps.preflight.outputs.version }}
119-
release_name: Firebase Admin Python SDK ${{ steps.preflight.outputs.version }}
120-
body: ${{ steps.preflight.outputs.changelog }}
121-
draft: false
122-
prerelease: false
121+
run: gh release create ${{ steps.preflight.outputs.version }}
122+
--title "Firebase Admin Python SDK ${{ steps.preflight.outputs.version }}"
123+
--notes '${{ steps.preflight.outputs.changelog }}'
123124

124125
- name: Publish to Pypi
125-
uses: pypa/gh-action-pypi-publish@v1.0.0a0
126-
with:
127-
user: firebase
128-
password: ${{ secrets.PYPI_PASSWORD }}
126+
uses: pypa/gh-action-pypi-publish@release/v1
129127

130128
# Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
131129
- name: Post to Twitter

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ htmlcov/
1313
.pytest_cache/
1414
.vscode/
1515
.venv/
16+
.DS_Store

CONTRIBUTING.md

Lines changed: 90 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ information on using pull requests.
8585

8686
### Initial Setup
8787

88-
You need Python 3.7+ to build and test the code in this repo.
88+
You need Python 3.8+ to build and test the code in this repo.
8989

9090
We recommend using [pip](https://pypi.python.org/pypi/pip) for installing the necessary tools and
9191
project dependencies. Most recent versions of Python ship with pip. If your development environment
@@ -162,44 +162,95 @@ pytest --cov=firebase_admin --cov=tests
162162

163163
### Integration Testing
164164

165-
A suite of integration tests are available under the `integration/` directory.
166-
These tests are designed to run against an actual Firebase project. Create a new
167-
project in the [Firebase Console](https://console.firebase.google.com), if you
168-
do not already have one suitable for running the tests aginst. Then obtain the
169-
following credentials from the project:
170-
171-
1. *Service account certificate*: This can be downloaded as a JSON file from
172-
the "Settings > Service Accounts" tab of the Firebase console. Copy the
173-
file into the repo so it's available at `cert.json`.
174-
2. *Web API key*: This is displayed in the "Settings > General" tab of the
175-
console. Copy it and save to a new text file at `apikey.txt`.
176-
177-
Then set up your Firebase/GCP project as follows:
178-
179-
1. Enable Firestore: Go to the Firebase Console, and select "Database" from
180-
the "Develop" menu. Click on the "Create database" button. You may choose
181-
to set up Firestore either in the locked mode or in the test mode.
182-
2. Enable password auth: Select "Authentication" from the "Develop" menu in
183-
Firebase Console. Select the "Sign-in method" tab, and enable the
184-
"Email/Password" sign-in method, including the Email link (passwordless
185-
sign-in) option.
186-
3. Enable the Firebase ML API: Go to the
187-
[Google Developers Console](
188-
https://console.developers.google.com/apis/api/firebaseml.googleapis.com/overview)
189-
and make sure your project is selected. If the API is not already enabled, click Enable.
190-
4. Enable the IAM API: Go to the
191-
[Google Cloud Platform Console](https://console.cloud.google.com) and make
192-
sure your Firebase/GCP project is selected. Select "APIs & Services >
193-
Dashboard" from the main menu, and click the "ENABLE APIS AND SERVICES"
194-
button. Search for and enable the "Identity and Access Management (IAM)
195-
API".
196-
5. Grant your service account the 'Firebase Authentication Admin' role. This is
197-
required to ensure that exported user records contain the password hashes of
198-
the user accounts:
199-
1. Go to [Google Cloud Platform Console / IAM & admin](https://console.cloud.google.com/iam-admin).
200-
2. Find your service account in the list, and click the 'pencil' icon to edit it's permissions.
201-
3. Click 'ADD ANOTHER ROLE' and choose 'Firebase Authentication Admin'.
202-
4. Click 'SAVE'.
165+
166+
Integration tests are executed against a real life Firebase project. If you do not already
167+
have one suitable for running the tests against, you can create a new project in the
168+
[Firebase Console](https://console.firebase.google.com) following the setup guide below.
169+
If you already have a Firebase project, you'll need to obtain credentials to communicate and
170+
authorize access to your Firebase project:
171+
172+
173+
1. Service account certificate: This allows access to your Firebase project through a service account
174+
which is required for all integration tests. This can be downloaded as a JSON file from the
175+
**Settings > Service Accounts** tab of the Firebase console when you click the
176+
**Generate new private key** button. Copy the file into the repo so it's available at `cert.json`.
177+
> **Note:** Service accounts should be carefully managed and their keys should never be stored in publicly accessible source code or repositories.
178+
179+
180+
2. Web API key: This allows for Auth sign-in needed for some Authentication and Tenant Management
181+
integration tests. This is displayed in the **Settings > General** tab of the Firebase console
182+
after enabling Authentication as described in the steps below. Copy it and save to a new text
183+
file at `apikey.txt`.
184+
185+
186+
Set up your Firebase project as follows:
187+
188+
189+
1. Enable Authentication:
190+
1. Go to the Firebase Console, and select **Authentication** from the **Build** menu.
191+
2. Click on **Get Started**.
192+
3. Select **Sign-in method > Add new provider > Email/Password** then enable both the
193+
**Email/Password** and **Email link (passwordless sign-in)** options.
194+
195+
196+
2. Enable Firestore:
197+
1. Go to the Firebase Console, and select **Firestore Database** from the **Build** menu.
198+
2. Click on the **Create database** button. You can choose to set up Firestore either in
199+
the production mode or in the test mode.
200+
201+
202+
3. Enable Realtime Database:
203+
1. Go to the Firebase Console, and select **Realtime Database** from the **Build** menu.
204+
2. Click on the **Create Database** button. You can choose to set up the Realtime Database
205+
either in the locked mode or in the test mode.
206+
207+
> **Note:** Integration tests are not run against the default Realtime Database reference and are
208+
instead run against a database created at `https://{PROJECT_ID}.firebaseio.com`.
209+
This second Realtime Database reference is created in the following steps.
210+
211+
3. In the **Data** tab click on the kebab menu (3 dots) and select **Create Database**.
212+
4. Enter your Project ID (Found in the **General** tab in **Account Settings**) as the
213+
**Realtime Database reference**. Again, you can choose to set up the Realtime Database
214+
either in the locked mode or in the test mode.
215+
216+
217+
4. Enable Storage:
218+
1. Go to the Firebase Console, and select **Storage** from the **Build** menu.
219+
2. Click on the **Get started** button. You can choose to set up Cloud Storage
220+
either in the production mode or in the test mode.
221+
222+
223+
5. Enable the Firebase ML API:
224+
1. Go to the
225+
[Google Cloud console | Firebase ML API](https://console.cloud.google.com/apis/api/firebaseml.googleapis.com/overview)
226+
and make sure your project is selected.
227+
2. If the API is not already enabled, click **Enable**.
228+
229+
230+
6. Enable the IAM API:
231+
1. Go to the [Google Cloud console](https://console.cloud.google.com)
232+
and make sure your Firebase project is selected.
233+
2. Select **APIs & Services** from the main menu, and click the
234+
**ENABLE APIS AND SERVICES** button.
235+
3. Search for and enable **Identity and Access Management (IAM) API** by Google Enterprise API.
236+
237+
238+
7. Enable Tenant Management:
239+
1. Go to
240+
[Google Cloud console | Identity Platform](https://console.cloud.google.com/customer-identity/)
241+
and if it is not already enabled, click **Enable**.
242+
2. Then
243+
[enable multi-tenancy](https://cloud.google.com/identity-platform/docs/multi-tenancy-quickstart#enabling_multi-tenancy)
244+
for your project.
245+
246+
247+
8. Ensure your service account has the **Firebase Authentication Admin** role. This is required
248+
to ensure that exported user records contain the password hashes of the user accounts:
249+
1. Go to [Google Cloud console | IAM & admin](https://console.cloud.google.com/iam-admin).
250+
2. Find your service account in the list. If not added click the pencil icon to edit its
251+
permissions.
252+
3. Click **ADD ANOTHER ROLE** and choose **Firebase Authentication Admin**.
253+
4. Click **SAVE**.
203254

204255

205256
Now you can invoke the integration test suite as follows:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ requests, code review feedback, and also pull requests.
4343

4444
## Supported Python Versions
4545

46-
We currently support Python 3.7+. Firebase
46+
We currently support Python 3.7+. However, Python 3.7 and Python 3.8 support is deprecated,
47+
and developers are strongly advised to use Python 3.9 or higher. Firebase
4748
Admin Python SDK is also tested on PyPy and
4849
[Google App Engine](https://cloud.google.com/appengine/) environments.
4950

firebase_admin/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"""About information (version, etc) for Firebase Admin SDK."""
1616

17-
__version__ = '6.2.0'
17+
__version__ = '6.8.0'
1818
__title__ = 'firebase_admin'
1919
__author__ = 'Firebase'
2020
__license__ = 'Apache License 2.0'

0 commit comments

Comments
 (0)