summaryrefslogtreecommitdiff
path: root/scripts/utils.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/utils.sh')
-rw-r--r--scripts/utils.sh35
1 files changed, 30 insertions, 5 deletions
diff --git a/scripts/utils.sh b/scripts/utils.sh
index d1f98bb3f62..897f8d5a8b8 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -18,11 +18,8 @@ function setup_db_user_only() {
}
function setup_db() {
- setup_db_user_only
-
- bundle exec rake db:drop db:create db:structure:load db:migrate
-
- bundle exec rake gitlab:db:setup_ee
+ run_timed_command "setup_db_user_only"
+ run_timed_command "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee"
}
function install_api_client_dependencies_with_apk() {
@@ -38,6 +35,24 @@ function install_gitlab_gem() {
gem install gitlab --no-document --version 4.13.0
}
+function run_timed_command() {
+ local cmd="${1}"
+ local start=$(date +%s)
+ echosuccess "\$ ${cmd}"
+ eval "${cmd}"
+ local ret=$?
+ local end=$(date +%s)
+ local runtime=$((end-start))
+
+ if [[ $ret -eq 0 ]]; then
+ echosuccess "==> '${cmd}' succeeded in ${runtime} seconds."
+ return 0
+ else
+ echoerr "==> '${cmd}' failed (${ret}) in ${runtime} seconds."
+ return $ret
+ fi
+}
+
function echoerr() {
local header="${2}"
@@ -58,6 +73,16 @@ function echoinfo() {
fi
}
+function echosuccess() {
+ local header="${2}"
+
+ if [ -n "${header}" ]; then
+ printf "\n\033[0;32m** %s **\n\033[0m" "${1}" >&2;
+ else
+ printf "\033[0;32m%s\n\033[0m" "${1}" >&2;
+ fi
+}
+
function get_job_id() {
local job_name="${1}"
local query_string="${2:+&${2}}"