CI: enhance package detection logic
authorIlya Lipnitskiy <[email protected]>
Wed, 24 Feb 2021 05:06:21 +0000 (21:06 -0800)
committerPaul Spooren <[email protected]>
Wed, 24 Feb 2021 06:17:30 +0000 (20:17 -1000)
Signed-off-by: Ilya Lipnitskiy <[email protected]>
.github/workflows/multi-arch-test-build.yml

index 20187622b0af87b9a76e08281f75b890fbe2f4ff..249efff33bdbdb5192e6a3a227599fe236e1d50a 100644 (file)
@@ -34,10 +34,18 @@ jobs:
 
       - name: Determine changed packages
         run: |
-          # only detect packages with changed Makefiles
-          PACKAGES="$(git diff --diff-filter=d --name-only origin/master \
-            | grep -E 'Makefile$|test.sh$' | grep -Ev '/files/|/src/' \
-            | awk -F/ '{ print $(NF-1) }' | tr '\n' ' ')"
+          # only detect packages with changes
+          PKG_ROOTS=$(find . -name Makefile | grep -v ".*/src/Makefile" | sed -e 's@./\(.*\)/Makefile@\1/@')
+          CHANGES=$(git diff --diff-filter=d --name-only origin/master)
+
+          for ROOT in $PKG_ROOTS; do
+            for CHANGE in $CHANGES; do
+              if [[ "$CHANGE" == "$ROOT"* ]]; then
+                PACKAGES+=$(echo "$ROOT" | sed -e 's@.*/\(.*\)/@\1 @')
+                break
+              fi
+            done
+          done
 
           # fallback to test packages if nothing explicitly changes this is
           # should run if other mechanics in packages.git changed