.github/workflows: test linux/arm64 on a native GHA runner (#348)
GitHub Actions supports native Linux ARM64 runners. We can use them instead of running QEMU on Intel. While here, move the loong64-related steps into their own job. This makes the yml simpler and the actions execution around 1 minute faster. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- commit
- 91e14e1f9173e8b82e891513a8b0316d53312ff6
- author
- Quim Muntal · · 2025-10-16 18:08 UTC
- committer
- GitHub · · 2025-10-16 18:08 UTC
- parent
- 8e5400e
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
1 file · +34 -37
M .github/workflows/test.yml +34 -37
| @@ -6,7 +6,7 @@ jobs: | |||
| 6 | 6 | test: | |
| 7 | 7 | strategy: | |
| 8 | 8 | matrix: | |
| 9 | - | os: [ubuntu-latest, macos-latest, windows-latest] | |
| 9 | + | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] | |
| 10 | 10 | go: ['1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x', '1.23.x', '1.24.x', '1.25.x'] | |
| 11 | 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | |
| 12 | 12 | runs-on: ${{ matrix.os }} | |
| @@ -28,12 +28,6 @@ jobs: | |||
| 28 | 28 | with: | |
| 29 | 29 | go-version: ${{ matrix.go }} | |
| 30 | 30 | ||
| 31 | - | - name: Set up the prerequisites | |
| 32 | - | if: runner.os == 'Linux' | |
| 33 | - | run: | | |
| 34 | - | sudo apt-get update | |
| 35 | - | sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu qemu-user | |
| 36 | - | ||
| 37 | 31 | - name: Set up the prerequisites | |
| 38 | 32 | if: runner.os == 'Windows' | |
| 39 | 33 | uses: msys2/setup-msys2@v2 | |
| @@ -113,35 +107,6 @@ jobs: | |||
| 113 | 107 | env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... | |
| 114 | 108 | env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... | |
| 115 | 109 | ||
| 116 | - | - name: go test (Linux arm64) | |
| 117 | - | if: runner.os == 'Linux' | |
| 118 | - | run: | | |
| 119 | - | go env -w CC=aarch64-linux-gnu-gcc | |
| 120 | - | go env -w CXX=aarch64-linux-gnu-g++ | |
| 121 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |
| 122 | - | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |
| 123 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |
| 124 | - | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |
| 125 | - | ||
| 126 | - | echo "=> go build (plugin)" | |
| 127 | - | # Make sure that plugin buildmode works since we save the R15 register (#254) | |
| 128 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -buildmode=plugin ./examples/libc | |
| 129 | - | ||
| 130 | - | go env -u CC | |
| 131 | - | go env -u CXX | |
| 132 | - | ||
| 133 | - | - name: go test (Linux loong64) | |
| 134 | - | if: ${{ runner.os == 'Linux' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') && !startsWith(matrix.go, '1.21.') && !startsWith(matrix.go, '1.22.') && !startsWith(matrix.go, '1.23.') && !startsWith(matrix.go, '1.24.') }} | |
| 135 | - | run: | | |
| 136 | - | go env -w CC=loongarch64-linux-gnu-gcc-14 | |
| 137 | - | go env -w CXX=loongarch64-linux-gnu-g++-14 | |
| 138 | - | env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |
| 139 | - | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |
| 140 | - | env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |
| 141 | - | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |
| 142 | - | go env -u CC | |
| 143 | - | go env -u CXX | |
| 144 | - | ||
| 145 | 110 | - name: go test (Windows 386) | |
| 146 | 111 | if: runner.os == 'Windows' | |
| 147 | 112 | run: | | |
| @@ -149,8 +114,9 @@ jobs: | |||
| 149 | 114 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | |
| 150 | 115 | ||
| 151 | 116 | - name: go test (Linux 386) | |
| 152 | - | if: runner.os == 'Linux' | |
| 117 | + | if: ${{ runner.os == 'Linux' && runner.arch != 'ARM64' }} | |
| 153 | 118 | run: | | |
| 119 | + | sudo apt-get update | |
| 154 | 120 | sudo apt-get install gcc-multilib | |
| 155 | 121 | sudo apt-get install g++-multilib | |
| 156 | 122 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | |
| @@ -166,6 +132,37 @@ jobs: | |||
| 166 | 132 | run: | | |
| 167 | 133 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | |
| 168 | 134 | ||
| 135 | + | loong: | |
| 136 | + | strategy: | |
| 137 | + | matrix: | |
| 138 | + | # Loong64 support internal linking from go1.25. | |
| 139 | + | go: ['1.25.x'] | |
| 140 | + | name: Test with Go ${{ matrix.go }} on Linux loong64 | |
| 141 | + | runs-on: ubuntu-latest | |
| 142 | + | defaults: | |
| 143 | + | run: | |
| 144 | + | shell: bash | |
| 145 | + | steps: | |
| 146 | + | - uses: actions/checkout@v4 | |
| 147 | + | - name: Setup Go | |
| 148 | + | uses: actions/setup-go@v5 | |
| 149 | + | with: | |
| 150 | + | go-version: ${{ matrix.go }} | |
| 151 | + | - name: Set up the prerequisites | |
| 152 | + | run: | | |
| 153 | + | sudo apt-get update | |
| 154 | + | sudo apt-get install -y gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu qemu-user | |
| 155 | + | - name: go test (Linux loong64) | |
| 156 | + | run: | | |
| 157 | + | go env -w CC=loongarch64-linux-gnu-gcc-14 | |
| 158 | + | go env -w CXX=loongarch64-linux-gnu-g++-14 | |
| 159 | + | env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |
| 160 | + | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |
| 161 | + | env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |
| 162 | + | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |
| 163 | + | go env -u CC | |
| 164 | + | go env -u CXX | |
| 165 | + | ||
| 169 | 166 | bsd: | |
| 170 | 167 | strategy: | |
| 171 | 168 | matrix: | |
| @@ -6,7 +6,7 @@ jobs: | |||||
| 6 | test: | 6 | test: | ||
| 7 | strategy: | 7 | strategy: | ||
| 8 | matrix: | 8 | matrix: | ||
| 9 | - | os: [ubuntu-latest, macos-latest, windows-latest] | 9 | + | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] |
| 10 | go: ['1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x', '1.23.x', '1.24.x', '1.25.x'] | 10 | go: ['1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x', '1.23.x', '1.24.x', '1.25.x'] | ||
| 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | ||
| 12 | runs-on: ${{ matrix.os }} | 12 | runs-on: ${{ matrix.os }} | ||
| @@ -28,12 +28,6 @@ jobs: | |||||
| 28 | with: | 28 | with: | ||
| 29 | go-version: ${{ matrix.go }} | 29 | go-version: ${{ matrix.go }} | ||
| 30 | 30 | ||||
| 31 | - | - name: Set up the prerequisites | |||
| 32 | - | if: runner.os == 'Linux' | |||
| 33 | - | run: | | |||
| 34 | - | sudo apt-get update | |||
| 35 | - | sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu qemu-user | |||
| 36 | - | ||||
| 37 | - name: Set up the prerequisites | 31 | - name: Set up the prerequisites | ||
| 38 | if: runner.os == 'Windows' | 32 | if: runner.os == 'Windows' | ||
| 39 | uses: msys2/setup-msys2@v2 | 33 | uses: msys2/setup-msys2@v2 | ||
| @@ -113,35 +107,6 @@ jobs: | |||||
| 113 | env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... | 107 | env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./... | ||
| 114 | env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... | 108 | env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./... | ||
| 115 | 109 | ||||
| 116 | - | - name: go test (Linux arm64) | |||
| 117 | - | if: runner.os == 'Linux' | |||
| 118 | - | run: | | |||
| 119 | - | go env -w CC=aarch64-linux-gnu-gcc | |||
| 120 | - | go env -w CXX=aarch64-linux-gnu-g++ | |||
| 121 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |||
| 122 | - | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |||
| 123 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |||
| 124 | - | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |||
| 125 | - | ||||
| 126 | - | echo "=> go build (plugin)" | |||
| 127 | - | # Make sure that plugin buildmode works since we save the R15 register (#254) | |||
| 128 | - | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -buildmode=plugin ./examples/libc | |||
| 129 | - | ||||
| 130 | - | go env -u CC | |||
| 131 | - | go env -u CXX | |||
| 132 | - | ||||
| 133 | - | - name: go test (Linux loong64) | |||
| 134 | - | if: ${{ runner.os == 'Linux' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.') && !startsWith(matrix.go, '1.21.') && !startsWith(matrix.go, '1.22.') && !startsWith(matrix.go, '1.23.') && !startsWith(matrix.go, '1.24.') }} | |||
| 135 | - | run: | | |||
| 136 | - | go env -w CC=loongarch64-linux-gnu-gcc-14 | |||
| 137 | - | go env -w CXX=loongarch64-linux-gnu-g++-14 | |||
| 138 | - | env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |||
| 139 | - | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |||
| 140 | - | env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |||
| 141 | - | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |||
| 142 | - | go env -u CC | |||
| 143 | - | go env -u CXX | |||
| 144 | - | ||||
| 145 | - name: go test (Windows 386) | 110 | - name: go test (Windows 386) | ||
| 146 | if: runner.os == 'Windows' | 111 | if: runner.os == 'Windows' | ||
| 147 | run: | | 112 | run: | | ||
| @@ -149,8 +114,9 @@ jobs: | |||||
| 149 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | 114 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | ||
| 150 | 115 | ||||
| 151 | - name: go test (Linux 386) | 116 | - name: go test (Linux 386) | ||
| 152 | - | if: runner.os == 'Linux' | 117 | + | if: ${{ runner.os == 'Linux' && runner.arch != 'ARM64' }} |
| 153 | run: | | 118 | run: | | ||
| 119 | + | sudo apt-get update | |||
| 154 | sudo apt-get install gcc-multilib | 120 | sudo apt-get install gcc-multilib | ||
| 155 | sudo apt-get install g++-multilib | 121 | sudo apt-get install g++-multilib | ||
| 156 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | 122 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | ||
| @@ -166,6 +132,37 @@ jobs: | |||||
| 166 | run: | | 132 | run: | | ||
| 167 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | 133 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | ||
| 168 | 134 | ||||
| 135 | + | loong: | |||
| 136 | + | strategy: | |||
| 137 | + | matrix: | |||
| 138 | + | # Loong64 support internal linking from go1.25. | |||
| 139 | + | go: ['1.25.x'] | |||
| 140 | + | name: Test with Go ${{ matrix.go }} on Linux loong64 | |||
| 141 | + | runs-on: ubuntu-latest | |||
| 142 | + | defaults: | |||
| 143 | + | run: | |||
| 144 | + | shell: bash | |||
| 145 | + | steps: | |||
| 146 | + | - uses: actions/checkout@v4 | |||
| 147 | + | - name: Setup Go | |||
| 148 | + | uses: actions/setup-go@v5 | |||
| 149 | + | with: | |||
| 150 | + | go-version: ${{ matrix.go }} | |||
| 151 | + | - name: Set up the prerequisites | |||
| 152 | + | run: | | |||
| 153 | + | sudo apt-get update | |||
| 154 | + | sudo apt-get install -y gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu qemu-user | |||
| 155 | + | - name: go test (Linux loong64) | |||
| 156 | + | run: | | |||
| 157 | + | go env -w CC=loongarch64-linux-gnu-gcc-14 | |||
| 158 | + | go env -w CXX=loongarch64-linux-gnu-g++-14 | |||
| 159 | + | env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |||
| 160 | + | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |||
| 161 | + | env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |||
| 162 | + | env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |||
| 163 | + | go env -u CC | |||
| 164 | + | go env -u CXX | |||
| 165 | + | ||||
| 169 | bsd: | 166 | bsd: | ||
| 170 | strategy: | 167 | strategy: | ||
| 171 | matrix: | 168 | matrix: | ||