зеркало из https://github.com/golang/pkgsite.git
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>
This commit is contained in:
Родитель
a59b4ce778
Коммит
ea15bff89b
2
all.bash
2
all.bash
|
@ -138,7 +138,6 @@ standard_linters() {
|
||||||
check_misspell
|
check_misspell
|
||||||
check_unparam
|
check_unparam
|
||||||
check_script_hashes
|
check_script_hashes
|
||||||
run_prettier
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -168,6 +167,7 @@ main() {
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
standard_linters
|
standard_linters
|
||||||
|
run_prettier
|
||||||
runcmd go mod tidy
|
runcmd go mod tidy
|
||||||
runcmd env GO_DISCOVERY_TESTDB=true go test ./...
|
runcmd env GO_DISCOVERY_TESTDB=true go test ./...
|
||||||
# To test internal/secrets, set GO_DISCOVERY_SECRETS_BUCKET and GO_DISCOVERY_KMS_KEY_NAME
|
# To test internal/secrets, set GO_DISCOVERY_SECRETS_BUCKET and GO_DISCOVERY_KMS_KEY_NAME
|
||||||
|
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче