CI: Do package run-tests only if target packages were built
[feed/routing.git] / .github / workflows / multi-arch-test-build.yml
index b0da82ca68cefb23884086892d885762eeee5cfe..3aabab41e8a303901137f78fca340c2f005b565c 100644 (file)
@@ -80,6 +80,7 @@ jobs:
 
       - name: Generate build keys
         run: |
+          sudo apt-get update
           sudo apt-get install -y signify-openbsd
           signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
           EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
@@ -117,21 +118,32 @@ jobs:
       - name: Remove logs
         run: sudo rm -rf logs/ || true
 
+      - name: Check if any packages were built
+        run: |
+          if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
+            echo "Found *.ipk files"
+            HAVE_IPKS=true
+          else
+            echo "No *.ipk files found"
+            HAVE_IPKS=false
+          fi
+          echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
+
       - name: Register QEMU
-        if: ${{ matrix.runtime_test }}
+        if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
         run: |
           sudo apt-get update
           sudo apt-get install -y qemu-user-static binfmt-support
           sudo update-binfmts --import
 
       - name: Build Docker container
-        if: ${{ matrix.runtime_test }}
+        if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
         run: |
           docker build -t test-container --build-arg ARCH .github/workflows/
         env:
           ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
 
       - name: Test via Docker container
-        if: ${{ matrix.runtime_test }}
+        if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
         run: |
           docker run --rm -v $GITHUB_WORKSPACE:/ci test-container