Browse Source

.github: save CI time

These jobs take 18 seconds of machine time and 21 seconds of setup;
consolidate them into one job to cut down on the overhead.
Tamir Duberstein 6 days ago
parent
commit
e5eb3058aa
1 changed files with 40 additions and 36 deletions
  1. 40 36
      .github/workflows/ci.yml

+ 40 - 36
.github/workflows/ci.yml

@@ -144,21 +144,6 @@ jobs:
             --workspace
 
   build-test-aya-ebpf:
-    strategy:
-      fail-fast: false
-      matrix:
-        bpf_target_arch:
-          - aarch64
-          - arm
-          - loongarch64
-          - mips
-          - powerpc64
-          - riscv64
-          - s390x
-          - x86_64
-        target:
-          - bpfel-unknown-none
-          - bpfeb-unknown-none
     runs-on: ubuntu-latest
 
     steps:
@@ -177,30 +162,49 @@ jobs:
 
       - uses: taiki-e/install-action@cargo-hack
 
-      - name: Build
+      - name: Build & test for all BPF architectures
         env:
-          CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.bpf_target_arch }}
-        run: |
-          set -euxo pipefail
-          cargo +nightly hack build \
-            --target ${{ matrix.target }} \
-            -Z build-std=core \
-            --package aya-ebpf \
-            --package aya-log-ebpf \
-            --feature-powerset
-
-      - name: Test
-        env:
-          CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.bpf_target_arch }}
           RUST_BACKTRACE: full
         run: |
-          set -euxo pipefail
-          cargo hack test \
-            --doc \
-            --package aya-ebpf \
-            --package aya-log-ebpf \
-            --feature-powerset
-
+          set -euo pipefail
+
+          failures=()
+
+          # NB: this hand-rolled shell script is used instead of a matrix
+          # because the time spent doing useful work per target is about equal
+          # to the overhead of setting up the job - so this saves a bunch of
+          # machine time.
+          for arch in aarch64 arm loongarch64 mips powerpc64 riscv64 s390x x86_64; do
+            for target in bpfeb-unknown-none bpfel-unknown-none; do
+              echo "::group::Build and test for $arch / $target"
+              if ! (
+                export CARGO_CFG_BPF_TARGET_ARCH="$arch"
+
+                cargo +nightly hack build \
+                  --target "$target" \
+                  -Z build-std=core \
+                  --package aya-ebpf \
+                  --package aya-log-ebpf \
+                  --feature-powerset
+
+                cargo hack test \
+                  --doc \
+                  --package aya-ebpf \
+                  --package aya-log-ebpf \
+                  --feature-powerset
+              ); then
+                echo "FAILED: $arch / $target"
+                failures+=("$arch/$target")
+              fi
+              echo "::endgroup::"
+            done
+          done
+
+          if ((${#failures[@]})); then
+            echo "::error::Some builds/tests failed:"
+            printf '  %s\n' "${failures[@]}"
+            exit 1
+          fi
   run-integration-test:
     strategy:
       fail-fast: false