aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-06-16 16:18:56 -0400
committerJulie Qiu <julie@golang.org>2021-06-18 15:15:44 +0000
commit977edda75c10ae2a8c2189cdfa2bca2e3eca79ea (patch)
tree3d58a6815dc5147306038959c5dfa4ed0679eaa9 /devtools
parentdd82e76f4a6d333649dd9cac070e86b93438c780 (diff)
downloadgo-x-pkgsite-977edda75c10ae2a8c2189cdfa2bca2e3eca79ea.tar.xz
devtools: add all.bash to docker-compose
all.bash can now be run using docker-compose. Change-Id: I2b365fd7911bb61f52f1fc7c9c9d594fb4c6c731 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/328749 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'devtools')
-rw-r--r--devtools/docker/docker-compose.yaml28
-rw-r--r--devtools/lib.sh37
2 files changed, 50 insertions, 15 deletions
diff --git a/devtools/docker/docker-compose.yaml b/devtools/docker/docker-compose.yaml
index 269496fb..4de57e4e 100644
--- a/devtools/docker/docker-compose.yaml
+++ b/devtools/docker/docker-compose.yaml
@@ -3,6 +3,33 @@
# license that can be found in the LICENSE file.
version: '3'
services:
+ allbash:
+ # Allocate a pseudo-tty, which sets the TERM
+ # environment variable to xterm.
+ # See
+ # https://docs.docker.com/engine/reference/run/#env-environment-variables and
+ # https://www.gnu.org/software/gettext/manual/html_node/The-TERM-variable.html.
+ # This is necessary because devtools/lib.sh uses tput.
+ tty:
+ true
+ # allbash depends only on db, since the Go tests will set up its own
+ # test databases.
+ depends_on:
+ - db
+ # This should match the version we are using on AppEngine.
+ image: golang:1.15.5
+ environment:
+ - GO_DISCOVERY_TESTDB=true
+ - GO_DISCOVERY_DATABASE_TEST_PORT=5432
+ - GO_DISCOVERY_DATABASE_TEST_HOST=db
+ - GO_DISCOVERY_DATABASE_TEST_USER=postgres
+ - GO_DISCOVERY_DATABASE_TEST_PASSWORD=postgres
+ # TERM is set to xterm-256color for use by devtools/lib.sh.
+ - TERM=xterm-256color
+ entrypoint: "./third_party/wait-for-it/wait-for-it.sh db:5432 -- ./all.bash"
+ volumes:
+ - ../../:/pkgsite
+ working_dir: /pkgsite
e2e:
image: node:14.17.0
depends_on:
@@ -27,6 +54,7 @@ services:
environment:
- CONNECTION_TIMEOUT=120000
frontend:
+ # This should match the version we are using on AppEngine.
image: golang:1.15.5
depends_on:
- migrate
diff --git a/devtools/lib.sh b/devtools/lib.sh
index 3fee0582..1ed82c91 100644
--- a/devtools/lib.sh
+++ b/devtools/lib.sh
@@ -4,17 +4,19 @@
# Library of useful bash functions and variables.
-if [ -t 1 ] && which tput >/dev/null 2>&1; then
- RED="$(tput setaf 1)"
- GREEN="$(tput setaf 2)"
- YELLOW="$(tput setaf 3)"
- NORMAL="$(tput sgr0)"
-else
- RED=""
- GREEN=""
- YELLOW=""
- NORMAL=""
-fi
+RED=; GREEN=; YELLOW=; BLUE=; BOLD=; RESET=;
+
+case $TERM in
+ '' | xterm) ;;
+ # If xterm is not xterm-16color, xterm-88color, or xterm-256color, tput will
+ # return the error:
+ # tput: No value for $TERM and no -T specified
+ *)
+ RED=`tput setaf 1`
+ GREEN=`tput setaf 2`
+ YELLOW=`tput setaf 3`
+ NORMAL=`tput sgr0`
+esac
EXIT_CODE=0
@@ -34,10 +36,15 @@ runcmd() {
msg="$@"
# Truncate command logging for narrow terminals.
# Account for the 2 characters of '$ '.
- maxwidth=$(( $(tput cols) - 2 ))
- if [[ ${#msg} -gt $maxwidth ]]; then
- msg="${msg::$(( maxwidth - 3 ))}..."
- fi
+ case ${TERM} in
+ '' | xterm) ;;
+ *)
+ maxwidth=$(( $(tput cols) - 2 ))
+ if [[ ${#msg} -gt $maxwidth ]]; then
+ msg="${msg::$(( maxwidth - 3 ))}..."
+ fi
+ esac
+
info "\$ $msg"
$@ || err "command failed"
}