hs-test: skip building images if no new changes 10/41910/2
authorAdrian Villin <[email protected]>
Thu, 12 Dec 2024 14:30:15 +0000 (15:30 +0100)
committerFlorin Coras <[email protected]>
Thu, 12 Dec 2024 19:59:24 +0000 (19:59 +0000)
- skip building if new changes are .go, .sum, .mod, .txt, .test,
  IP address files or dotfiles

Type: test

Change-Id: Ib041a077fa34120e86ebb43cd19e50142ef01f16
Signed-off-by: Adrian Villin <[email protected]>
.gitignore
extras/hs-test/script/build_hst.sh

index f579912..8d5b846 100644 (file)
@@ -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
index b7580f5..96a7214 100755 (executable)
@@ -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"