test.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. name: Test
  2. on: [push, pull_request]
  3. jobs:
  4. test:
  5. strategy:
  6. matrix:
  7. os: [ubuntu-latest, macos-latest, windows-latest]
  8. go: ['1.22.x', '1.23.x']
  9. name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
  10. runs-on: ${{ matrix.os }}
  11. env:
  12. DISPLAY: ':99.0'
  13. defaults:
  14. run:
  15. shell: bash
  16. steps:
  17. - name: Git
  18. run: |
  19. # See actions/checkout#135
  20. git config --global core.autocrlf false
  21. git config --global core.eol lf
  22. - name: Checkout
  23. uses: actions/checkout@v4
  24. - name: Setup Go
  25. uses: actions/setup-go@v5
  26. with:
  27. go-version: ${{ matrix.go }}
  28. - name: Setup JDK
  29. uses: actions/setup-java@v4
  30. with:
  31. java-version: '11'
  32. distribution: 'adopt'
  33. - name: Install dependencies
  34. if: runner.os == 'Linux'
  35. run: |
  36. sudo apt-get update
  37. sudo apt-get install libasound2-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev
  38. - name: Install Chrome
  39. uses: browser-actions/setup-chrome@latest
  40. - name: Install wasmbrowsertest
  41. run: |
  42. wasmbrowsertest_version=06679196c7e76f227e71456cdc16fccd6cc33601
  43. go install github.com/agnivade/wasmbrowsertest@${wasmbrowsertest_version}
  44. mv $(go env GOPATH)/bin/wasmbrowsertest${{ runner.os == 'Windows' && '.exe' || '' }} $(go env GOPATH)/bin/go_js_wasm_exec${{ runner.os == 'Windows' && '.exe' || '' }}
  45. go install github.com/agnivade/wasmbrowsertest/cmd/cleanenv@${wasmbrowsertest_version}
  46. - name: Prepare ebitenmobile test
  47. run: |
  48. cd /tmp
  49. git clone --depth=1 https://github.com/hajimehoshi/go-inovation
  50. cd go-inovation
  51. go mod edit -replace=github.com/hajimehoshi/ebiten/v2=$GITHUB_WORKSPACE
  52. go mod tidy
  53. - name: Xvfb
  54. if: runner.os == 'Linux'
  55. run: |
  56. Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
  57. - name: go vet (Linux)
  58. if: runner.os == 'Linux'
  59. run: |
  60. go vet ./...
  61. - name: go vet (macOS)
  62. if: runner.os == 'macOS'
  63. run: |
  64. go list ./... | grep -v -x -F -f .github/workflows/govetblock_darwin.txt | xargs go vet
  65. - name: go vet (Windows)
  66. if: runner.os == 'Windows'
  67. run: |
  68. go list ./... | grep -v -x -F -f .github/workflows/govetblock_windows.txt | xargs go vet
  69. - name: go vet (vettool)
  70. run: |
  71. go install ./internal/vettools
  72. go vet -vettool=$(which vettools)${{ runner.os == 'Windows' && '.exe' || '' }} -v ./...
  73. - name: go build
  74. run: |
  75. go build -v ./...
  76. # Compile without optimization to check potential stack overflow.
  77. # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
  78. # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue #2120.
  79. go build "-gcflags=all=-N -l" -v ./...
  80. env GOOS=js GOARCH=wasm go build -v ./...
  81. env GOOS=windows GOARCH=386 go build -v ./...
  82. env GOOS=windows GOARCH=amd64 go build -v ./...
  83. env GOOS=windows GOARCH=arm go build -v ./...
  84. env GOOS=windows GOARCH=arm64 go build -v ./...
  85. - name: go build (macOS)
  86. if: runner.os == 'macOS'
  87. run: |
  88. env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v ./...
  89. env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o flappy_amd64 -v ./examples/flappy
  90. env CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o flappy_arm64 -v ./examples/flappy
  91. lipo -create flappy_amd64 flappy_arm64 -output flappy
  92. file flappy
  93. rm flappy
  94. - name: go build (NintendoSDK)
  95. if: runner.os == 'Linux'
  96. run: |
  97. go build -tags=nintendosdk -v ./...
  98. - name: go build (PlayStation 5)
  99. if: runner.os == 'Linux'
  100. run: |
  101. go build -tags=playstation5 -v ./...
  102. - name: go mod vendor
  103. run: |
  104. mkdir /tmp/vendoring
  105. cd /tmp/vendoring
  106. go mod init foo
  107. # TODO: Is there a way to create a complete list of Ebitengine sub-packages?
  108. echo 'package main' > main.go
  109. echo 'import (' >> main.go
  110. echo ' _ "github.com/hajimehoshi/ebiten/v2"' >> main.go
  111. echo ' _ "github.com/hajimehoshi/ebiten/v2/audio"' >> main.go
  112. echo ')' >> main.go
  113. echo 'func main() {}' >> main.go
  114. go mod edit -replace github.com/hajimehoshi/ebiten/v2=$GITHUB_WORKSPACE
  115. go mod tidy
  116. go mod vendor
  117. go build -v .
  118. - name: go test (Linux)
  119. if: runner.os == 'Linux'
  120. run: |
  121. go test -shuffle=on -v -p=1 ./...
  122. - name: go test (Linux 386)
  123. if: runner.os == 'Linux'
  124. run: |
  125. sudo dpkg --add-architecture i386
  126. sudo apt-get update
  127. sudo apt-get install gcc-multilib
  128. sudo apt-get install libasound2-dev:i386 libgl1-mesa-dev:i386 libxcursor-dev:i386 libxi-dev:i386 libxinerama-dev:i386 libxrandr-dev:i386 libxxf86vm-dev:i386
  129. env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -p=1 ./...
  130. - name: go test (Linux OpenGL ES)
  131. if: runner.os == 'Linux'
  132. run: |
  133. sudo apt-get install libgles2-mesa-dev
  134. env EBITENGINE_GRAPHICS_LIBRARY=opengl go test -shuffle=on -v -p=1 ./...
  135. - name: go test (Windows)
  136. if: runner.os == 'Windows'
  137. run: |
  138. go test -shuffle=on -v ./...
  139. env EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./...
  140. - name: go test (Windows 386)
  141. if: runner.os == 'Windows'
  142. run: |
  143. env GOARCH=386 go test -shuffle=on -v ./...
  144. env GOARCH=386 EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./...
  145. - name: go test (Wasm)
  146. if: runner.os == 'Linux'
  147. run: |
  148. # Disable AppArmor for Ubuntu 23.10+.
  149. # https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
  150. echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
  151. # Wasm tests don't work on macOS with the headless mode enabled, but the headless mode cannot be disabled in GitHub Actions (#2972).
  152. # Wasm tests time out on Windows (#3076).
  153. 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
  154. - name: Install ebitenmobile
  155. run: |
  156. go install ./cmd/ebitenmobile
  157. - name: ebitenmobile bind (Android)
  158. run: |
  159. cd /tmp/go-inovation
  160. ebitenmobile bind -target android -androidapi 23 -javapkg com.hajimehoshi.goinovation -o inovation.aar -v github.com/hajimehoshi/go-inovation/mobile
  161. - name: ebitenmobile bind (iOS)
  162. if: runner.os == 'macOS'
  163. run: |
  164. cd /tmp/go-inovation
  165. ebitenmobile bind -target ios -o Inovation.xcframework -v github.com/hajimehoshi/go-inovation/mobile