summaryrefslogtreecommitdiffstats
path: root/travis
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2020-12-17 22:47:16 +0100
committerArnstein Ressem <aressem@verizonmedia.com>2020-12-17 22:47:16 +0100
commit0f145a8c9fce39fa862b0eb2b568ba2a1fa84216 (patch)
treed8afc5e092fd47cdd61ac2ad04f15b5eaff86ca6 /travis
parentf6fcb839f35d175b4599b0cedcd7e6a53b46f22c (diff)
Add some smartness to what to build in PR's.
Diffstat (limited to 'travis')
-rwxr-xr-xtravis/detect-what-to-build.sh28
-rwxr-xr-xtravis/travis-build-full.sh23
-rwxr-xr-xtravis/travis-build.sh48
-rwxr-xr-xtravis/travis.sh2
4 files changed, 77 insertions, 24 deletions
diff --git a/travis/detect-what-to-build.sh b/travis/detect-what-to-build.sh
new file mode 100755
index 00000000000..3119e01ef61
--- /dev/null
+++ b/travis/detect-what-to-build.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+if [[ $TRAVIS_PULL_REQUEST == false ]]; then
+ export SHOULD_BUILD=all
+ exit 0
+fi
+
+# Future use
+#JSON=$(curl -sLf https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST)
+#PR_TITLE=$(jq -re '.title' <<< "$JSON")
+
+JSON=$(curl -sLf https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/commits)
+COMMITS=$(jq -re '.[].sha' <<< "$JSON")
+
+FILES=$(for C in $COMMITS; do JSON=$(curl -sLf https://api.github.com/repos/$TRAVIS_REPO_SLUG/commits/$C); jq -re '.files[].filename' <<< "$JSON"; done)
+
+if [[ -z $FILES ]]; then
+ SHOULD_BUILD=all
+elif ! grep -v -E "(.h|.hh|.hxx|.c|.cpp|.cxx)$" <<< "$FILES"; then
+ SHOULD_BUILD=cpp
+elif ! grep -v -E "(.java)$" <<< "$FILES"; then
+ SHOULD_BUILD=java
+else
+ SHOULD_BUILD=all
+fi
+
+export SHOULD_BUILD
+
diff --git a/travis/travis-build-full.sh b/travis/travis-build-full.sh
deleted file mode 100755
index 46268a964c2..00000000000
--- a/travis/travis-build-full.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-set -e
-
-export SOURCE_DIR=/source
-export NUM_THREADS=6
-export MALLOC_ARENA_MAX=1
-export MAVEN_OPTS="-Xss1m -Xms128m -Xmx2g"
-source /etc/profile.d/enable-devtoolset-9.sh
-source /etc/profile.d/enable-rh-maven35.sh
-
-ccache --max-size=1600M
-ccache --set-config=compression=true
-ccache -p
-
-cd ${SOURCE_DIR}
-env VESPA_MAVEN_EXTRA_OPTS="--no-snapshot-updates --batch-mode --threads ${NUM_THREADS}" sh ./bootstrap.sh java
-mvn -V install --no-snapshot-updates --batch-mode --threads ${NUM_THREADS}
-cmake3 -DVESPA_UNPRIVILEGED=no .
-make -j ${NUM_THREADS}
-ctest3 --output-on-failure -j ${NUM_THREADS}
-ccache --show-stats
-make install
diff --git a/travis/travis-build.sh b/travis/travis-build.sh
new file mode 100755
index 00000000000..d75ce605fa0
--- /dev/null
+++ b/travis/travis-build.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+set -euo pipefail
+
+export SOURCE_DIR=/source
+export NUM_THREADS=6
+export MALLOC_ARENA_MAX=1
+export MAVEN_OPTS="-Xss1m -Xms128m -Xmx2g"
+source /etc/profile.d/enable-devtoolset-9.sh
+source /etc/profile.d/enable-rh-maven35.sh
+
+ccache --max-size=1600M
+ccache --set-config=compression=true
+ccache -p
+
+if ! source /source/travis/detect-what-to-build.sh; then
+ SHOULD_BUILD=all
+fi
+
+echo "Building $SHOULD_BUILD"
+
+cd ${SOURCE_DIR}
+
+case $SHOULD_BUILD in
+ cpp)
+ env VESPA_MAVEN_EXTRA_OPTS="--no-snapshot-updates --batch-mode --threads ${NUM_THREADS}" sh ./bootstrap.sh full
+ cmake3 -DVESPA_UNPRIVILEGED=no .
+ make -j ${NUM_THREADS}
+ ctest3 --output-on-failure -j ${NUM_THREADS}
+ ccache --show-stats
+ ;;
+ java)
+ env VESPA_MAVEN_EXTRA_OPTS="--no-snapshot-updates --batch-mode --threads ${NUM_THREADS}" sh ./bootstrap.sh java
+ mvn -V install --no-snapshot-updates --batch-mode --threads ${NUM_THREADS}
+ ;;
+ *)
+ env VESPA_MAVEN_EXTRA_OPTS="--no-snapshot-updates --batch-mode --threads ${NUM_THREADS}" sh ./bootstrap.sh java
+ mvn -V install --no-snapshot-updates --batch-mode --threads ${NUM_THREADS}
+ cmake3 -DVESPA_UNPRIVILEGED=no .
+ make -j ${NUM_THREADS}
+ ctest3 --output-on-failure -j ${NUM_THREADS}
+ ccache --show-stats
+ make install
+ ;;
+esac
+
+
diff --git a/travis/travis.sh b/travis/travis.sh
index 315771b43b9..3ed81d1864b 100755
--- a/travis/travis.sh
+++ b/travis/travis.sh
@@ -14,5 +14,5 @@ DOCKER_IMAGE=vespaengine/vespa-build-centos7:latest
bell &
docker run --rm -v ${HOME}/.m2:/root/.m2 -v ${HOME}/.ccache:/root/.ccache -v $(pwd):/source \
- --entrypoint /source/travis/travis-build-full.sh ${DOCKER_IMAGE}
+ --entrypoint /source/travis/travis-build.sh ${DOCKER_IMAGE}
exit $?