diff --git a/.gitignore b/.gitignore index f57991284dd..8d5b84605c4 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,7 @@ compile_commands.json /extras/hs-test/.last_hst_ppid /extras/hs-test/.goimports.ok /extras/hs-test/summary/ +/extras/hs-test/.last_state_hash # ./configure /CMakeFiles diff --git a/extras/hs-test/script/build_hst.sh b/extras/hs-test/script/build_hst.sh index b7580f5af7e..96a7214d705 100755 --- a/extras/hs-test/script/build_hst.sh +++ b/extras/hs-test/script/build_hst.sh @@ -5,6 +5,24 @@ if [ "$(lsb_release -is)" != Ubuntu ]; then exit 1 fi +LAST_STATE_FILE=".last_state_hash" + +# get current state hash +current_state_hash=$(git status --porcelain | grep -vE '(/\.|/10|\.go$|\.sum$|\.mod$|\.txt$|\.test$)' | sha1sum | awk '{print $1}') + +if [ -f "$LAST_STATE_FILE" ]; then + last_state_hash=$(cat "$LAST_STATE_FILE") +else + last_state_hash="" +fi + +# compare current state with last state +if [ "$current_state_hash" = "$last_state_hash" ]; then + echo "*** Skipping docker build - no new changes \ +(excluding .go, .txt, .sum, .mod, dotfiles, IP address files) ***" + exit 0 +fi + export VPP_WS=../.. OS_ARCH="$(uname -m)" DOCKER_BUILD_DIR="/scratch/docker-build" @@ -85,3 +103,5 @@ if [ "$images" != "" ]; then # shellcheck disable=SC2086 docker rmi $images fi + +echo "$current_state_hash" > "$LAST_STATE_FILE"