Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: appengine/findit/util_scripts/run.sh

Issue 1866883002: [Findit] A huge refactoring and some bug fixing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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="${THIS_SCRIPT_DIR}/.." 11 FINDIT_DIR="$(realpath ${THIS_SCRIPT_DIR}/..)"
12 INFRA_DIR="${FINDIT_DIR}/../.." 12 INFRA_DIR="$(realpath ${FINDIT_DIR}/../..)"
13 GOOGLE_APP_ENGINE_DIR="${INFRA_DIR}/../google_appengine" 13 GOOGLE_APP_ENGINE_DIR="$(realpath ${INFRA_DIR}/../google_appengine)"
14 FINDIT_MODULES="${FINDIT_DIR}/app.yaml ${FINDIT_DIR}/build-failure-analysis.yaml " 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"
16
17 if [[ -z "${USER}" ]]; then
18 echo "Can't not identify who is deploying Findit. Please set USER."
lijeffrey 2016/04/07 02:57:30 nit: Cannot identify who is deploying Findit ...
stgao 2016/04/07 04:46:03 Done.
19 exit 1
20 fi
15 21
16 if [[ -z "${APPENGINE_TMP}" ]]; then 22 if [[ -z "${APPENGINE_TMP}" ]]; then
17 TMP_DIR="${FINDIT_DIR}/.tmp" 23 TMP_DIR="${FINDIT_DIR}/.tmp"
18 else 24 else
19 TMP_DIR=${APPENGINE_TMP} 25 TMP_DIR=${APPENGINE_TMP}
20 fi 26 fi
21 27
22 print_usage() { 28 print_usage() {
23 echo 29 echo
24 echo "Usage:" 30 echo "Usage:"
25 echo "$0 <command>" 31 echo "$0 <command>"
26 echo 32 echo
27 echo "Supported commands:" 33 echo "Supported commands:"
28 echo " test Run the unittest" 34 echo " test Run the unittest"
29 echo " run Run Findit locally" 35 echo " run Run Findit locally"
30 echo " deploy-test Deploy Findit to findit-for-waterfall" 36 echo " deploy-prod Deploy Findit to findit-for-me for release"
31 echo " deploy-prod Deploy Findit to findit-for-me" 37 echo " deploy-test-dev Deploy Findit to findit-for-me-dev for test"
38 echo " deploy-test-prod Deploy Findit to findit-for-me for staging test"
32 exit 1 39 exit 1
33 } 40 }
34 41
42 print_command_for_queue_cron_dispatch() {
43 echo
44 echo "If there is any change to queue.yaml, cron.yaml, or dispatch.yaml since"
45 echo " last deployment, please run appropriate commands below to update them:"
46 echo " ${APP_CFG} update_queues -A $1 ${FINDIT_DIR}"
47 echo " ${APP_CFG} update_cron -A $1 ${FINDIT_DIR}"
48 echo " ${APP_CFG} update_dispatch -A $1 ${FINDIT_DIR}"
49 }
50
35 run_unittests() { 51 run_unittests() {
36 local coverage_report_dir="${TMP_DIR}/coverage" 52 local coverage_report_dir="${TMP_DIR}/coverage"
37 python ${INFRA_DIR}/test.py test --html-report ${coverage_report_dir} \ 53 python ${INFRA_DIR}/test.py test --html-report ${coverage_report_dir} \
38 appengine/findit 54 appengine/findit
39 echo "Code coverage report file://${coverage_report_dir}/index.html" 55 echo "Code coverage report file://${coverage_report_dir}/index.html"
40 } 56 }
41 57
42 run_findit_locally() { 58 run_findit_locally() {
43 local options="--storage_path ${TMP_DIR}/findit" 59 local options="--storage_path ${TMP_DIR}/findit"
44 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_MODULES} 60 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_MODULES}
45 } 61 }
46 62
47 deploy_findit() { 63 deploy_findit_for_test() {
48 local app_id="findit-for-waterfall" 64 # Deploy a version for testing, the version name is the same as the user name.
65 local app_id="findit-for-me-dev"
49 if [[ "$1" == "prod" ]]; then 66 if [[ "$1" == "prod" ]]; then
50 app_id="findit-for-me" 67 app_id="findit-for-me"
51 local update_log="$TMP_DIR/update.log" 68 fi
52 echo "Syncing code to tip of tree, logging in $update_log ..." 69 local new_version=${USER}
53 local update="$(cd $INFRA_DIR && git pull >>$update_log 2>>$update_log && gc lient sync >>$update_log 2>>$update_log && echo $?)" 70
54 if [[ "$update" != "0" ]]; then 71 echo "-----------------------------------"
55 echo "Failed to run 'git pull && gclient sync'!" 72 python ${APP_CFG} update -A ${app_id} $FINDIT_MODULES --version ${new_version}
56 echo "Please check log at $update_log" 73 echo "-----------------------------------"
57 return 74 print_command_for_queue_cron_dispatch ${app_id}
58 fi 75 echo "-----------------------------------"
59 echo "Code was synced successfully." 76 echo Findit was deployed to "https://${new_version}-dot-${app_id}.appspot.com/ "
77 }
78
79 deploy_findit_for_prod() {
80 local app_id="findit-for-me"
81
82 # Sync to latest code.
83 local update_log="${TMP_DIR}/update.log"
84 echo "Syncing code to tip of tree, logging in ${update_log} ..."
85 local update="0" #"$(cd ${INFRA_DIR} && git pull >>${update_log} 2>>${update_l og} && gclient sync >>$update_log >>${update_log} 2>>${update_log} && echo $?)"
86 if [[ "${update}" != "0" ]]; then
87 echo "Failed to run 'git pull && gclient sync'!"
88 echo "Please check log at ${update_log}"
89 return
90 fi
91 echo "Code was synced successfully."
92
93 # Check uncommitted local changes.
94 local changed_file_number="$(git status --porcelain | wc -l)"
95 if [[ "${changed_file_number}" != "0" ]]; then
96 echo "You have uncommitted local changes!"
97 echo "Please run 'git status' to check local changes."
98 return
60 fi 99 fi
61 100
101 local new_version="$(git rev-parse --short HEAD)"
102
103 # Check committed local changes.
104 local tot_version="$(git rev-parse --short origin/master)"
105 if [[ "${new_version}" != "${tot_version}" ]]; then
106 echo "You have local commits!"
107 echo "Please run 'git reset ${tot_version}' to reset the local changes."
108 return
109 fi
110
111 # Check current deployed version.
62 local current_version=`curl -s https://${app_id}.appspot.com/version` 112 local current_version=`curl -s https://${app_id}.appspot.com/version`
63 if ! [[ $current_version =~ ^[0-9a-fA-F]+$ ]]; then 113 if ! [[ ${current_version} =~ ^[0-9a-fA-F]+$ ]]; then
64 echo "Failed to retrieve current version of Findit from the live app." 114 echo "Failed to retrieve current version of Findit from the live app."
65 echo "Please input the current version, followed by [ENTER]:" 115 echo "Please input the current version, followed by [ENTER]:"
66 read current_version 116 read current_version
67 fi 117 fi
68 echo "Current deployed version is $current_version"
69 118
70 local new_version="$(git rev-parse --short HEAD)" 119 echo "Current deployed version is ${current_version}"
71 if [[ "$1" == "prod" ]]; then
72 # Check uncommitted local changes.
73 local changed_file_number="$(git status --porcelain | wc -l)"
74 if [[ "$changed_file_number" != "0" ]]; then
75 echo "You have uncommitted local changes!"
76 echo "Please run 'git status' to check local changes."
77 return
78 fi
79
80 # Check committed local changes.
81 local tot_version="$(git rev-parse --short origin/master)"
82 if [[ "$new_version" != "$tot_version" ]]; then
83 echo "You have local commits!"
84 echo "Please run 'git reset $tot_version' to reset the local changes."
85 return
86 fi
87 fi
88
89 local app_cfg="${GOOGLE_APP_ENGINE_DIR}/appcfg.py"
90
91 echo "Current deployed version is '$current_version'."
92 echo "Deploying new version '${new_version}'..." 120 echo "Deploying new version '${new_version}'..."
93 121
94 echo 122 echo
95 echo "-----------------------------------" 123 echo "-----------------------------------"
96 python ${app_cfg} update -A ${app_id} $FINDIT_MODULES --version ${new_version} 124 python ${APP_CFG} update -A ${app_id} $FINDIT_MODULES --version ${new_version}
125 echo "-----------------------------------"
126 print_command_for_queue_cron_dispatch ${app_id}
97 echo "-----------------------------------" 127 echo "-----------------------------------"
98 echo 128 echo
99 129
100 echo "New version '${new_version}' of Findit was deployed to ${app_id}." 130 echo "New version '${new_version}' of Findit was deployed to ${app_id}."
101 if ! [[ "$1" == "prod" ]]; then
102 return
103 fi
104 131
105 local dashboard_url="https://${new_version}-dot-${app_id}.appspot.com/list-ana lyses" 132 local dashboard_url="https://${new_version}-dot-${app_id}.appspot.com/list-ana lyses"
106 echo "Please force a re-run of a recent build failure on dashboard ${dashboard _url}," 133 echo "Please force a re-run of a recent build failure on dashboard ${dashboard _url},"
107 echo "ensure that the analysis is run in the new-version frontend & backend an d gives correct results," 134 echo "ensure that the analysis is run in the new-version frontend & backend an d gives correct results,"
108 echo "and then set the new version ${new_version} as default for both frontend and backend." 135 echo "and then set the new version ${new_version} as default for both frontend and backend."
109 echo 136 echo
110 137
111 local change_log_url="https://chromium.googlesource.com/infra/infra/+log/${cur rent_version}..${new_version}/appengine/findit" 138 local change_log_url="https://chromium.googlesource.com/infra/infra/+log/${cur rent_version}..${new_version}/appengine/findit"
112 echo "If the release is for findit-for-me, please email chrome-findit with the following:" 139 echo "If the release is for findit-for-me, please email chrome-findit with the following:"
113 echo "Subject: 'Release: findit-for-me was update to ${new_version}.'" 140 echo "Subject: 'Release: findit-for-me was update to ${new_version}.'"
114 echo "Hi all," 141 echo "Hi all,"
115 echo 142 echo
116 echo "The app findit-for-me was updated from ${current_version} to ${new_versi on}." 143 echo "The app findit-for-me was updated from ${current_version} to ${new_versi on}."
117 echo "Changelogs: ${change_log_url}" 144 echo "Changelogs: ${change_log_url}"
118 echo 145 echo
119 echo "If your bug fixes/features are included in the release, please verify on ${app_id} and mark them as verified on http://crbug.com" 146 echo "If your bug fixes/features are included in the release, please verify on ${app_id} and mark them as verified on http://crbug.com"
120 echo 147 echo
121 echo "Thanks," 148 echo "Thanks,"
122 echo "Released by ${USER}@" 149 echo "Released by ${USER}@"
123 } 150 }
124 151
125 case "$1" in 152 case "$1" in
126 test) 153 test)
127 run_unittests 154 run_unittests
128 ;; 155 ;;
129 run) 156 run)
130 run_findit_locally 157 run_findit_locally
131 ;; 158 ;;
132 deploy-test) 159 deploy-prod)
133 deploy_findit "test" 160 deploy_findit_for_prod
134 ;; 161 ;;
135 deploy-prod) 162 deploy-test-dev)
136 deploy_findit "prod" 163 deploy_findit_for_test "dev"
164 ;;
165 deploy-test-prod)
166 deploy_findit_for_test "prod"
137 ;; 167 ;;
138 *) 168 *)
139 print_usage 169 print_usage
140 ;; 170 ;;
141 esac 171 esac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698