test.yml RawHistoryFolder
1name: Test
2
3on: [push, pull_request]
4
5jobs:
6 test:
7 strategy:
8 matrix:
9 os: [ubuntu-latest, macos-latest, windows-latest]
10 go: ['1.18.x', '1.19.x', '1.20.x', '1.21.x']
11 name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
12 runs-on: ${{ matrix.os }}
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
23 - name: Checkout
24 uses: actions/checkout@v2
25
26 - name: Setup Go
27 uses: actions/setup-go@v3
28 with:
29 go-version: ${{ matrix.go }}
30
31 - name: go vet
32 if: runner.os != 'Windows' && runner.os != 'macOS'
33 run: |
34 go vet -v ./...
35
36 - name: go build
37 run: |
38 go build -v ./...
39 # Compile without optimization to check potential stack overflow.
40 # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
41 # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
42 go build "-gcflags=all=-N -l" -v ./...
43
44 # Check cross-compiling Windows binaries.
45 env GOOS=windows GOARCH=386 go build -v ./...
46 env GOOS=windows GOARCH=amd64 go build -v ./...
47 env GOOS=windows GOARCH=arm go build -v ./...
48 env GOOS=windows GOARCH=arm64 go build -v ./...
49
50 # Check cross-compiling macOS binaries.
51 env GOOS=darwin GOARCH=amd64 go build -v ./...
52 env GOOS=darwin GOARCH=arm64 go build -v ./...
53
54 # Check cross-compiling Linux binaries.
55 env GOOS=linux GOARCH=amd64 go build -v ./...
56 env GOOS=linux GOARCH=arm64 go build -v ./...
57
58 # Check cross-compiling FreeBSD binaries.
59 # gcflags -std is necessary to make fakecgo the Cgo for
60 # FreeBSD to add the symbols that libc.so depends on.
61 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
62 env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
63
64 - name: go mod vendor
65 if: runner.os != 'Linux'
66 run: |
67 mkdir /tmp/vendoring
68 cd /tmp/vendoring
69 go mod init foo
70 echo 'package main' > main.go
71 echo 'import (' >> main.go
72 echo ' _ "github.com/ebitengine/purego"' >> main.go
73 echo ')' >> main.go
74 echo 'func main() {}' >> main.go
75 go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
76 go mod tidy
77 go mod vendor
78 go build -v .
79
80 - name: go test
81 run: |
82 env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./...
83 env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
84
85 # TODO: add Windows 386 tests
86
87 - name: go test race
88 if: ${{ !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
89 run: |
90 go test -race -shuffle=on -v -count=10 ./...
91
92 freebsd:
93 strategy:
94 matrix:
95 go: ['1.18.10', '1.19.12', '1.20.7', '1.21.0']
96 name: Test with Go ${{ matrix.go }} on FreeBSD
97 runs-on: macos-12
98 defaults:
99 run:
100 shell: bash
101 steps:
102 - uses: actions/checkout@v3
103 - name: Run in freebsd
104 uses: vmactions/freebsd-vm@v0
105 with:
106 usesh: true
107 prepare: |
108 fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
109 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
110 ln -s /usr/local/go/bin/go /usr/local/bin
111 run: |
112 # FreeBSD tests run within a virtualbox VM on macOS.
113 # vmactions/freebsd-vm only supports a single "step" where it
114 # brings down the VM at the end of the step, so all
115 # the commands to run need to be put into this single block.
116
117 echo "Running tests on $(uname -a) at $PWD"
118
119 # verify Go is available
120 go version
121
122 echo "=> go build"
123 go build -v ./...
124 # Compile without optimization to check potential stack overflow.
125 # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
126 # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
127 go build "-gcflags=all=-N -l" -v ./...
128
129 # Check cross-compiling Windows binaries.
130 env GOOS=windows GOARCH=386 go build -v ./...
131 env GOOS=windows GOARCH=amd64 go build -v ./...
132 env GOOS=windows GOARCH=arm go build -v ./...
133 env GOOS=windows GOARCH=arm64 go build -v ./...
134
135 # Check cross-compiling macOS binaries.
136 env GOOS=darwin GOARCH=amd64 go build -v ./...
137 env GOOS=darwin GOARCH=arm64 go build -v ./...
138
139 # Check cross-compiling Linux binaries.
140 env GOOS=linux GOARCH=amd64 go build -v ./...
141 env GOOS=linux GOARCH=arm64 go build -v ./...
142
143 # Check cross-compiling FreeBSD binaries.
144 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
145 env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
146
147 echo "=> go mod vendor"
148 mkdir /tmp/vendoring
149 cd /tmp/vendoring
150 go mod init foo
151 echo 'package main' > main.go
152 echo 'import (' >> main.go
153 echo ' _ "github.com/ebitengine/purego"' >> main.go
154 echo ')' >> main.go
155 echo 'func main() {}' >> main.go
156 go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
157 go mod tidy
158 go mod vendor
159 go build -v .
160
161 cd $GITHUB_WORKSPACE
162 echo "=> go test CGO_ENABLED=0"
163 env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./...
164
165 echo "=> go test CGO_ENABLED=1"
166 env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
167
168 if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then
169 echo "=> go test race"
170 go test -race -shuffle=on -v -count=10 ./...
171 fi