diff options
| author | Rob Findley <rfindley@google.com> | 2020-07-08 22:41:24 -0400 |
|---|---|---|
| committer | Robert Findley <rfindley@google.com> | 2020-07-09 12:11:21 +0000 |
| commit | ea15bff89b2fdf2cbe1b992decf20cfbb53388ff (patch) | |
| tree | 5f7dd52475513ad04543ab1fdc6a103c01541a5f /devtools | |
| parent | a59b4ce778c465c6feb8d805ca5aa47c61b8105e (diff) | |
| download | go-x-pkgsite-ea15bff89b2fdf2cbe1b992decf20cfbb53388ff.tar.xz | |
devtools: add a script for running pure docker CI
For simplicity, add a new script that runs all.bash CI using Docker
only. This will facilitate hooking into Kokoro (a Google internal CI
runner).
Change-Id: I2faa6190e6ecc35a2b2dc9151f173dc07f80d9b5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241603
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'devtools')
| -rwxr-xr-x | devtools/docker_ci.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/devtools/docker_ci.sh b/devtools/docker_ci.sh new file mode 100755 index 00000000..a15b2f69 --- /dev/null +++ b/devtools/docker_ci.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Copyright 2020 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +set -e + +usage() { + cat <<EOUSAGE +Usage: $0 [--sudo] + +Run standard CI (tests and linters) using local docker. If --sudo is set, run +docker with sudo. +EOUSAGE +} + +maybe_sudo= +while [[ $# -gt 0 ]]; do + case "$1" in + "-h" | "--help" | "help") + usage + exit 0 + ;; + "--sudo") + maybe_sudo="sudo " + shift + ;; + *) + usage + exit 1 + esac +done + +# Find the repo root. +script_dir=$(dirname "$(readlink -f "$0")") +pkgsite_dir=$(readlink -f "${script_dir}/..") + +# Run postgres. +pg_container=$(${maybe_sudo}docker run --rm -d --name pg_pkgsite_ci -e LANG=C postgres:11.4) +trap "${maybe_sudo} docker stop ${pg_container}" EXIT + +# Run all.bash. To avoid any port conflict, run in the postgres network. +cd "${pkgsite_dir}" +${maybe_sudo}docker run --rm -t \ + --network container:${pg_container} \ + -v $(pwd):"/workspace" -w "/workspace" \ + -e GO_DISCOVERY_TESTDB=true golang:1.14 ./all.bash ci |
