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

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: Fix nit. 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 "Cannot identify who is deploying Findit. Please set USER."
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 cron.yaml, dispatch.yaml, index.yaml, or"
45 echo " queue.yaml since last deployment, please run appropriate commands"
46 echo " below to update them:"
47 echo " ${APP_CFG} update_cron -A $1 ${FINDIT_DIR}"
48 echo " ${APP_CFG} update_dispatch -A $1 ${FINDIT_DIR}"
49 echo " ${APP_CFG} update_indexes -A $1 ${FINDIT_DIR}"
50 echo " ${APP_CFG} update_queues -A $1 ${FINDIT_DIR}"
51 }
52
35 run_unittests() { 53 run_unittests() {
36 local coverage_report_dir="${TMP_DIR}/coverage" 54 local coverage_report_dir="${TMP_DIR}/coverage"
37 python ${INFRA_DIR}/test.py test --html-report ${coverage_report_dir} \ 55 python ${INFRA_DIR}/test.py test --html-report ${coverage_report_dir} \
38 appengine/findit 56 appengine/findit
39 echo "Code coverage report file://${coverage_report_dir}/index.html" 57 echo "Code coverage report file://${coverage_report_dir}/index.html"
40 } 58 }
41 59
42 run_findit_locally() { 60 run_findit_locally() {
43 local options="--storage_path ${TMP_DIR}/findit" 61 local options="--storage_path ${TMP_DIR}/findit"
44 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_MODULES} 62 python ${GOOGLE_APP_ENGINE_DIR}/dev_appserver.py ${options} ${FINDIT_MODULES}
45 } 63 }
46 64
47 deploy_findit() { 65 deploy_findit_for_test() {
48 local app_id="findit-for-waterfall" 66 # Deploy a version for testing, the version name is the same as the user name.
67 local app_id="findit-for-me-dev"
49 if [[ "$1" == "prod" ]]; then 68 if [[ "$1" == "prod" ]]; then
50 app_id="findit-for-me" 69 app_id="findit-for-me"
51 local update_log="$TMP_DIR/update.log" 70 fi
52 echo "Syncing code to tip of tree, logging in $update_log ..." 71 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 $?)" 72
54 if [[ "$update" != "0" ]]; then 73 echo "-----------------------------------"
55 echo "Failed to run 'git pull && gclient sync'!" 74 python ${APP_CFG} update -A ${app_id} $FINDIT_MODULES --version ${new_version}
56 echo "Please check log at $update_log" 75 echo "-----------------------------------"
57 return 76 print_command_for_queue_cron_dispatch ${app_id}
58 fi 77 echo "-----------------------------------"
59 echo "Code was synced successfully." 78 echo Findit was deployed to "https://${new_version}-dot-${app_id}.appspot.com/ "
79 }
80
81 deploy_findit_for_prod() {
82 local app_id="findit-for-me"
83
84 # Sync to latest code.
85 local update_log="${TMP_DIR}/update.log"
86 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 $?)"
88 if [[ "${update}" != "0" ]]; then
89 echo "Failed to run 'git pull && gclient sync'!"
90 echo "Please check log at ${update_log}"
91 return
92 fi
93 echo "Code was synced successfully."
94
95 # Check uncommitted local changes.
96 local changed_file_number="$(git status --porcelain | wc -l)"
97 if [[ "${changed_file_number}" != "0" ]]; then
98 echo "You have uncommitted local changes!"
99 echo "Please run 'git status' to check local changes."
100 return
60 fi 101 fi
61 102
103 local new_version="$(git rev-parse --short HEAD)"
104
105 # Check committed local changes.
106 local tot_version="$(git rev-parse --short origin/master)"
107 if [[ "${new_version}" != "${tot_version}" ]]; then
108 echo "You have local commits!"
109 echo "Please run 'git reset ${tot_version}' to reset the local changes."
110 return
111 fi
112
113 # Check current deployed version.
62 local current_version=`curl -s https://${app_id}.appspot.com/version` 114 local current_version=`curl -s https://${app_id}.appspot.com/version`
63 if ! [[ $current_version =~ ^[0-9a-fA-F]+$ ]]; then 115 if ! [[ ${current_version} =~ ^[0-9a-fA-F]+$ ]]; then
64 echo "Failed to retrieve current version of Findit from the live app." 116 echo "Failed to retrieve current version of Findit from the live app."
65 echo "Please input the current version, followed by [ENTER]:" 117 echo "Please input the current version, followed by [ENTER]:"
66 read current_version 118 read current_version
67 fi 119 fi
68 echo "Current deployed version is $current_version"
69 120
70 local new_version="$(git rev-parse --short HEAD)" 121 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}'..." 122 echo "Deploying new version '${new_version}'..."
93 123
94 echo 124 echo
95 echo "-----------------------------------" 125 echo "-----------------------------------"
96 python ${app_cfg} update -A ${app_id} $FINDIT_MODULES --version ${new_version} 126 python ${APP_CFG} update -A ${app_id} $FINDIT_MODULES --version ${new_version}
127 echo "-----------------------------------"
128 print_command_for_queue_cron_dispatch ${app_id}
97 echo "-----------------------------------" 129 echo "-----------------------------------"
98 echo 130 echo
99 131
100 echo "New version '${new_version}' of Findit was deployed to ${app_id}." 132 echo "New version '${new_version}' of Findit was deployed to ${app_id}."
101 if ! [[ "$1" == "prod" ]]; then
102 return
103 fi
104 133
105 local dashboard_url="https://${new_version}-dot-${app_id}.appspot.com/list-ana lyses" 134 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}," 135 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," 136 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." 137 echo "and then set the new version ${new_version} as default for both frontend and backend."
109 echo 138 echo
110 139
111 local change_log_url="https://chromium.googlesource.com/infra/infra/+log/${cur rent_version}..${new_version}/appengine/findit" 140 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:" 141 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}.'" 142 echo "Subject: 'Release: findit-for-me was update to ${new_version}.'"
114 echo "Hi all," 143 echo "Hi all,"
115 echo 144 echo
116 echo "The app findit-for-me was updated from ${current_version} to ${new_versi on}." 145 echo "The app findit-for-me was updated from ${current_version} to ${new_versi on}."
117 echo "Changelogs: ${change_log_url}" 146 echo "Changelogs: ${change_log_url}"
118 echo 147 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" 148 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 149 echo
121 echo "Thanks," 150 echo "Thanks,"
122 echo "Released by ${USER}@" 151 echo "Released by ${USER}@"
123 } 152 }
124 153
125 case "$1" in 154 case "$1" in
126 test) 155 test)
127 run_unittests 156 run_unittests
128 ;; 157 ;;
129 run) 158 run)
130 run_findit_locally 159 run_findit_locally
131 ;; 160 ;;
132 deploy-test) 161 deploy-prod)
133 deploy_findit "test" 162 deploy_findit_for_prod
134 ;; 163 ;;
135 deploy-prod) 164 deploy-test-dev)
136 deploy_findit "prod" 165 deploy_findit_for_test "dev"
166 ;;
167 deploy-test-prod)
168 deploy_findit_for_test "prod"
137 ;; 169 ;;
138 *) 170 *)
139 print_usage 171 print_usage
140 ;; 172 ;;
141 esac 173 esac
OLDNEW
« no previous file with comments | « appengine/findit/util_scripts/remote_queries/swarming_task_data_query.py ('k') | appengine/findit/waterfall-backend.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698