File: test.yml

package info (click to toggle)
golang-github-ebitengine-purego 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,452 kB
  • sloc: asm: 31,862; ansic: 1,001; cpp: 8; makefile: 3
file content (270 lines) | stat: -rw-r--r-- 11,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: Test

on: [push, pull_request]

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
        go: ['1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x', '1.23.x', '1.24.x', '1.25.x', '1.26.x']
    name: Test 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@v5

      - name: Setup Go
        uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go }}

      - name: Set up the prerequisites
        if: runner.os == 'Windows'
        uses: msys2/setup-msys2@v2

      - name: go vet
        run: |
          env CGO_ENABLED=0 go vet -v ./...

      - name: gofmt
        run: test -z "$(gofmt -s -l .)"

      - name: go build
        run: |
          go build -v ./...
          # 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 hajimehoshi/ebiten#2120.
          go build "-gcflags=all=-N -l" -v ./...

          # Check cross-compiling Windows binaries.
          env GOOS=windows GOARCH=386 go build -v ./...
          env GOOS=windows GOARCH=amd64 go build -v ./...
          env GOOS=windows GOARCH=arm64 go build -v ./...

          # Check cross-compiling macOS binaries.
          env GOOS=darwin GOARCH=amd64 go build -v ./...
          env GOOS=darwin GOARCH=arm64 go build -v ./...

          # Check cross-compiling Linux binaries.
          env GOOS=linux GOARCH=amd64 go build -v ./...
          env GOOS=linux GOARCH=arm64 go build -v ./...

          # Check cross-compiling FreeBSD binaries.
          # gcflags -std is necessary to make fakecgo the Cgo for
          # FreeBSD to add the symbols that libc.so depends on.
          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 ./...          
          
          # Check cross-compiling NetBSD binaries.
          env GOOS=netbsd GOARCH=amd64 go build -v ./...
          env GOOS=netbsd GOARCH=arm64 go build -v ./...

      - name: go build (Linux minor architectures)
        # Test them only on the latest Go to reduce CI time.
        # s390x cannot be tested here as it requires Cgo.
        if: startsWith(matrix.go, '1.26.')
        run: |
          # Check cross-compiling Linux binaries for minor architectures.
          env GOOS=linux GOARCH=loong64 go build -v ./...
          env GOOS=linux GOARCH=ppc64le go build -v ./...
          env GOOS=linux GOARCH=riscv64 go build -v ./...

      - name: go build (plugin)
        if: runner.os == 'Linux' || runner.os == 'macOS'
        run:
          # Make sure that plugin buildmode works since we save the R15 register (#254)
          go build -buildmode=plugin ./examples/libc

      - name: go mod vendor
        if: runner.os != 'Linux'
        run: |
          mkdir /tmp/vendoring
          cd /tmp/vendoring
          go mod init foo
          echo 'package main' > main.go
          echo 'import (' >> main.go
          echo '  _ "github.com/ebitengine/purego"' >> main.go
          echo ')' >> main.go
          echo 'func main() {}' >> main.go
          go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
          go mod tidy
          go mod vendor
          go build -v .

      - name: go test
        run: |
          env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./...
          env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
          # 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.
          env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
          env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...

      - name: go test (Windows 386)
        if: runner.os == 'Windows'
        run: |
          env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./...
          env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...

      - name: go test (Linux 386)
        if: ${{ runner.os == 'Linux' && runner.arch != 'ARM64' }}
        run: |
           sudo apt-get update
           sudo apt-get install gcc-multilib
           sudo apt-get install g++-multilib
           env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./...
           env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
      
      - name: go test (Linux arm)
        if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
        run: |
           sudo apt-get update
           sudo apt-get install -y qemu-user gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross
           # Create symlink for the dynamic linker that QEMU expects
           sudo ln -sf /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
           go env -w CC=arm-linux-gnueabihf-gcc
           go env -w CXX=arm-linux-gnueabihf-g++
           env GOOS=linux GOARCH=arm CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
           env QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-arm ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
           env GOOS=linux GOARCH=arm CGO_ENABLED=1 go test -c -o=purego-test-cgo .
           env QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-arm ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
           go env -u CC
           go env -u CXX

      - name: go test race (no Cgo)
        if: ${{ runner.os == 'macOS' &&  !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
        run: |
          # -race usually requires Cgo, but macOS is an exception. See https://go.dev/doc/articles/race_detector#Requirements
          env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./...

      - name: go test race (Cgo)
        if: ${{ !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
        run: |
          env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./...

  minor-arches:
    strategy:
      matrix:
        # Test them only on the latest Go to reduce CI time.
        go: ['1.26.x']
    name: Test with Go ${{ matrix.go }} on Linux minor architectures
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Setup Go
        uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go }}

      - name: Set up the prerequisites
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu \
            gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
            gcc-riscv64-linux-gnu g++-riscv64-linux-gnu \
            gcc-s390x-linux-gnu g++-s390x-linux-gnu \
            qemu-user

      - name: go test (Linux loong64)
        run: |
          go env -w CC=loongarch64-linux-gnu-gcc-14
          go env -w CXX=loongarch64-linux-gnu-g++-14
          env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
          env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
          env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
          env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
          go env -u CC
          go env -u CXX

      - name: go test (Linux ppc64le)
        run: |
          go env -w CC=powerpc64le-linux-gnu-gcc
          go env -w CXX=powerpc64le-linux-gnu-g++
          env GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
          env QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu qemu-ppc64le ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
          env GOOS=linux GOARCH=ppc64le CGO_ENABLED=1 go test -c -o=purego-test-cgo .
          env QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu qemu-ppc64le ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
          go env -u CC
          go env -u CXX

      - name: go test (Linux riscv64)
        run: |
          go env -w CC=riscv64-linux-gnu-gcc
          go env -w CXX=riscv64-linux-gnu-g++
          # Create symlink for the dynamic linker that QEMU expects
          sudo ln -sf /usr/riscv64-linux-gnu/lib/ld-linux-riscv64-lp64d.so.1 /lib/ld.so.1
          env GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
          env QEMU_LD_PREFIX=/usr/riscv64-linux-gnu qemu-riscv64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
          env GOOS=linux GOARCH=riscv64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
          env QEMU_LD_PREFIX=/usr/riscv64-linux-gnu qemu-riscv64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
          go env -u CC
          go env -u CXX

      - name: go test (Linux s390x)
        run: |
          go env -w CC=s390x-linux-gnu-gcc
          go env -w CXX=s390x-linux-gnu-g++
          env GOOS=linux GOARCH=s390x CGO_ENABLED=1 go test -c -o=purego-test-cgo .
          env QEMU_LD_PREFIX=/usr/s390x-linux-gnu qemu-s390x ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
          go env -u CC
          go env -u CXX

  bsd:
    strategy:
      matrix:
        os: ['FreeBSD'] # TODO: Add 'NetBSD' again (#304)
        go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.12', '1.24.13', '1.25.7', '1.26.0']
        exclude:
          # there are no prebuilt download links for these versions of Go for NetBSD
          - os: NetBSD
            go: '1.18.10'
          - os: NetBSD
            go: '1.19.13'
          - os: NetBSD
            go: '1.20.14'
    name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
    runs-on: ubuntu-22.04
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v5
      - name: Run in FreeBSD
        if: matrix.os == 'FreeBSD'
        uses: vmactions/freebsd-vm@v1
        with:
          usesh: true
          prepare: |
            fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
            rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
            chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
          run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
      - name: Run in NetBSD
        if: matrix.os == 'NetBSD'
        uses: vmactions/netbsd-vm@v1
        with:
          usesh: true
          prepare: |
            ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
            mkdir /usr/local
            rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
            chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
          run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh