From 7436ea247bc946b36a7e5e6ca6019796ef76d85c Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Tue, 4 Jun 2019 11:06:13 -0700 Subject: Fix Kokoro revision and 'go get usage' As a convenience for debugging, also factor the scripts such that can be run without Kokoro. In the future, this may be used to add additional presubmit hooks that run without Kokoro. PiperOrigin-RevId: 251474868 --- tools/run_build.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tools/run_build.sh (limited to 'tools/run_build.sh') diff --git a/tools/run_build.sh b/tools/run_build.sh new file mode 100755 index 000000000..b6b446690 --- /dev/null +++ b/tools/run_build.sh @@ -0,0 +1,44 @@ +#!/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. + +# Fail on any error. +set -e +# Display commands to stderr. +set -x + +# Install the latest version of Bazel and log the version. +(which use_bazel.sh && use_bazel.sh latest) || which bazel +bazel version + +# Switch into the workspace and checkout the appropriate commit. +if [[ -v KOKORO_GIT_COMMIT ]]; then + cd git/repo && git checkout "${KOKORO_GIT_COMMIT}" +fi + +# Build runsc. +bazel build //runsc + +# Move the runsc binary into "latest" directory, and also a directory with the +# current date. +if [[ -v KOKORO_ARTIFACTS_DIR ]]; then + latest_dir="${KOKORO_ARTIFACTS_DIR}"/latest + today_dir="${KOKORO_ARTIFACTS_DIR}"/"$(date -Idate)" + mkdir -p "${latest_dir}" "${today_dir}" + cp bazel-bin/runsc/linux_amd64_pure_stripped/runsc "${latest_dir}" + sha512sum "${latest_dir}"/runsc | awk '{print $1 " runsc"}' > "${latest_dir}"/runsc.sha512 + cp bazel-bin/runsc/linux_amd64_pure_stripped/runsc "${today_dir}" + sha512sum "${today_dir}"/runsc | awk '{print $1 " runsc"}' > "${today_dir}"/runsc.sha512 +fi -- cgit v1.2.3 From 6f92038ce0d2062c3dfd84fe65141ee09deeabfc Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Tue, 4 Jun 2019 14:42:25 -0700 Subject: Use github directory if it exists. Unfortunately, kokoro names the top-level directory per the SCM type. This means there's no way to make the job names match; we simply need to probe for the existence of the correct directory. PiperOrigin-RevId: 251519409 --- tools/run_build.sh | 8 +++++--- tools/run_tests.sh | 9 +++------ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'tools/run_build.sh') diff --git a/tools/run_build.sh b/tools/run_build.sh index b6b446690..d49a1d4be 100755 --- a/tools/run_build.sh +++ b/tools/run_build.sh @@ -23,9 +23,11 @@ set -x (which use_bazel.sh && use_bazel.sh latest) || which bazel bazel version -# Switch into the workspace and checkout the appropriate commit. -if [[ -v KOKORO_GIT_COMMIT ]]; then - cd git/repo && git checkout "${KOKORO_GIT_COMMIT}" +# Switch into the workspace. +if [[ -v KOKORO_GIT_COMMIT ]] && [[ -d git/repo ]]; then + cd git/repo +elif [[ -v KOKORO_GIT_COMMIT ]] && [[ -d github/repo ]]; then + cd github/repo fi # Build runsc. diff --git a/tools/run_tests.sh b/tools/run_tests.sh index c6e97dc95..dc282c142 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -21,8 +21,10 @@ set -eux # GLOBAL ENV VARS # ################### -if [[ -v KOKORO_GIT_COMMIT ]]; then +if [[ -v KOKORO_GIT_COMMIT ]] && [[ -d git/repo ]]; then readonly WORKSPACE_DIR="${PWD}/git/repo" +elif [[ -v KOKORO_GIT_COMMIT ]] && [[ -d github/repo ]]; then + readonly WORKSPACE_DIR="${PWD}/github/repo" else readonly WORKSPACE_DIR="${PWD}" fi @@ -46,11 +48,6 @@ readonly TEST_PACKAGES=("//pkg/..." "//runsc/..." "//tools/...") (which use_bazel.sh && use_bazel.sh latest) || which bazel bazel version -# Checkout the appropriate commit. -if [[ -v KOKORO_GIT_COMMIT ]]; then - (cd "${WORKSPACE_DIR}" && git checkout "${KOKORO_GIT_COMMIT}") -fi - # Load the kvm module. sudo -n -E modprobe kvm -- cgit v1.2.3