aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2021-06-04 12:22:04 -0400
committerJulie Qiu <julie@golang.org>2021-06-04 20:29:50 +0000
commit0d2439f018f87a07bfea9bf06459bae9137ace8b (patch)
tree8d5f4629cda3f290a50c60664a9911eeb09124fa /devtools
parent7bf1c2047116bd6a3b230cf24c94badb903b3cfb (diff)
downloadgo-x-pkgsite-0d2439f018f87a07bfea9bf06459bae9137ace8b.tar.xz
devtools/ci: add files for CI
Files used for kokoro are copied to devtools/ci along with a README.md, so that it is clear what these files are used for. The existing files will be deleted in the next CL, after an internal CL is merged to change references. Change-Id: I893ac9461d3f775460ba749da80e2b4ba71dcc1e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325129 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'devtools')
-rw-r--r--devtools/ci/README.md8
-rwxr-xr-xdevtools/ci/ci.sh47
-rwxr-xr-xdevtools/ci/e2e.sh16
-rwxr-xr-xdevtools/ci/nodejs.h20
4 files changed, 91 insertions, 0 deletions
diff --git a/devtools/ci/README.md b/devtools/ci/README.md
new file mode 100644
index 00000000..e156b364
--- /dev/null
+++ b/devtools/ci/README.md
@@ -0,0 +1,8 @@
+# CI
+
+The Go pkgsite project uses a continuous integration service called “Kokoro”
+for running tests.
+
+This directory contains files used for kokoro test job configurations.
+(Additional job definitions live in an internal repository). The shell scripts
+that act as entry points to execute the actual tests.
diff --git a/devtools/ci/ci.sh b/devtools/ci/ci.sh
new file mode 100755
index 00000000..96747d28
--- /dev/null
+++ b/devtools/ci/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 -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.15 ./all.bash ci
diff --git a/devtools/ci/e2e.sh b/devtools/ci/e2e.sh
new file mode 100755
index 00000000..4f1c62b8
--- /dev/null
+++ b/devtools/ci/e2e.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+# Copyright 2021 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:
+
+This is a placeholder file for running e2e tests in CI.
+EOUSAGE
+}
+
+usage
diff --git a/devtools/ci/nodejs.h b/devtools/ci/nodejs.h
new file mode 100755
index 00000000..a0c2b9ae
--- /dev/null
+++ b/devtools/ci/nodejs.h
@@ -0,0 +1,20 @@
+#!/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
+
+# Script for running a nodejs docker image.
+# It passes env variables for e2e tests,
+# mounts the pwd into a volume in the container at /pkgsite,
+# and sets the working directory in the container to /pkgsite.
+
+docker run --net=host --rm \
+ -e GO_DISCOVERY_E2E_BASE_URL \
+ -e GO_DISCOVERY_E2E_AUTHORIZATION \
+ -e GO_DISCOVERY_E2E_QUOTA_BYPASS \
+ -v `pwd`:/pkgsite \
+ -w /pkgsite \
+ node:15.14.0 $@