| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # | 2 # |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # This script is to ease running Findit locally, running its unit tests, and | 7 # This script is to ease running Findit locally, running its unit tests, and |
| 8 # deploying Findit to App Engine. | 8 # deploying Findit to App Engine. |
| 9 | 9 |
| 10 THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE:-$0}" )" && pwd )" | 10 THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE:-$0}" )" && pwd )" |
| 11 FINDIT_DIR="$(realpath ${THIS_SCRIPT_DIR}/..)" | 11 FINDIT_DIR="$(realpath ${THIS_SCRIPT_DIR}/..)" |
| 12 INFRA_DIR="$(realpath ${FINDIT_DIR}/../..)" | 12 INFRA_DIR="$(realpath ${FINDIT_DIR}/../..)" |
| 13 GOOGLE_APP_ENGINE_DIR="$(realpath ${INFRA_DIR}/../google_appengine)" | 13 GOOGLE_APP_ENGINE_DIR="$(realpath ${INFRA_DIR}/../google_appengine)" |
| 14 APP_CFG="${GOOGLE_APP_ENGINE_DIR}/appcfg.py" | 14 APP_CFG="${GOOGLE_APP_ENGINE_DIR}/appcfg.py" |
| 15 FINDIT_MODULES="${FINDIT_DIR}/app.yaml ${FINDIT_DIR}/waterfall-frontend.yaml ${F
INDIT_DIR}/waterfall-backend.yaml" | 15 FINDIT_MODULES="${FINDIT_DIR}/app.yaml ${FINDIT_DIR}/waterfall-frontend.yaml ${F
INDIT_DIR}/waterfall-backend.yaml ${FINDIT_DIR}/crash-frontend.yaml ${FINDIT_DIR
}/crash-backend-fracas.yaml" |
| 16 | 16 |
| 17 if [[ -z "${USER}" ]]; then | 17 if [[ -z "${USER}" ]]; then |
| 18 echo "Cannot identify who is deploying Findit. Please set USER." | 18 echo "Cannot identify who is deploying Findit. Please set USER." |
| 19 exit 1 | 19 exit 1 |
| 20 fi | 20 fi |
| 21 | 21 |
| 22 if [[ -z "${APPENGINE_TMP}" ]]; then | 22 if [[ -z "${APPENGINE_TMP}" ]]; then |
| 23 TMP_DIR="${FINDIT_DIR}/.tmp" | 23 TMP_DIR="${FINDIT_DIR}/.tmp" |
| 24 else | 24 else |
| 25 TMP_DIR=${APPENGINE_TMP} | 25 TMP_DIR=${APPENGINE_TMP} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 echo "Code coverage report file://${coverage_report_dir}/index.html" | 57 echo "Code coverage report file://${coverage_report_dir}/index.html" |
| 58 } | 58 } |
| 59 | 59 |
| 60 run_findit_locally() { | 60 run_findit_locally() { |
| 61 local options="--storage_path ${TMP_DIR}/findit" | 61 local options="--storage_path ${TMP_DIR}/findit" |
| 62 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_DIR}/disp
atch.yaml ${FINDIT_MODULES} | 62 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_DIR}/disp
atch.yaml ${FINDIT_MODULES} |
| 63 } | 63 } |
| 64 | 64 |
| 65 deploy_findit_for_test() { | 65 deploy_findit_for_test() { |
| 66 # Deploy a version for testing, the version name is the same as the user name. | 66 # Deploy a version for testing, the version name is the same as the user name. |
| 67 local app_id="findit-for-me-dev" | 67 if [[ -z ${APP_ID} ]]; then |
| 68 if [[ "$1" == "prod" ]]; then | 68 if [[ "$1" == "prod" ]]; then |
| 69 app_id="findit-for-me" | 69 local app_id_to_use="findit-for-me" |
| 70 else |
| 71 local app_id_to_use="findit-for-me-dev" |
| 72 fi |
| 73 else |
| 74 local app_id_to_use=${APP_ID} |
| 70 fi | 75 fi |
| 76 echo "app id is ${app_id_to_use}" |
| 77 |
| 71 local new_version=${USER} | 78 local new_version=${USER} |
| 72 | 79 |
| 73 echo "-----------------------------------" | 80 echo "-----------------------------------" |
| 74 python ${APP_CFG} update -A ${app_id} $FINDIT_MODULES --version ${new_version} | 81 python ${APP_CFG} update -A ${app_id_to_use} $FINDIT_MODULES --version ${new_v
ersion} |
| 75 echo "-----------------------------------" | 82 echo "-----------------------------------" |
| 76 print_command_for_queue_cron_dispatch ${app_id} | 83 print_command_for_queue_cron_dispatch ${app_id_to_use} |
| 77 echo "-----------------------------------" | 84 echo "-----------------------------------" |
| 78 echo Findit was deployed to "https://${new_version}-dot-${app_id}.appspot.com/
" | 85 echo Findit was deployed to "https://${new_version}-dot-${app_id_to_use}.appsp
ot.com/" |
| 79 } | 86 } |
| 80 | 87 |
| 81 deploy_findit_for_prod() { | 88 deploy_findit_for_prod() { |
| 82 local app_id="findit-for-me" | 89 local app_id="findit-for-me" |
| 83 | 90 |
| 84 # Sync to latest code. | 91 # Sync to latest code. |
| 85 local update_log="${TMP_DIR}/update.log" | 92 local update_log="${TMP_DIR}/update.log" |
| 86 echo "Syncing code to tip of tree, logging in ${update_log} ..." | 93 echo "Syncing code to tip of tree, logging in ${update_log} ..." |
| 87 local update="0" #"$(cd ${INFRA_DIR} && git pull >>${update_log} 2>>${update_l
og} && gclient sync >>$update_log >>${update_log} 2>>${update_log} && echo $?)" | 94 local update="0" #"$(cd ${INFRA_DIR} && git pull >>${update_log} 2>>${update_l
og} && gclient sync >>$update_log >>${update_log} 2>>${update_log} && echo $?)" |
| 88 if [[ "${update}" != "0" ]]; then | 95 if [[ "${update}" != "0" ]]; then |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 deploy-test-dev) | 171 deploy-test-dev) |
| 165 deploy_findit_for_test "dev" | 172 deploy_findit_for_test "dev" |
| 166 ;; | 173 ;; |
| 167 deploy-test-prod) | 174 deploy-test-prod) |
| 168 deploy_findit_for_test "prod" | 175 deploy_findit_for_test "prod" |
| 169 ;; | 176 ;; |
| 170 *) | 177 *) |
| 171 print_usage | 178 print_usage |
| 172 ;; | 179 ;; |
| 173 esac | 180 esac |
| OLD | NEW |