diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a952418c..61d3861bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Continuous Integration -on: push +on: pull_request jobs: build: diff --git a/.gitignore b/.gitignore index 4880bc525..79d2d5ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,8 @@ build/ dist/ *~ -scripts/cert.json -scripts/apikey.txt +cert.json +apikey.txt htmlcov/ .pytest_cache/ .vscode/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b521ec99..80a607a8d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,9 +170,9 @@ following credentials from the project: 1. *Service account certificate*: This can be downloaded as a JSON file from the "Settings > Service Accounts" tab of the Firebase console. Copy the - file into the repo so it's available at `scripts/cert.json`. + file into the repo so it's available at `cert.json`. 2. *Web API key*: This is displayed in the "Settings > General" tab of the - console. Copy it and save to a new text file at `scripts/apikey.txt`. + console. Copy it and save to a new text file at `apikey.txt`. Then set up your Firebase/GCP project as follows: @@ -202,7 +202,7 @@ Then set up your Firebase/GCP project as follows: Now you can invoke the integration test suite as follows: ``` -pytest integration/ --cert scripts/cert.json --apikey scripts/apikey.txt +pytest integration/ --cert cert.json --apikey apikey.txt ``` ### Emulator-based Integration Testing diff --git a/scripts/bash_utils.sh b/scripts/bash_utils.sh deleted file mode 100644 index 628068fb7..000000000 --- a/scripts/bash_utils.sh +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 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. - -#!/bin/bash - -function parseVersion { - if [[ ! "$1" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then - return 1 - fi - MAJOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/') - MINOR_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/') - PATCH_VERSION=$(echo "$1" | sed -e 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/') - return 0 -} diff --git a/scripts/prepare_release.sh b/scripts/prepare_release.sh deleted file mode 100755 index aa55dae92..000000000 --- a/scripts/prepare_release.sh +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2017 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. - -#!/bin/bash - -source bash_utils.sh - -function isNewerVersion { - parseVersion "$1" - ARG_MAJOR=$MAJOR_VERSION - ARG_MINOR=$MINOR_VERSION - ARG_PATCH=$PATCH_VERSION - - parseVersion "$2" - if [ "$ARG_MAJOR" -ne "$MAJOR_VERSION" ]; then - if [ "$ARG_MAJOR" -lt "$MAJOR_VERSION" ]; then return 1; else return 0; fi; - fi - if [ "$ARG_MINOR" -ne "$MINOR_VERSION" ]; then - if [ "$ARG_MINOR" -lt "$MINOR_VERSION" ]; then return 1; else return 0; fi; - fi - if [ "$ARG_PATCH" -ne "$PATCH_VERSION" ]; then - if [ "$ARG_PATCH" -lt "$PATCH_VERSION" ]; then return 1; else return 0; fi; - fi - # The build numbers are equal - return 1 -} - -set -e - -if [ -z "$1" ]; then - echo "[ERROR] No version number provided." - echo "[INFO] Usage: ./prepare_release.sh " - exit 1 -fi - - -############################# -# VALIDATE VERSION NUMBER # -############################# - -VERSION="$1" -if ! parseVersion "$VERSION"; then - echo "[ERROR] Illegal version number provided. Version number must match semver." - exit 1 -fi - -CUR_VERSION=$(grep "^__version__ =" ../firebase_admin/__about__.py | awk '{print $3}' | sed "s/'//g") -if [ -z "$CUR_VERSION" ]; then - echo "[ERROR] Failed to find the current version. Check firebase_admin/__about__.py for version declaration." - exit 1 -fi -if ! parseVersion "$CUR_VERSION"; then - echo "[ERROR] Illegal current version number. Version number must match semver." - exit 1 -fi - -if ! isNewerVersion "$VERSION" "$CUR_VERSION"; then - echo "[ERROR] Illegal version number provided. Version $VERSION <= $CUR_VERSION" - exit 1 -fi - - -############################# -# VALIDATE TEST RESOURCES # -############################# - -if [[ ! -e "cert.json" ]]; then - echo "[ERROR] cert.json file is required to run integration tests." - exit 1 -fi - -if [[ ! -e "apikey.txt" ]]; then - echo "[ERROR] apikey.txt file is required to run integration tests." - exit 1 -fi - - -################### -# VALIDATE REPO # -################### - -# Ensure the checked out branch is master -CHECKED_OUT_BRANCH="$(git branch | grep "*" | awk -F ' ' '{print $2}')" -if [[ $CHECKED_OUT_BRANCH != "master" ]]; then - read -p "[WARN] You are on the '${CHECKED_OUT_BRANCH}' branch, not 'master'. Continue? (y/N) " CONTINUE - echo - - if ! [[ $CONTINUE == "y" || $CONTINUE == "Y" ]]; then - echo "[INFO] You chose not to continue." - exit 1 - fi -fi - -# Ensure the branch does not have local changes -if [[ $(git status --porcelain) ]]; then - read -p "[WARN] Local changes exist in the repo. Continue? (y/N) " CONTINUE - echo - - if ! [[ $CONTINUE == "y" || $CONTINUE == "Y" ]]; then - echo "[INFO] You chose not to continue." - exit 1 - fi -fi - - -#################### -# UPDATE VERSION # -#################### - -HOST=$(uname) -echo "[INFO] Updating __about__.py" -if [ $HOST == "Darwin" ]; then - sed -i "" -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__about__.py" -else - sed -i -e "s/__version__ = '$CUR_VERSION'/__version__ = '$VERSION'/" "../firebase_admin/__about__.py" -fi - - -################## -# LAUNCH TESTS # -################## - -echo "[INFO] Running unit tests" -pytest ../tests - -echo "[INFO] Running integration tests" -pytest ../integration --cert cert.json --apikey apikey.txt - -echo "[INFO] This repo has been prepared for a release. Create a branch and commit the changes." diff --git a/scripts/verify_release.sh b/scripts/verify_release.sh deleted file mode 100755 index f4edd25de..000000000 --- a/scripts/verify_release.sh +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2017 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. - -#!/bin/bash - -source bash_utils.sh - -if [ -z "$1" ]; then - echo "[ERROR] No version number provided." - echo "[INFO] Usage: ./verify_release.sh " - exit 1 -fi - -VERSION="$1" -if ! parseVersion "$VERSION"; then - echo "[ERROR] Illegal version number provided. Version number must match semver." - exit 1 -fi - -mkdir sandbox -virtualenv sandbox -source sandbox/bin/activate -pip install firebase_admin -INSTALLED_VERSION=`python -c 'import firebase_admin; print firebase_admin.__version__'` -echo "[INFO] Installed firebase_admin version $INSTALLED_VERSION" -deactivate -rm -rf sandbox - -if [[ "$VERSION" == "$INSTALLED_VERSION" ]]; then - echo "[INFO] Release verified successfully" -else - echo "[ERROR] Installed version did not match the release version." - exit 1 -fi