|
| 1 | +# go-doom/engine 6-arch CI -- vet + tests on the pure-Go engine path on |
| 2 | +# every 64-bit arch (amd64 / arm64 / riscv64 / loong64 / ppc64le / s390x). |
| 3 | +# Pairs with go.yml (host-side cgo demos under example/ + ebitengine, amd64- |
| 4 | +# only). Per the org conformance standard, the engine + TamaGo backend |
| 5 | +# layer validates on the same six targets the go-quake1 family does. |
| 6 | +# |
| 7 | +# Scope: |
| 8 | +# - root package (doom.go, seed.go, ...) |
| 9 | +# - backend/audiolog |
| 10 | +# - backend/tamago |
| 11 | +# - cmd/harvest-reference |
| 12 | +# - embedwad |
| 13 | +# |
| 14 | +# Excludes example/* + cgo-bound demos -- those build only on amd64 with |
| 15 | +# SDL/GL/ebitengine and are covered by the existing go.yml. |
| 16 | + |
| 17 | +name: ci-6arch |
| 18 | + |
| 19 | +on: |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + pull_request: |
| 23 | + branches: [main] |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +env: |
| 29 | + GOWORK: off |
| 30 | + CGO_ENABLED: 0 |
| 31 | + |
| 32 | +jobs: |
| 33 | + test: |
| 34 | + name: vet + test (amd64, CGO=0) |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v7 |
| 38 | + |
| 39 | + - uses: actions/setup-go@v6 |
| 40 | + with: |
| 41 | + go-version: stable |
| 42 | + check-latest: true |
| 43 | + |
| 44 | + - run: go version |
| 45 | + |
| 46 | + - name: list pure-Go packages |
| 47 | + id: pkgs |
| 48 | + run: | |
| 49 | + pkgs=$(go list ./... | grep -vE '/(example|reference)/' | tr '\n' ' ') |
| 50 | + echo "PURE_GO_PKGS=$pkgs" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + - name: go vet |
| 53 | + run: go vet $PURE_GO_PKGS |
| 54 | + |
| 55 | + - name: go test |
| 56 | + run: go test $PURE_GO_PKGS |
| 57 | + |
| 58 | + test-arm64: |
| 59 | + name: test (arm64, native CGO=0) |
| 60 | + runs-on: ubuntu-24.04-arm |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v7 |
| 63 | + |
| 64 | + - uses: actions/setup-go@v6 |
| 65 | + with: |
| 66 | + go-version: stable |
| 67 | + check-latest: true |
| 68 | + |
| 69 | + - run: go version |
| 70 | + |
| 71 | + - name: list pure-Go packages |
| 72 | + run: | |
| 73 | + pkgs=$(go list ./... | grep -vE '/(example|reference)/' | tr '\n' ' ') |
| 74 | + echo "PURE_GO_PKGS=$pkgs" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + - name: go test |
| 77 | + run: go test $PURE_GO_PKGS |
| 78 | + |
| 79 | + emulated: |
| 80 | + name: test (${{ matrix.arch }}, qemu CGO=0) |
| 81 | + runs-on: ubuntu-latest |
| 82 | + strategy: |
| 83 | + fail-fast: false |
| 84 | + matrix: |
| 85 | + include: |
| 86 | + - arch: riscv64 |
| 87 | + image: debian:trixie |
| 88 | + qemu_cpu: rv64,v=true,vlen=128 |
| 89 | + - arch: loong64 |
| 90 | + image: ghcr.io/loong64/debian:trixie |
| 91 | + qemu_cpu: la464 |
| 92 | + - arch: ppc64le |
| 93 | + image: debian:trixie |
| 94 | + qemu_cpu: power9 |
| 95 | + - arch: s390x |
| 96 | + image: debian:trixie |
| 97 | + qemu_cpu: qemu |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - uses: actions/setup-go@v5 |
| 102 | + with: |
| 103 | + go-version: stable |
| 104 | + check-latest: true |
| 105 | + |
| 106 | + - run: go version |
| 107 | + |
| 108 | + - name: register QEMU binfmt handlers |
| 109 | + run: docker run --privileged --rm tonistiigi/binfmt --install all |
| 110 | + |
| 111 | + - name: cross-compile test binaries |
| 112 | + env: |
| 113 | + GOOS: linux |
| 114 | + GOARCH: ${{ matrix.arch }} |
| 115 | + run: | |
| 116 | + set -euo pipefail |
| 117 | + mkdir -p _qemu |
| 118 | + pkgs=$(go list ./... | grep -vE '/(example|reference)/') |
| 119 | + for pkg in $pkgs; do |
| 120 | + name=$(echo "$pkg" | tr '/.' '__') |
| 121 | + if go test -c -o "_qemu/${name}.test" "$pkg"; then |
| 122 | + echo "built ${name}.test for $pkg" |
| 123 | + else |
| 124 | + echo "no test binary for $pkg (no tests?)" |
| 125 | + fi |
| 126 | + done |
| 127 | +
|
| 128 | + - name: run test binaries under QEMU (${{ matrix.arch }}) |
| 129 | + run: | |
| 130 | + set -euo pipefail |
| 131 | + shopt -s nullglob |
| 132 | + bins=(_qemu/*.test) |
| 133 | + if [ ${#bins[@]} -eq 0 ]; then |
| 134 | + echo "::error::no test binaries were built for ${{ matrix.arch }}" |
| 135 | + exit 1 |
| 136 | + fi |
| 137 | + for bin in "${bins[@]}"; do |
| 138 | + echo "::group::$bin (${{ matrix.arch }})" |
| 139 | + docker run --rm \ |
| 140 | + --platform "linux/${{ matrix.arch }}" \ |
| 141 | + -e QEMU_CPU='${{ matrix.qemu_cpu }}' \ |
| 142 | + -v "$PWD:/work" -w /work \ |
| 143 | + ${{ matrix.image }} \ |
| 144 | + "/work/$bin" -test.v |
| 145 | + echo "::endgroup::" |
| 146 | + done |
0 commit comments