From 9e313445bb75bae71b5d003f7264ee55ae296023 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 5 May 2020 17:54:47 +0100 Subject: [PATCH] Kokoro Ubuntu: Switch to docker image presubmit.sh now runs presubmit-docker.sh using the new radial docker image which contains various toolchains. The `/bin/using.sh` bash script exports the `using` bash function which can be called to configure toolchains at specific versions. --- kokoro/ubuntu/presubmit-docker.sh | 39 +++++++++++++++++++++++++++++ kokoro/ubuntu/presubmit.sh | 41 +++++++++---------------------- 2 files changed, 50 insertions(+), 30 deletions(-) create mode 100755 kokoro/ubuntu/presubmit-docker.sh diff --git a/kokoro/ubuntu/presubmit-docker.sh b/kokoro/ubuntu/presubmit-docker.sh new file mode 100755 index 0000000..82c64f0 --- /dev/null +++ b/kokoro/ubuntu/presubmit-docker.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e # Fail on any error. + +. /bin/using.sh # Declare the bash `using` function for configuring toolchains. + +set -x # Display commands being run. + +cd github/cppdap + +git submodule update --init + +if [ "$BUILD_SYSTEM" == "cmake" ]; then + using cmake-3.17.2 + using gcc-9 + + mkdir build + cd build + + build_and_run() { + cmake .. -DCPPDAP_BUILD_EXAMPLES=1 -DCPPDAP_BUILD_TESTS=1 -DCPPDAP_WARNINGS_AS_ERRORS=1 $1 + make --jobs=$(nproc) + + ./cppdap-unittests + } + + if [ "$BUILD_SANITIZER" == "asan" ]; then + build_and_run "-DCPPDAP_ASAN=1" + elif [ "$BUILD_SANITIZER" == "msan" ]; then + build_and_run "-DCPPDAP_MSAN=1" + elif [ "$BUILD_SANITIZER" == "tsan" ]; then + build_and_run "-DCPPDAP_TSAN=1" + else + build_and_run + fi +else + echo "Unknown build system: $BUILD_SYSTEM" + exit 1 +fi \ No newline at end of file diff --git a/kokoro/ubuntu/presubmit.sh b/kokoro/ubuntu/presubmit.sh index 402b814..b69d40d 100755 --- a/kokoro/ubuntu/presubmit.sh +++ b/kokoro/ubuntu/presubmit.sh @@ -1,35 +1,16 @@ #!/bin/bash set -e # Fail on any error. -set -x # Display commands being run. -BUILD_ROOT=$PWD +ROOT_DIR=`pwd` +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )" -cd github/cppdap - -git submodule update --init - -if [ "$BUILD_SYSTEM" == "cmake" ]; then - mkdir build - cd build - - build_and_run() { - cmake .. -DCPPDAP_BUILD_EXAMPLES=1 -DCPPDAP_BUILD_TESTS=1 -DCPPDAP_WARNINGS_AS_ERRORS=1 $1 - make --jobs=$(nproc) - - ./cppdap-unittests - } - - if [ "$BUILD_SANITIZER" == "asan" ]; then - build_and_run "-DCPPDAP_ASAN=1" - elif [ "$BUILD_SANITIZER" == "msan" ]; then - build_and_run "-DCPPDAP_MSAN=1" - elif [ "$BUILD_SANITIZER" == "tsan" ]; then - build_and_run "-DCPPDAP_TSAN=1" - else - build_and_run - fi -else - echo "Unknown build system: $BUILD_SYSTEM" - exit 1 -fi \ No newline at end of file +docker run --rm -i \ + --volume "${ROOT_DIR}:${ROOT_DIR}" \ + --volume "${KOKORO_ARTIFACTS_DIR}:/mnt/artifacts" \ + --workdir "${ROOT_DIR}" \ + --env BUILD_SYSTEM=$BUILD_SYSTEM \ + --env BUILD_TARGET_ARCH=$BUILD_TARGET_ARCH \ + --env BUILD_SANITIZER=$BUILD_SANITIZER \ + --entrypoint "${SCRIPT_DIR}/presubmit-docker.sh" \ + "gcr.io/shaderc-build/radial-build:latest"