diff --git a/.travis.yml b/.travis.yml index 27eefec75..f5ace4d73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,24 @@ install: - chmod -R 777 $TRAVIS_BUILD_DIR script: - - docker run -v$TRAVIS_BUILD_DIR:/phd chriscummins/phd_build:latest -c "./tools/flaky_bazel.sh run --config=travis //tools:whoami" + - > + docker run \ + -u root \ + -v$TRAVIS_BUILD_DIR:/phd \ + -v/var/run/docker.sock:/var/run/docker.sock \ + -v$HOME/.cache/bazel/_bazel_docker:/home/docker/.cache/bazel/_bazel_docker \ + chriscummins/phd_build:latest \ + -c "./tools/flaky_bazel.sh run --config=travis //tools:whoami" + - > + docker run \ + -u root \ + -v$TRAVIS_BUILD_DIR:/phd \ + -v/var/run/docker.sock:/var/run/docker.sock \ + -v$HOME/.cache/bazel/_bazel_docker:/home/docker/.cache/bazel/_bazel_docker \ + --env COMMIT_RANGE=$TRAVIS_COMMIT_RANGE \ + --env TEST_ARGS=--config=travis \ + chriscummins/phd_build:latest \ + -c "./third_party/bazel/ci.sh" notifications: email: diff --git a/BUILD b/BUILD index da361151c..3d54cb173 100644 --- a/BUILD +++ b/BUILD @@ -5,7 +5,10 @@ load("@bazel_gazelle//:def.bzl", "gazelle") load("@build_stack_rules_proto//python:python_grpc_library.bzl", "python_grpc_library") exports_files([ + ".travis.yml", "README.md", + "INSTALL.md", + "CONTRIBUTING.md", "WORKSPACE", "version.txt", "deployment.properties", diff --git a/WORKSPACE b/WORKSPACE index 1a3c1dcdd..536909be8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -709,7 +709,7 @@ container_pull( # Defined in //tools/docker/phd_build:Dockerfile container_pull( name = "phd_build", - digest = "sha256:47fa263c92568900f831c0cab664a97baabfafa9a3e31cff7fe058140a5ce629", + digest = "sha256:d4f29cd4f28b3276ecea0c672d2d53bfffbbdbbad5088853378bb06ae3d8d09d", registry = "index.docker.io", repository = "chriscummins/phd_build", ) diff --git a/third_party/bazel/ci.sh b/third_party/bazel/ci.sh index 5c38a75dd..6e41eda81 100755 --- a/third_party/bazel/ci.sh +++ b/third_party/bazel/ci.sh @@ -40,17 +40,20 @@ # value for COMMIT_RANGE. # When running in Travis-CI, you can directly use the $TRAVIS_COMMIT_RANGE # environment variable. - COMMIT_RANGE=${COMMIT_RANGE:-$(git merge-base origin/master HEAD)".."} # Go to the root of the repo cd "$(git rev-parse --show-toplevel)" +returncode=0 + # Get a list of the current files in package form by querying Bazel. files=() for file in $(git diff --name-only ${COMMIT_RANGE}); do - files+=($(bazel query $file)) - echo $(bazel query $file) + query_files=$(bazel query --keep_going --noshow_progress $file) + returncode=$((returncode + $?)) + echo "$query_files" + files+=($query_files) done # Query for the associated buildables @@ -62,6 +65,7 @@ buildables=$(bazel query \ if [[ ! -z $buildables ]]; then echo "Building binaries" bazel build $buildables + returncode=$((returncode + $?)) fi tests=$(bazel query \ @@ -71,5 +75,11 @@ tests=$(bazel query \ # Run the tests if there were results if [[ ! -z $tests ]]; then echo "Running tests" - bazel test $tests + bazel test $TEST_ARGS $tests + returncode=$((returncode + $?)) +fi + +if [[ $returncode != 0 ]]; then + echo "There were errors" >&2 + exit 1 fi diff --git a/tools/docker/phd_build/Dockerfile b/tools/docker/phd_build/Dockerfile index c759f7fdc..a2982af3c 100644 --- a/tools/docker/phd_build/Dockerfile +++ b/tools/docker/phd_build/Dockerfile @@ -15,18 +15,19 @@ ENV DEBIAN_FRONTEND noninteractive # Install packages. RUN apt-get update && apt-get install -y --no-install-recommends \ # Packages required to build code. - unzip \ + apt-transport-https \ + ca-certificates gnupg-agent \ g++ \ - zlib1g-dev \ + m4 \ ocl-icd-opencl-dev \ + patch \ python \ - apt-transport-https \ - ca-certificates gnupg-agent \ + python-dev \ software-properties-common \ texlive-full \ - patch \ + unzip \ zip \ - m4 \ + zlib1g-dev \ # Packages required to build matplotlib. pkg-config \ libfreetype6-dev \ @@ -67,7 +68,7 @@ RUN apt update \ && rm -rf /var/lib/apt/lists/* # Install bazel. -ENV BAZEL_VERSION 2.0.0 +ENV BAZEL_VERSION 3.1.0 RUN curl -L -o /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ bash /tmp/bazel.sh && rm /tmp/bazel.sh diff --git a/tools/flaky_bazel.sh b/tools/flaky_bazel.sh index 3e33c7bc5..5c89c7e1f 100755 --- a/tools/flaky_bazel.sh +++ b/tools/flaky_bazel.sh @@ -10,8 +10,8 @@ set -eu export max_attempts=5 export returncode=1 -for _ in $(seq $max_attempts); do bazel $@ && { +for i in $(seq $max_attempts); do bazel $@ && { returncode=0 break -} || echo "> returncode: $?"; done +} || echo "> flaky bazel attempt $i of $max_attempts, returncode: $?"; done exit $returncode diff --git a/version.txt b/version.txt index 8db04fa91..97efeb94d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -20.04.25 +20.04.26