summaryrefslogtreecommitdiffhomepage
path: root/scripts/build.sh
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2019-09-03 22:01:34 -0700
committergVisor bot <gvisor-bot@google.com>2019-09-03 22:02:43 -0700
commit67a2ab1438cdccbe045143bbfaa807cf83110ebc (patch)
tree8c17f5ecd3e5b3e9c4decb46d8f2b2e893809dc1 /scripts/build.sh
parent144127e5e1c548150f49501a7decb82ec2e239f2 (diff)
Impose order on test scripts.
The simple test script has gotten out of control. Shard this script into different pieces and attempt to impose order on overall test structure. This change helps lay some of the foundations for future improvements. * The runsc/test directories are moved into just test/. * The runsc/test/testutil package is split into logical pieces. * The scripts/ directory contains new top-level targets. * Each test is now responsible for building targets it requires. * The install functionality is moved into `runsc` itself for simplicity. * The existing kokoro run_tests.sh file now just calls all (can be split). After this change is merged, I will create multiple distinct workflows for Kokoro, one for each of the scripts currently targeted by `run_tests.sh` today, which should dramatically reduce the time-to-run for the Kokoro tests, and provides a better foundation for further improvements to the infrastructure. PiperOrigin-RevId: 267081397
Diffstat (limited to 'scripts/build.sh')
-rwxr-xr-xscripts/build.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 000000000..dae3460af
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Copyright 2018 The gVisor Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+source $(dirname $0)/common.sh
+
+# Build runsc.
+runsc=$(build -c opt //runsc)
+
+# Build packages.
+pkg=$(build -c opt --host_force_python=py2 //runsc:debian)
+
+# Build a repository, if the key is available.
+if [[ -v KOKORO_REPO_KEY ]]; then
+ repo=$(tools/make_repository.sh "${KOKORO_REPO_KEY}" gvisor-bot@google.com)
+fi
+
+# Install installs artifacts.
+install() {
+ mkdir -p $1
+ cp "${runsc}" "$1"/runsc
+ sha512sum "$1"/runsc | awk '{print $1 " runsc"}' > "$1"/runsc.sha512
+ if [[ -v repo ]]; then
+ cp -a "${repo}" "${latest_dir}"/repo
+ fi
+}
+
+# Move the runsc binary into "latest" directory, and also a directory with the
+# current date. If the current commit happens to correpond to a tag, then we
+# will also move everything into a directory named after the given tag.
+if [[ -v KOKORO_ARTIFACTS_DIR ]]; then
+ if [[ "${KOKORO_BUILD_NIGHTLY}" == "true" ]]; then
+ # The "latest" directory and current date.
+ install "${KOKORO_ARTIFACTS_DIR}/nightly/latest"
+ install "${KOKORO_ARTIFACTS_DIR}/nightly/$(date -Idate)"
+ else
+ # Is it a tagged release? Build that instead. In that case, we also try to
+ # update the base release directory, in case this is an update. Finally, we
+ # update the "release" directory, which has the last released version.
+ tag="$(git describe --exact-match --tags HEAD)"
+ if ! [[ -z "${tag}" ]]; then
+ install "${KOKORO_ARTIFACTS_DIR}/${tag}"
+ base=$(echo "${tag}" | cut -d'.' -f1)
+ if [[ "${base}" != "${tag}" ]]; then
+ install "${KOKORO_ARTIFACTS_DIR}/${base}"
+ fi
+ install "${KOKORO_ARTIFACTS_DIR}/release"
+ fi
+ fi
+fi