name: Test on: [push, pull_request] concurrency: # A push event has no head_ref and falls back to a unique run ID, so pushes are never cancelled. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: test: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] go: ['1.25.x', '1.26.x', '1.27.x'] name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} env: DISPLAY: ':99.0' defaults: run: shell: bash steps: - name: Git run: | # See actions/checkout#135 git config --global core.autocrlf false git config --global core.eol lf - name: Checkout uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: Install dependencies if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install libgl1 libgl1-mesa-dri libx11-6 libxcursor1 libxext6 libxi6 libxinerama1 libxrandr2 libxrender1 - name: Xvfb if: runner.os == 'Linux' run: | Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - name: gofmt # gofmt's results can differ between Go versions, but not between OSes. if: runner.os == 'Linux' && matrix.go == '1.27.x' run: | files=$(gofmt -l .) if [ -n "$files" ]; then echo "$files" exit 1 fi - name: go vet (Linux) if: runner.os == 'Linux' run: | go list ./... ./skills/run-ebitengine-app-headless/_driver | grep -v -x -F -f .github/workflows/govetblock_linbsd.txt | xargs go vet - name: go vet (macOS) if: runner.os == 'macOS' run: | go list ./... ./skills/run-ebitengine-app-headless/_driver | grep -v -x -F -f .github/workflows/govetblock_darwin.txt | xargs go vet - name: go vet (Windows) if: runner.os == 'Windows' run: | go list ./... ./skills/run-ebitengine-app-headless/_driver | grep -v -x -F -f .github/workflows/govetblock_windows.txt | xargs go vet - name: go vet (vettool) run: | go install ./internal/vettools go vet -vettool=$(which vettools)${{ runner.os == 'Windows' && '.exe' || '' }} -v ./... ./skills/run-ebitengine-app-headless/_driver - name: go build run: | go build -v ./... ./skills/run-ebitengine-app-headless/_driver # Compile without optimization to check potential stack overflow. # The option '-gcflags=all=-N -l' is often used at Visual Studio Code. # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue #2120. go build "-gcflags=all=-N -l" -v ./... - name: go build (cross-compile from Windows) if: runner.os == 'Windows' run: | # Check that cross-compilation works from a non-Linux host. env GOOS=darwin GOARCH=arm64 go build -v ./... env GOOS=linux GOARCH=amd64 go build -v ./... - name: go build (cross-compile from macOS) if: runner.os == 'macOS' run: | # Check that cross-compilation works from a non-Linux host. env GOOS=linux GOARCH=amd64 go build -v ./... env GOOS=windows GOARCH=amd64 go build -v ./... - name: go build (macOS) if: runner.os == 'macOS' run: | env GOOS=darwin GOARCH=amd64 go build -o flappy_amd64 -v ./examples/flappy env GOOS=darwin GOARCH=arm64 go build -o flappy_arm64 -v ./examples/flappy lipo -create flappy_amd64 flappy_arm64 -output flappy file flappy rm flappy - name: go mod vendor run: | mkdir /tmp/vendoring cd /tmp/vendoring go mod init foo # TODO: Is there a way to create a complete list of Ebitengine sub-packages? echo 'package main' > main.go echo 'import (' >> main.go echo ' _ "github.com/hajimehoshi/ebiten/v2"' >> main.go echo ' _ "github.com/hajimehoshi/ebiten/v2/audio"' >> main.go echo ')' >> main.go echo 'func main() {}' >> main.go go mod edit -replace github.com/hajimehoshi/ebiten/v2=$GITHUB_WORKSPACE go mod tidy go mod vendor go build -v . - name: go test (Linux) if: runner.os == 'Linux' run: | go test -shuffle=on -v -p=1 ./... - name: go test -race (Linux) if: runner.os == 'Linux' && matrix.go == '1.27.x' run: | go test -race -shuffle=on -v -p=1 ./... - name: go test (Linux 386) if: runner.os == 'Linux' run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libgl1:i386 libgl1-mesa-dri:i386 libx11-6:i386 libxcursor1:i386 libxext6:i386 libxi6:i386 libxinerama1:i386 libxrandr2:i386 libxrender1:i386 env GOARCH=386 go test -shuffle=on -v -p=1 ./... - name: go test (Linux OpenGL ES) if: runner.os == 'Linux' run: | sudo apt-get install libegl1 libgles2 env EBITENGINE_GRAPHICS_LIBRARY=opengl go test -shuffle=on -v -p=1 ./... - name: go test (Windows) if: runner.os == 'Windows' run: | go test -shuffle=on -v ./... env EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./... - name: go test (Windows 386) if: runner.os == 'Windows' run: | env GOARCH=386 go test -shuffle=on -v ./... env GOARCH=386 EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./... gbm: strategy: matrix: go: ['1.25.x', '1.26.x', '1.27.x'] name: Test GBM with Go ${{ matrix.go }} runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: Install dependencies run: | sudo apt-get update sudo apt-get install libdrm2 libegl1 libegl-mesa0 libgbm1 libgl1-mesa-dri libgles2 linux-modules-extra-$(uname -r) - name: Load vkms run: | # vkms is a virtual KMS device with a connected output. Mesa renders for it with its software driver. sudo modprobe vkms sudo udevadm settle sudo chmod a+rw /dev/dri/card* - name: go test (GBM) run: | # With neither DISPLAY nor WAYLAND_DISPLAY set, Ebitengine presents through GBM and KMS. # Only one process can be the DRM master at a time, so packages must run one by one. go test -shuffle=on -v -p=1 ./... cross-build: strategy: matrix: go: ['1.25.x', '1.26.x', '1.27.x'] name: Cross build with Go ${{ matrix.go }} runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: go build run: | env GOOS=darwin GOARCH=amd64 go build -v ./... env GOOS=darwin GOARCH=arm64 go build -v ./... env GOOS=freebsd GOARCH=amd64 go build "-gcflags=github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... env GOOS=freebsd GOARCH=arm64 go build "-gcflags=github.com/ebitengine/purego/internal/fakecgo=-std" -v ./... env GOOS=js GOARCH=wasm go build -v ./... env GOOS=linux GOARCH=386 go build -v ./... env GOOS=linux GOARCH=amd64 go build -v ./... env GOOS=linux GOARCH=arm go build -v ./... env GOOS=linux GOARCH=arm64 go build -v ./... env GOOS=netbsd GOARCH=amd64 go build -v ./... env GOOS=netbsd GOARCH=arm64 go build -v ./... env GOOS=windows GOARCH=386 go build -v ./... env GOOS=windows GOARCH=amd64 go build -v ./... env GOOS=windows GOARCH=arm64 go build -v ./... cgo: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] go: ['1.25.x', '1.26.x', '1.27.x'] name: Test Cgo with Go ${{ matrix.go }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} defaults: run: shell: bash steps: - name: Git run: | # See actions/checkout#135 git config --global core.autocrlf false git config --global core.eol lf - name: Checkout uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: Setup JDK uses: actions/setup-java@v5 with: java-version: '11' distribution: 'adopt' - name: Install dependencies if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install libegl-dev - name: Prepare ebitenmobile test run: | cd /tmp git clone --depth=1 https://github.com/hajimehoshi/go-inovation cd go-inovation go mod edit -replace=github.com/hajimehoshi/ebiten/v2=$GITHUB_WORKSPACE go mod tidy - name: go build (NintendoSDK) if: runner.os == 'Linux' run: | go build -tags=nintendosdk -v ./... - name: go build (PlayStation 5) if: runner.os == 'Linux' run: | go build -tags=playstation5 -v ./... - name: go test internal/glfw (xlibcheck) if: runner.os == 'Linux' run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install gcc-multilib sudo apt-get install libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev sudo apt-get install libxcursor-dev:i386 libxi-dev:i386 libxinerama-dev:i386 libxrandr-dev:i386 libxrender-dev:i386 go test -shuffle=on -v -tags=ebitenginexlibcheck ./internal/glfw/ env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -tags=ebitenginexlibcheck ./internal/glfw/ - name: Install ebitenmobile run: | go install ./cmd/ebitenmobile - name: ebitenmobile bind (Android) run: | cd /tmp/go-inovation ebitenmobile bind -target android -androidapi 23 -javapkg com.hajimehoshi.goinovation -o inovation.aar -v github.com/hajimehoshi/go-inovation/mobile - name: ebitenmobile bind (iOS) if: runner.os == 'macOS' run: | cd /tmp/go-inovation ebitenmobile bind -target ios -o Inovation.xcframework -v github.com/hajimehoshi/go-inovation/mobile wasm: strategy: matrix: go: ['1.25.x', '1.26.x', '1.27.x'] name: Test WebAssembly with Go ${{ matrix.go }} runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Git run: | # See actions/checkout#135 git config --global core.autocrlf false git config --global core.eol lf - name: Checkout uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v6 with: go-version: ${{ matrix.go }} - name: Install Chrome uses: browser-actions/setup-chrome@latest - name: Install wasmbrowsertest run: | wasmbrowsertest_version=eec8f6b3828fd793968ed35171566ab20de7b4cc go install github.com/agnivade/wasmbrowsertest@${wasmbrowsertest_version} mv $(go env GOPATH)/bin/wasmbrowsertest${{ runner.os == 'Windows' && '.exe' || '' }} $(go env GOPATH)/bin/go_js_wasm_exec${{ runner.os == 'Windows' && '.exe' || '' }} go install github.com/agnivade/wasmbrowsertest/cmd/cleanenv@${wasmbrowsertest_version} - name: go test (Wasm) run: | # Disable AppArmor for Ubuntu 23.10+. # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns # Wasm tests don't work on macOS with the headless mode enabled, but the headless mode cannot be disabled in GitHub Actions (#2972). # Wasm tests time out on Windows (#3076). max_attempts=3 for i in $(seq 1 $max_attempts); do env GOOS=js GOARCH=wasm cleanenv -remove-prefix GITHUB_ -remove-prefix JAVA_ -remove-prefix PSModulePath -remove-prefix STATS_ -remove-prefix RUNNER_ -- go test -shuffle=on -v ./... -test.paniconexit0=false && break if [ $i -eq $max_attempts ]; then echo "All $max_attempts attempts failed." exit 1 fi echo "Attempt $i failed. Retrying in 10 seconds..." sleep 10 done