I'm trying to create Github Actions for my repo on Github. Everything works fine, until actions come to testing because I have this error:
Run cd tests && go test . -v
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
2024/03/14 23:49:05 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running]:
github.com/hajimehoshi/ebiten/v2/internal/cglfw.acceptError({0x0, 0x0, 0x10004?})
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/cglfw/error.go:184 +0x1f4
github.com/hajimehoshi/ebiten/v2/internal/cglfw.panicError(...)
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/cglfw/error.go:195
github.com/hajimehoshi/ebiten/v2/internal/cglfw.WindowHint(0x0?, 0x0?)
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/cglfw/window.go:317 +0x34
github.com/hajimehoshi/ebiten/v2/internal/glfw.WindowHint(...)
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/glfw/glfw_cglfw.go:347
github.com/hajimehoshi/ebiten/v2/internal/ui.initialize()
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/ui_glfw.go:174 +0x36
github.com/hajimehoshi/ebiten/v2/internal/ui.init.2()
/home/runner/go/pkg/mod/github.com/hajimehoshi/ebiten/[email protected]/internal/ui/ui_glfw.go:159 +0x13
FAIL github.com/Arkadiusz4/meteor-maverick-game/tests 0.028s
FAIL
Error: Process completed with exit code 1.
As you can see there is problem with X11 (I have no clue what's going on here).
I tried to add something to my workflow file:
name: Go
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.21.x' ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.3'
- name: Display Go version
run: go version
- name: Install dependencies
run: |
go get github.com/hajimehoshi/ebiten/v2
go get github.com/stretchr/testify
sudo apt-get install libxrandr-dev libgl1-mesa-dev libxcursor-dev libxinerama-dev libxi-dev libxxf86vm-dev xorg-dev mesa-utils
- name: Build
run: go build -v ./...
- name: Testing, testing
run: cd tests && go test . -v
It doesn't help, so I also tried to add something to my main.go.
func main() {
err := os.Setenv("DISPLAY", ":0")
if err != nil {
panic(err)
}
g := game.NewGame()
err = ebiten.RunGame(g)
err := ebiten.RunGame(g)
if err != nil {
panic(err)
}
}
It also doesn't help and I don't have any other thoughts how I can repair this :/
Thanks for your help in advance.