Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: firebase/firebase-admin-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.5.0
Choose a base ref
...
head repository: firebase/firebase-admin-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Nov 30, 2017

  1. Fixing start_at, end_at, equal_to queries to accept False values (#96)

    * Fixing start_at, end_at, equal_to queries to accept False values
    
    * Updating docs
    hiranya911 authored Nov 30, 2017
    Copy the full SHA
    11f70f0 View commit details

Commits on Dec 5, 2017

  1. Custom Claims and List Users Support (#86)

    * Implemented set_custom_user_claims() function
    
    * Unit and integration tests for the new functionality
    
    * Implemented list_users() function
    
    * Tests for list users API
    
    * Updated tests
    
    * Implemented user iteration using Python's native iterable API
    
    * Cleaned up the test code
    
    * Moved user iteration logic to _user_mgt
    
    * Code cleanup
    
    * Updated the list users API by adding the ListUsersPage class
    
    * Updated error message
    hiranya911 authored Dec 5, 2017
    Copy the full SHA
    8f7c906 View commit details

Commits on Dec 6, 2017

  1. Copy the full SHA
    e9c78e2 View commit details
  2. Copy the full SHA
    89beac0 View commit details

Commits on Dec 8, 2017

  1. Copy the full SHA
    90bce1d View commit details
  2. Fixing a typo (#103)

    hiranya911 authored Dec 8, 2017
    Copy the full SHA
    6901b89 View commit details

Commits on Dec 20, 2017

  1. Implemented IID delete API (#95)

    * Implemented IID delete API
    
    * Implemented better error handling
    
    * Improved error handling
    
    * Resolved TODO regarding backend errors
    
    * Fixing typo
    
    * Improved error handling
    
    * Updated error message format
    hiranya911 authored Dec 20, 2017
    Copy the full SHA
    3b6b613 View commit details

Commits on Dec 21, 2017

  1. Copy the full SHA
    d2b3c94 View commit details

Commits on Jan 10, 2018

  1. Shallow reads support in database API (#109)

    * Shallow reads support in database API
    
    * Updated docstring
    hiranya911 authored Jan 10, 2018
    Copy the full SHA
    cd4e7d6 View commit details

Commits on Jan 11, 2018

  1. Auto init (#105)

    Read the default options from the FIREBASE_CONFIG env var if options are not passed to initialize_app.
    avishalom authored Jan 11, 2018
    Copy the full SHA
    f5d6071 View commit details
  2. Contributing (#110)

    * documenting test coverage reports
    avishalom authored Jan 11, 2018
    Copy the full SHA
    f6a6610 View commit details
  3. Dropping py33 from the list of validation environments (This version …

    …of Python is no longer supported upstream, and it's becoming hard to find good installation candidates). (#111)
    hiranya911 authored and avishalom committed Jan 11, 2018
    Copy the full SHA
    e6fd8d1 View commit details
  4. Copy the full SHA
    22bd2f4 View commit details
  5. Copy the full SHA
    c05ee5d View commit details

Commits on Jan 18, 2018

  1. Copy the full SHA
    0b2b029 View commit details

Commits on Jan 22, 2018

  1. Create CHANGELOG.md (#119)

    * Create CHANGELOG.md
    
    Create changlelog from https://firebase.google.com/support/release-notes/admin/python
    
    * Update CHANGELOG.md
    
    Oops.. forgot to fully qualify docs urls
    teskey authored and hiranya911 committed Jan 22, 2018
    Copy the full SHA
    9f3b8de View commit details

Commits on Jan 24, 2018

  1. Prepare Script to Update Changelog (#120)

    * Updating change log at releases
    
    * Updated prepare script
    
    * Addressing some styling concerns
    hiranya911 authored Jan 24, 2018
    Copy the full SHA
    cec75e1 View commit details
  2. Copy the full SHA
    d2d0060 View commit details

Commits on Jan 29, 2018

  1. Copy the full SHA
    5f90e02 View commit details

Commits on Feb 2, 2018

  1. Non existing iid (#124)

    * non-existing-uid
    
    * legal iid comment
    avishalom authored Feb 2, 2018
    Copy the full SHA
    8b89a9c View commit details
  2. Copy the full SHA
    ef397a0 View commit details

Commits on Feb 13, 2018

  1. Revoke refresh token (#123)

    * adding revoke_refresh_tokens verify_id_token(check_revoked), and the tokens_valid_after_timestamp preoperty
    avishalom authored Feb 13, 2018
    Copy the full SHA
    a85865c View commit details
  2. Firebase Cloud Messaging API (#117)

    * Implemented FCM send functionality
    
    * Added integration tests; Implemented dry_run support
    
    * Added webpush support
    
    * Added APNS support
    
    * Implemented topic management functions
    
    * FCM error handling
    
    * Improved error handling
    
    * Updated documentation
    
    * Adding APNS types
    
    * Updated docs and tests
    
    * Handling TTL encoding and added more tests
    
    * Fixing a lint error in tests; Updated changelog
    
    * Accept prefixed topic named (#126)
    
    * Accept prefixed topic named
    
    * Minor refactoring
    
    * Updated FCM error codes (#127)
    hiranya911 authored Feb 13, 2018
    Copy the full SHA
    d7e8494 View commit details
  3. Guard agains non boolean values in check_revoked + tests (#128)

    * Guard agains non bools in check_revoked + tests
    
    * lint
    
    * whitespace
    avishalom authored Feb 13, 2018
    Copy the full SHA
    432f4e5 View commit details

Commits on Feb 14, 2018

  1. Copy the full SHA
    176ef5f View commit details

Commits on Feb 20, 2018

  1. 1
    Copy the full SHA
    432a207 View commit details

Commits on Mar 1, 2018

  1. Copy the full SHA
    bf783c3 View commit details

Commits on Mar 9, 2018

  1. Copy the full SHA
    328036c View commit details

Commits on Mar 15, 2018

  1. Copy the full SHA
    9564ce0 View commit details
  2. Bumped version to 2.9.1 (#137)

    * Bumped version to 2.9.1
    
    * Changlog updates
    
    * Changlog url
    
    * trigger cla check
    avishalom authored Mar 15, 2018
    Copy the full SHA
    7e0d47e View commit details

Commits on Mar 21, 2018

  1. Copy the full SHA
    b9a0f1b View commit details

Commits on Mar 27, 2018

  1. Copy the full SHA
    1af54ed View commit details

Commits on Mar 30, 2018

  1. Reading FCM error code from details section (#146)

    * Reading FCM error code from details section
    
    * Early terminating the loop
    hiranya911 authored Mar 30, 2018
    Copy the full SHA
    9239585 View commit details

Commits on Apr 3, 2018

  1. Implementing support for APNS mutable-content field (#143)

    * Implementing support for APNS content-mutable field
    
    * Corrected the mutable-content option name
    
    * Renamed custom_fields to custom_data; Updated CHANGELOG
    
    * Cleaned up tests for clarity
    hiranya911 authored Apr 3, 2018
    Copy the full SHA
    a9300ef View commit details

Commits on Apr 4, 2018

  1. Session Management API (#147)

    * Moved token generation/validation code to new helper module
    
    * Basic session cookie support (without tests)
    
    * Separated token generation and verification into two classes
    
    * Added unit tests for session management
    
    * Fixing a lint error
    
    * Added integration tests
    
    * Handling article in error messages
    
    * Fixed a lint error
    
    * Updated changelog
    hiranya911 authored Apr 4, 2018
    Copy the full SHA
    18eb9aa View commit details

Commits on Apr 5, 2018

  1. Re-organizing Auth Unit Tests (#149)

    * Re-organizing auth unit tests
    
    * Moving _request to TokenVerifier class
    
    * Updated tests
    hiranya911 authored Apr 5, 2018
    Copy the full SHA
    c2f3ffe View commit details
  2. Caching Public Keys for ID Token and Cookie Verification (#150)

    * Re-organizing auth unit tests
    
    * Moving _request to TokenVerifier class
    
    * Updated tests
    
    * Caching public certificates used to verify ID tokens and session cookies
    hiranya911 authored Apr 5, 2018
    Copy the full SHA
    dbd8da5 View commit details

Commits on Apr 11, 2018

  1. Snippets for Session Management (#148)

    * Moved token generation/validation code to new helper module
    
    * Basic session cookie support (without tests)
    
    * Separated token generation and verification into two classes
    
    * Added unit tests for session management
    
    * Fixing a lint error
    
    * Added integration tests
    
    * Handling article in error messages
    
    * Fixed a lint error
    
    * Updated changelog
    
    * Added snippets for auth session management
    
    * Updated snippets
    
    * Added some comments
    
    * Merged with master; Updated CHANGELOG for #150
    
    * Minor improvements to samples
    hiranya911 authored Apr 11, 2018
    Copy the full SHA
    6fbf507 View commit details

Commits on Apr 12, 2018

  1. Copy the full SHA
    2e75177 View commit details

Commits on May 16, 2018

  1. Using Python 3 compatible print statements in snippets (#157) (#159)

    * Uses python 3 compatible print statements.
    
    * Fixed Python 3 incompatible print syntax used in snippets.
    
    * adjusting snippets to lint happily on Python <3
    
     - added "from __future__ import print_function" in snippets using
       print to make pylint "print-function-aware" and lint Python 3.x
       print-syntax without errors when running under Python 2.x.
    
    * remove unwanted parens from print statements in snippets
    
     - delete duplicate parens added in previous commits
    
    * Uses python 3 compatible print statements.
    
    * Fixed Python 3 incompatible print syntax used in snippets.
    
     - added "from __future__ import print_function" in snippets using
       print to make pylint "print-function-aware" and lint Python 3.x
       print-syntax without errors when running under Python 2.x.
     - delete duplicate parens used in print statements
    Nicolas Couture authored and hiranya911 committed May 16, 2018
    Copy the full SHA
    9444c95 View commit details

Commits on May 22, 2018

  1. Copy the full SHA
    351d624 View commit details
  2. Copy the full SHA
    b01f30d View commit details
  3. Refactored the _user_mgt module (#154)

    * Refactored the validators and paylaod constructors
    
    * Fixed a lint error and other regressions
    
    * Facilitating more duck typing in the API
    hiranya911 authored May 22, 2018
    Copy the full SHA
    18657b9 View commit details

Commits on May 29, 2018

  1. Implementing the import_users() API (#168)

    * Refactored the validators and paylaod constructors
    
    * Fixed a lint error and other regressions
    
    * Adding initial test cases
    
    * Added more tests; Added documentation
    
    * Moved more public API types to _user_mgt and aliased them
    
    * Added hash support
    
    * Handling b64 encoding correctly for py3
    
    * Integration tests for import users
    
    * Cleaning up UserImportRecord public API
    
    * Cleaned up the API surface; Relaxed vlidation and used duck typing instead
    
    * Facilitating more duck typing in the API
    
    * Further splitting the _user_mgt module into sub modules
    
    * refactored the UserProvider API
    
    * Added the rest of the hash algorithms
    
    * Added some documentation
    hiranya911 authored May 29, 2018
    Copy the full SHA
    4b2e858 View commit details

Commits on May 30, 2018

  1. Updated API docs (#171)

    * Updated API refs; Renamed UserImportRecord to ImportUserRecord
    
    * Updated documentation for hash types
    
    * Added snippets for import_users() API (#172)
    hiranya911 authored May 30, 2018
    Copy the full SHA
    e4604da View commit details

Commits on May 31, 2018

  1. Bumped version to 2.11.0 (#174)

    * Bumped version to 2.11.0
    
    * Removing redundant whitespace
    hiranya911 authored May 31, 2018
    Copy the full SHA
    4cf7374 View commit details

Commits on Jun 29, 2018

  1. Reading project ID from GOOGLE_CLOUD_PROJECT (#176)

    * Reading project ID from GOOGLE_CLOUD_PROJECT
    
    * Updated changelog
    
    * Renamed local variable for clarity
    hiranya911 authored Jun 29, 2018
    Copy the full SHA
    14e5dc4 View commit details

Commits on Jul 12, 2018

  1. Support for creating custom tokens without service account credentials (

    #175)
    
    * Ability to sign custom tokens without a service account
    
    * Fixing tests for py3
    
    * Fix for Python 3.5
    
    * Implemented go/firebase-admin-sign
    
    * Sending the required headers when calling the metadata service
    
    * Renamed service_account option to service_account_+id
    
    * Added discovery failiure test
    
    * Added snippet; Updated error message to be in sync with docs
    
    * Renamed service_account_id option to serviceAccountId for consistency
    hiranya911 authored Jul 12, 2018
    Copy the full SHA
    e4950a0 View commit details
  2. Copy the full SHA
    be6c050 View commit details

Commits on Jul 17, 2018

  1. Bumped version to 2.12.0 (#181)

    * Bumped version to 2.12.0
    
    * Updated changelog
    hiranya911 authored Jul 17, 2018
    Copy the full SHA
    70d9817 View commit details
Showing with 30,438 additions and 2,410 deletions.
  1. +17 −5 ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug_report.md
  2. +20 −0 .github/ISSUE_TEMPLATE/feature_request.md
  3. +6 −0 .github/dependabot.yml
  4. BIN .github/resources/integ-service-account.json.gpg
  5. +79 −0 .github/scripts/generate_changelog.sh
  6. +184 −0 .github/scripts/publish_preflight_check.sh
  7. +25 −0 .github/scripts/run_integration_tests.sh
  8. +47 −0 .github/workflows/ci.yml
  9. +99 −0 .github/workflows/nightly.yml
  10. +142 −0 .github/workflows/release.yml
  11. +7 −2 .gitignore
  12. +14 −0 .opensource/project.json
  13. +40 −65 .pylintrc
  14. +0 −13 .travis.yml
  15. +106 −48 CONTRIBUTING.md
  16. +8 −4 README.md
  17. +6 −10 scripts/bash_utils.sh → firebase_admin/__about__.py
  18. +116 −55 firebase_admin/__init__.py
  19. +761 −0 firebase_admin/_auth_client.py
  20. +431 −0 firebase_admin/_auth_providers.py
  21. +491 −0 firebase_admin/_auth_utils.py
  22. +256 −11 firebase_admin/_http_client.py
  23. +718 −0 firebase_admin/_messaging_encoder.py
  24. +505 −0 firebase_admin/_messaging_utils.py
  25. +223 −0 firebase_admin/_retry.py
  26. +87 −0 firebase_admin/_rfc3339.py
  27. +205 −0 firebase_admin/_sseclient.py
  28. +466 −0 firebase_admin/_token_gen.py
  29. +103 −0 firebase_admin/_user_identifier.py
  30. +520 −0 firebase_admin/_user_import.py
  31. +802 −236 firebase_admin/_user_mgt.py
  32. +317 −4 firebase_admin/_utils.py
  33. +161 −0 firebase_admin/app_check.py
  34. +754 −479 firebase_admin/auth.py
  35. +71 −40 firebase_admin/credentials.py
  36. +352 −181 firebase_admin/db.py
  37. +237 −0 firebase_admin/exceptions.py
  38. +52 −41 firebase_admin/firestore.py
  39. +92 −0 firebase_admin/firestore_async.py
  40. +439 −0 firebase_admin/functions.py
  41. +99 −0 firebase_admin/instance_id.py
  42. +607 −0 firebase_admin/messaging.py
  43. +939 −0 firebase_admin/ml.py
  44. +663 −0 firebase_admin/project_management.py
  45. +762 −0 firebase_admin/remote_config.py
  46. +13 −10 firebase_admin/storage.py
  47. +439 −0 firebase_admin/tenant_mgt.py
  48. +4 −5 integration/conftest.py
  49. +756 −20 integration/test_auth.py
  50. +116 −53 integration/test_db.py
  51. +59 −8 integration/test_firestore.py
  52. +114 −0 integration/test_firestore_async.py
  53. +56 −0 integration/test_functions.py
  54. +26 −0 integration/test_instance_id.py
  55. +223 −0 integration/test_messaging.py
  56. +378 −0 integration/test_ml.py
  57. +179 −0 integration/test_project_management.py
  58. +4 −4 integration/test_storage.py
  59. +418 −0 integration/test_tenant_mgt.py
  60. +8 −5 lint.sh
  61. +13 −9 requirements.txt
  62. +0 −102 scripts/prepare_release.sh
  63. +0 −45 scripts/verify_release.sh
  64. +3 −4 setup.cfg
  65. +32 −27 setup.py
  66. 0 snippets/__init__.py
  67. 0 snippets/auth/__init__.py
  68. +29 −0 snippets/auth/get_service_account_tokens.py
  69. +1,106 −0 snippets/auth/index.py
  70. 0 snippets/database/__init__.py
  71. +360 −0 snippets/database/index.py
  72. 0 snippets/firestore/__init__.py
  73. +84 −0 snippets/firestore/firestore.py
  74. +132 −0 snippets/firestore/firestore_async.py
  75. 0 snippets/messaging/__init__.py
  76. +269 −0 snippets/messaging/cloud_messaging.py
  77. +6 −0 tests/data/firebase_config.json
  78. 0 tests/data/firebase_config_empty.json
  79. +1 −0 tests/data/firebase_config_invalid.json
  80. +4 −0 tests/data/firebase_config_invalid_key.json
  81. +4 −0 tests/data/firebase_config_partial.json
  82. +2 −1 tests/data/get_user.json
  83. +1 −0 tests/data/invalid_model.tflite
  84. +18 −0 tests/data/list_oidc_provider_configs.json
  85. +40 −0 tests/data/list_saml_provider_configs.json
  86. +55 −0 tests/data/list_users.json
  87. BIN tests/data/model1.tflite
  88. +7 −0 tests/data/oidc_provider_config.json
  89. +18 −0 tests/data/saml_provider_config.json
  90. +210 −30 tests/test_app.py
  91. +275 −0 tests/test_app_check.py
  92. +0 −584 tests/test_auth.py
  93. +755 −0 tests/test_auth_providers.py
  94. +22 −7 tests/test_credentials.py
  95. +469 −160 tests/test_db.py
  96. +175 −0 tests/test_exceptions.py
  97. +143 −53 tests/test_firestore.py
  98. +167 −0 tests/test_firestore_async.py
  99. +323 −0 tests/test_functions.py
  100. +647 −43 tests/test_http_client.py
  101. +148 −0 tests/test_instance_id.py
  102. +2,425 −0 tests/test_messaging.py
  103. +1,088 −0 tests/test_ml.py
  104. +1,252 −0 tests/test_project_management.py
  105. +984 −0 tests/test_remote_config.py
  106. +454 −0 tests/test_retry.py
  107. +67 −0 tests/test_rfc3339.py
  108. +144 −0 tests/test_sseclient.py
  109. +1 −1 tests/test_storage.py
  110. +1,052 −0 tests/test_tenant_mgt.py
  111. +905 −0 tests/test_token_gen.py
  112. +1,561 −0 tests/test_user_mgt.py
  113. +165 −10 tests/testutils.py
  114. +0 −35 tox.ini
22 changes: 17 additions & 5 deletions ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
---
name: Bug report
about: Bug reports related to any component in this repo
title: ''
labels: ''
assignees: ''

---

### [READ] Step 1: Are you in the right place?

* For issues or feature requests related to __the code in this repository__
file a Github issue.
* If this is a __feature request__ make sure the issue title starts with "FR:".
* For issues related to __the code in this repository__ file a GitHub issue.
* If the issue pertains to __Cloud Firestore__, report directly in the
[Python Firestore](https://github.com/googleapis/python-firestore) GitHub repo. Firestore
bugs reported in this repo will be closed with a reference to the Python Firestore
project.
* For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/)
with the firebase tag.
with the `firebase` tag.
* For general Firebase discussion, use the [firebase-talk](https://groups.google.com/forum/#!forum/firebase-talk)
google group.
* For help troubleshooting your application that does not fall under one
@@ -15,8 +26,9 @@

* Operating System version: _____
* Firebase SDK version: _____
* Library version: _____
* Firebase Product: _____ (auth, database, storage, etc)
* Python version: _____
* Pip version: _____

### [REQUIRED] Step 3: Describe the problem

20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FR]"
labels: 'type: feature request'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context, code samples or screenshots about the feature request here.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
Binary file added .github/resources/integ-service-account.json.gpg
Binary file not shown.
79 changes: 79 additions & 0 deletions .github/scripts/generate_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
set -u

function printChangelog() {
local TITLE=$1
shift
# Skip the sentinel value.
local ENTRIES=("${@:2}")
if [ ${#ENTRIES[@]} -ne 0 ]; then
echo "### ${TITLE}"
echo ""
for ((i = 0; i < ${#ENTRIES[@]}; i++))
do
echo "* ${ENTRIES[$i]}"
done
echo ""
fi
}

if [[ -z "${GITHUB_SHA}" ]]; then
GITHUB_SHA="HEAD"
fi

LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2> /dev/null` || true
if [[ -z "${LAST_TAG}" ]]; then
echo "[INFO] No tags found. Including all commits up to ${GITHUB_SHA}."
VERSION_RANGE="${GITHUB_SHA}"
else
echo "[INFO] Last release tag: ${LAST_TAG}."
COMMIT_SHA=`git show-ref -s ${LAST_TAG}`
echo "[INFO] Last release commit: ${COMMIT_SHA}."
VERSION_RANGE="${COMMIT_SHA}..${GITHUB_SHA}"
echo "[INFO] Including all commits in the range ${VERSION_RANGE}."
fi

echo ""

# Older versions of Bash (< 4.4) treat empty arrays as unbound variables, which triggers
# errors when referencing them. Therefore we initialize each of these arrays with an empty
# sentinel value, and later skip them.
CHANGES=("")
FIXES=("")
FEATS=("")
MISC=("")

while read -r line
do
COMMIT_MSG=`echo ${line} | cut -d ' ' -f 2-`
if [[ $COMMIT_MSG =~ ^change(\(.*\))?: ]]; then
CHANGES+=("$COMMIT_MSG")
elif [[ $COMMIT_MSG =~ ^fix(\(.*\))?: ]]; then
FIXES+=("$COMMIT_MSG")
elif [[ $COMMIT_MSG =~ ^feat(\(.*\))?: ]]; then
FEATS+=("$COMMIT_MSG")
else
MISC+=("${COMMIT_MSG}")
fi
done < <(git log ${VERSION_RANGE} --oneline)

printChangelog "Breaking Changes" "${CHANGES[@]}"
printChangelog "New Features" "${FEATS[@]}"
printChangelog "Bug Fixes" "${FIXES[@]}"
printChangelog "Miscellaneous" "${MISC[@]}"
184 changes: 184 additions & 0 deletions .github/scripts/publish_preflight_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


###################################### Outputs #####################################

# 1. version: The version of this release including the 'v' prefix (e.g. v1.2.3).
# 2. changelog: Formatted changelog text for this release.

####################################################################################

set -e
set -u

function echo_info() {
local MESSAGE=$1
echo "[INFO] ${MESSAGE}"
}

function echo_warn() {
local MESSAGE=$1
echo "[WARN] ${MESSAGE}"
}

function terminate() {
echo ""
echo_warn "--------------------------------------------"
echo_warn "PREFLIGHT FAILED"
echo_warn "--------------------------------------------"
exit 1
}


echo_info "Starting publish preflight check..."
echo_info "Git revision : ${GITHUB_SHA}"
echo_info "Workflow triggered by : ${GITHUB_ACTOR}"
echo_info "GitHub event : ${GITHUB_EVENT_NAME}"


echo_info ""
echo_info "--------------------------------------------"
echo_info "Extracting release version"
echo_info "--------------------------------------------"
echo_info ""

readonly ABOUT_FILE="firebase_admin/__about__.py"
echo_info "Loading version from: ${ABOUT_FILE}"

readonly RELEASE_VERSION=`grep "__version__" ${ABOUT_FILE} | awk '{print $3}' | tr -d \'` || true
if [[ -z "${RELEASE_VERSION}" ]]; then
echo_warn "Failed to extract release version from: ${ABOUT_FILE}"
terminate
fi

if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
echo_warn "Malformed release version string: ${RELEASE_VERSION}. Exiting."
terminate
fi

echo_info "Extracted release version: ${RELEASE_VERSION}"
echo "version=v${RELEASE_VERSION}" >> $GITHUB_OUTPUT


echo_info ""
echo_info "--------------------------------------------"
echo_info "Check release artifacts"
echo_info "--------------------------------------------"
echo_info ""

if [[ ! -d dist ]]; then
echo_warn "dist directory does not exist."
terminate
fi

readonly BIN_DIST="dist/firebase_admin-${RELEASE_VERSION}-py3-none-any.whl"
if [[ -f "${BIN_DIST}" ]]; then
echo_info "Found binary distribution (bdist_wheel): ${BIN_DIST}"
else
echo_warn "Binary distribution ${BIN_DIST} not found."
terminate
fi

readonly SRC_DIST="dist/firebase_admin-${RELEASE_VERSION}.tar.gz"
if [[ -f "${SRC_DIST}" ]]; then
echo_info "Found source distribution (sdist): ${SRC_DIST}"
else
echo_warn "Source distribution ${SRC_DIST} not found."
terminate
fi

readonly ARTIFACT_COUNT=`ls dist/ | wc -l`
if [[ $ARTIFACT_COUNT -ne 2 ]]; then
echo_warn "Unexpected artifacts in the distribution directory."
ls -l dist
terminate
fi


echo_info ""
echo_info "--------------------------------------------"
echo_info "Checking previous releases"
echo_info "--------------------------------------------"
echo_info ""

readonly PYPI_URL="https://pypi.org/pypi/firebase-admin/${RELEASE_VERSION}/json"
readonly PYPI_STATUS=`curl -s -o /dev/null -L -w "%{http_code}" ${PYPI_URL}`
if [[ $PYPI_STATUS -eq 404 ]]; then
echo_info "Release version ${RELEASE_VERSION} not found in Pypi."
elif [[ $PYPI_STATUS -eq 200 ]]; then
echo_warn "Release version ${RELEASE_VERSION} already present in Pypi."
terminate
else
echo_warn "Unexpected ${PYPI_STATUS} response from Pypi. Exiting."
terminate
fi


echo_info ""
echo_info "--------------------------------------------"
echo_info "Checking release tag"
echo_info "--------------------------------------------"
echo_info ""

echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* >---"
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo ""

readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true
if [[ -n "${EXISTING_TAG}" ]]; then
echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting."
echo_warn "If the tag was created in a previous unsuccessful attempt, delete it and try again."
echo_warn " $ git tag -d v${RELEASE_VERSION}"
echo_warn " $ git push --delete origin v${RELEASE_VERSION}"

readonly RELEASE_URL="https://github.com/firebase/firebase-admin-python/releases/tag/v${RELEASE_VERSION}"
echo_warn "Delete any corresponding releases at ${RELEASE_URL}."
terminate
fi

echo_info "Tag v${RELEASE_VERSION} does not exist."


echo_info ""
echo_info "--------------------------------------------"
echo_info "Generating changelog"
echo_info "--------------------------------------------"
echo_info ""

echo_info "---< git fetch origin master --prune --unshallow >---"
git fetch origin master --prune --unshallow
echo ""

echo_info "Generating changelog from history..."
readonly CURRENT_DIR=$(dirname "$0")
readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
echo "$CHANGELOG"

# Parse and preformat the text to handle multi-line output.
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
# and https://github.com/github/docs/issues/21529#issue-1418590935
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"`
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\''/'"'}"
echo "changelog<<CHANGELOGEOF" >> $GITHUB_OUTPUT
echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT
echo "CHANGELOGEOF" >> $GITHUB_OUTPUT


echo ""
echo_info "--------------------------------------------"
echo_info "PREFLIGHT SUCCESSFUL"
echo_info "--------------------------------------------"
25 changes: 25 additions & 0 deletions .github/scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Copyright 2020 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
set -u

gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \
--output integ-service-account.json .github/resources/integ-service-account.json.gpg

echo "${FIREBASE_API_KEY}" > integ-api-key.txt

pytest integration/ --cert integ-service-account.json --apikey integ-api-key.txt
Loading