|
| 1 | +name: ARM64 tests on PRs |
| 2 | + |
| 3 | +on: [workflow_call] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +jobs: |
| 9 | + cross-compile: |
| 10 | + name: Cross-compile all packages for ARM64 |
| 11 | + runs-on: ubuntu-24.04 |
| 12 | + timeout-minutes: 15 |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v5 |
| 16 | + |
| 17 | + - name: Setup Go |
| 18 | + uses: ./.github/actions/go-setup-cache |
| 19 | + |
| 20 | + - name: Install ARM64 cross-compiler |
| 21 | + run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu |
| 22 | + |
| 23 | + - name: Build and vet packages (pure Go) |
| 24 | + run: | |
| 25 | + for pkg in api client-proxy envd shared db docker-reverse-proxy; do |
| 26 | + echo "::group::packages/$pkg" |
| 27 | + pushd "packages/$pkg" > /dev/null |
| 28 | + GOARCH=arm64 go build ./... |
| 29 | + GOARCH=arm64 go vet ./... |
| 30 | + popd > /dev/null |
| 31 | + echo "::endgroup::" |
| 32 | + done |
| 33 | +
|
| 34 | + - name: Fetch busybox for orchestrator embed |
| 35 | + run: make -C packages/orchestrator fetch-busybox BUILD_ARCH=arm64 |
| 36 | + |
| 37 | + - name: Build and vet orchestrator (CGO) |
| 38 | + run: | |
| 39 | + CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=arm64 go build ./... |
| 40 | + CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=arm64 go vet ./... |
| 41 | + working-directory: packages/orchestrator |
| 42 | + |
| 43 | + arm64-unit-tests: |
| 44 | + name: ARM64 tests for ${{ matrix.package }} |
| 45 | + runs-on: ubuntu-24.04-arm |
| 46 | + timeout-minutes: 30 |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + include: |
| 50 | + - package: packages/api |
| 51 | + test_path: ./... |
| 52 | + sudo: false |
| 53 | + - package: packages/client-proxy |
| 54 | + test_path: ./... |
| 55 | + sudo: false |
| 56 | + - package: packages/db |
| 57 | + test_path: ./... |
| 58 | + sudo: false |
| 59 | + - package: packages/docker-reverse-proxy |
| 60 | + test_path: ./... |
| 61 | + sudo: false |
| 62 | + - package: packages/envd |
| 63 | + test_path: ./... |
| 64 | + sudo: true |
| 65 | + - package: packages/orchestrator |
| 66 | + test_path: ./... |
| 67 | + sudo: true |
| 68 | + - package: packages/shared |
| 69 | + test_path: ./pkg/... |
| 70 | + sudo: false |
| 71 | + fail-fast: false |
| 72 | + steps: |
| 73 | + - name: Checkout repository |
| 74 | + uses: actions/checkout@v5 |
| 75 | + |
| 76 | + - name: Setup Go |
| 77 | + uses: ./.github/actions/go-setup-cache |
| 78 | + with: |
| 79 | + cache-dependency-paths: | |
| 80 | + go.work |
| 81 | + ${{ matrix.package }}/go.mod |
| 82 | + ${{ matrix.package }}/go.sum |
| 83 | +
|
| 84 | + - name: Setup envd tests |
| 85 | + run: | |
| 86 | + sudo apt-get update && sudo apt-get install -y bindfs |
| 87 | + if: matrix.package == 'packages/envd' |
| 88 | + |
| 89 | + - name: Setup orchestrator tests |
| 90 | + run: | |
| 91 | + # Download busybox for go:embed |
| 92 | + make -C packages/orchestrator fetch-busybox |
| 93 | +
|
| 94 | + # Enable unprivileged uffd (Ubuntu defaults to 0) |
| 95 | + echo 1 | sudo tee /proc/sys/vm/unprivileged_userfaultfd |
| 96 | +
|
| 97 | + # Enable hugepages (256 × 2MB = 512MB). |
| 98 | + # Tests that need more hugepages than available will skip gracefully. |
| 99 | + sudo mkdir -p /mnt/hugepages |
| 100 | + sudo mount -t hugetlbfs none /mnt/hugepages |
| 101 | + echo 256 | sudo tee /proc/sys/vm/nr_hugepages |
| 102 | +
|
| 103 | + # Install extra kernel modules (nbd is not in base modules on GitHub-hosted runners) |
| 104 | + sudo apt-get update |
| 105 | + sudo apt-get install -y linux-modules-extra-$(uname -r) |
| 106 | + sudo modprobe nbd nbds_max=256 |
| 107 | +
|
| 108 | + # Disable inotify watching of change events for NBD devices |
| 109 | + echo 'ACTION=="add|change", KERNEL=="nbd*", OPTIONS:="nowatch"' | sudo tee /etc/udev/rules.d/97-nbd-device.rules |
| 110 | + sudo udevadm control --reload-rules |
| 111 | + sudo udevadm trigger |
| 112 | + if: matrix.package == 'packages/orchestrator' |
| 113 | + |
| 114 | + - name: Run tests that require sudo |
| 115 | + working-directory: ${{ matrix.package }} |
| 116 | + run: sudo -E `which go` test -race -v ${{ matrix.test_path }} |
| 117 | + if: matrix.sudo == true |
| 118 | + |
| 119 | + - name: Run tests |
| 120 | + working-directory: ${{ matrix.package }} |
| 121 | + run: go test -race -v ${{ matrix.test_path }} |
| 122 | + if: matrix.sudo == false |
0 commit comments