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', '1.22.x', '1.23.x', '1.24.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@v4
25
26 - name: Setup Go
27 uses: actions/setup-go@v5
28 with:
29 go-version: ${{ matrix.go }}
30
31 - name: Set up the prerequisites
32 if: runner.os == 'Linux'
33 run: |
34 sudo apt-get update
35 sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user
36
37 - name: Set up the prerequisites
38 if: runner.os == 'Windows'
39 uses: msys2/setup-msys2@v2
40
41 - name: go vet
42 run: |
43 env CGO_ENABLED=0 go vet -v ./...
44
45 - name: go build
46 run: |
47 go build -v ./...
48 # Compile without optimization to check potential stack overflow.
49 # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
50 # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
51 go build "-gcflags=all=-N -l" -v ./...
52
53 # Check cross-compiling Windows binaries.
54 env GOOS=windows GOARCH=386 go build -v ./...
55 env GOOS=windows GOARCH=amd64 go build -v ./...
56 env GOOS=windows GOARCH=arm go build -v ./...
57 env GOOS=windows GOARCH=arm64 go build -v ./...
58
59 # Check cross-compiling macOS binaries.
60 env GOOS=darwin GOARCH=amd64 go build -v ./...
61 env GOOS=darwin GOARCH=arm64 go build -v ./...
62
63 # Check cross-compiling Linux binaries.
64 env GOOS=linux GOARCH=amd64 go build -v ./...
65 env GOOS=linux GOARCH=arm64 go build -v ./...
66
67 # Check cross-compiling FreeBSD binaries.
68 # gcflags -std is necessary to make fakecgo the Cgo for
69 # FreeBSD to add the symbols that libc.so depends on.
70 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
71 env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
72
73 # Check cross-compiling NetBSD binaries.
74 env GOOS=netbsd GOARCH=amd64 go build -v ./...
75 env GOOS=netbsd GOARCH=arm64 go build -v ./...
76
77 - name: go build (plugin)
78 if: runner.os == 'Linux' || runner.os == 'macOS'
79 run:
80 # Make sure that plugin buildmode works since we save the R15 register (#254)
81 go build -buildmode=plugin ./examples/libc
82
83 - name: go mod vendor
84 if: runner.os != 'Linux'
85 run: |
86 mkdir /tmp/vendoring
87 cd /tmp/vendoring
88 go mod init foo
89 echo 'package main' > main.go
90 echo 'import (' >> main.go
91 echo ' _ "github.com/ebitengine/purego"' >> main.go
92 echo ')' >> main.go
93 echo 'func main() {}' >> main.go
94 go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
95 go mod tidy
96 go mod vendor
97 go build -v .
98
99 - name: go test
100 run: |
101 env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./...
102 env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
103 # Compile without optimization to check potential stack overflow.
104 # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
105 # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch.
106 env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
107 env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
108
109 - name: go test (Linux arm64)
110 if: runner.os == 'Linux'
111 run: |
112 go env -w CC=aarch64-linux-gnu-gcc
113 go env -w CXX=aarch64-linux-gnu-g++
114 env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
115 env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
116 env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
117 env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
118
119 echo "=> go build (plugin)"
120 # Make sure that plugin buildmode works since we save the R15 register (#254)
121 env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go build -buildmode=plugin ./examples/libc
122
123 go env -u CC
124 go env -u CXX
125
126 - name: go test (Windows 386)
127 if: runner.os == 'Windows'
128 run: |
129 env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./...
130 env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
131
132 - name: go test (Linux 386)
133 if: runner.os == 'Linux'
134 run: |
135 sudo apt-get install gcc-multilib
136 sudo apt-get install g++-multilib
137 env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
138
139 - name: go test race
140 if: ${{ !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
141 run: |
142 go test -race -shuffle=on -v -count=10 ./...
143
144 bsd:
145 strategy:
146 matrix:
147 os: ['FreeBSD'] # TODO: Add 'NetBSD' again (#304)
148 go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.9', '1.24.3']
149 exclude:
150 # there are no prebuilt download links for these versions of Go for NetBSD
151 - os: NetBSD
152 go: '1.18.10'
153 - os: NetBSD
154 go: '1.19.13'
155 - os: NetBSD
156 go: '1.20.14'
157 name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
158 runs-on: ubuntu-22.04
159 defaults:
160 run:
161 shell: bash
162 steps:
163 - uses: actions/checkout@v4
164 - name: Run in FreeBSD
165 if: matrix.os == 'FreeBSD'
166 uses: vmactions/freebsd-vm@v1
167 with:
168 usesh: true
169 prepare: |
170 fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
171 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
172 chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
173 run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
174 - name: Run in NetBSD
175 if: matrix.os == 'NetBSD'
176 uses: vmactions/netbsd-vm@v1
177 with:
178 usesh: true
179 prepare: |
180 ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
181 mkdir /usr/local
182 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
183 chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
184 run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh