aboutsummaryrefslogtreecommitdiffstats
path: root/screwdriver/detect-what-to-build.sh
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@verizonmedia.com>2021-05-18 21:23:50 +0200
committerArnstein Ressem <aressem@verizonmedia.com>2021-05-18 21:23:50 +0200
commit3d12e94939ae6995088431841009b1b7cf547841 (patch)
treebf5cb137311178a4706bbcfa98f9d3b709f18262 /screwdriver/detect-what-to-build.sh
parent72e477e68f44ba210406b6dad8a80efcc4eab17d (diff)
Remove Travis remains.
Diffstat (limited to 'screwdriver/detect-what-to-build.sh')
-rwxr-xr-xscrewdriver/detect-what-to-build.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/screwdriver/detect-what-to-build.sh b/screwdriver/detect-what-to-build.sh
new file mode 100755
index 00000000000..1c4809f7295
--- /dev/null
+++ b/screwdriver/detect-what-to-build.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+if (( ${#BASH_SOURCE[@]} == 1 )); then
+ echo "This script must be sourced."
+ exit 1
+fi
+
+if [[ -z $SD_PULL_REQUEST == false ]]; then
+ export SHOULD_BUILD=all
+ return 0
+fi
+
+JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST)
+PR_TITLE=$(jq -re '.title' <<< "$JSON")
+
+JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST/commits)
+COMMITS=$(jq -re '.[].sha' <<< "$JSON")
+
+FILES=$(for C in $COMMITS; do JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/commits/$C); jq -re '.files[].filename' <<< "$JSON"; done)
+
+if [[ $PR_TITLE =~ \[run-systemtest\] ]]; then
+ SHOULD_BUILD=systemtest
+elif [[ -z $FILES ]]; then
+ SHOULD_BUILD=all
+elif ! grep -v -E "(\.h|\.hh|\.hxx|\.c|\.cpp|\.cxx)$" <<< "$FILES" &> /dev/null; then
+ SHOULD_BUILD=cpp
+elif ! grep -v -E "(\.java)$" <<< "$FILES" &> /dev/null; then
+ SHOULD_BUILD=java
+else
+ SHOULD_BUILD=all
+fi
+
+export SHOULD_BUILD
+