-
Notifications
You must be signed in to change notification settings - Fork 2
197 lines (171 loc) · 5.34 KB
/
test.yml
File metadata and controls
197 lines (171 loc) · 5.34 KB
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
name: Tests
# Testing Strategy:
# - Build verification on Linux, macOS, and Windows (cross-platform library)
# - WebGPU bindings via goffi + wgpu-native
# - Go 1.25+ required (matches go.mod requirement)
# - Dependencies: goffi, golang.org/x/sys
#
# NOTE: GPU tests require wgpu-native DLL and actual GPU hardware.
# Full GPU tests are skipped in CI - only math tests and build verification run.
#
# Branch Strategy (Git Flow):
# - feature/** branches: Development work
# - release/** branches: Pre-release testing
# - hotfix/** branches: Critical bug fixes
# - develop branch: Integration branch
# - main branch: Production-ready code only
# - Pull requests: Must pass all checks before merge
on:
push:
branches:
- main
- develop
- 'feature/**'
- 'release/**'
- 'hotfix/**'
pull_request:
branches:
- main
- develop
jobs:
# Unit tests - Cross-platform
unit-tests:
name: Unit Tests - ${{ matrix.os }} - Go ${{ matrix.go-version }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
id-token: write # Required for Codecov OIDC tokenless upload
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest] # macos-latest = ARM64 (Apple Silicon)
go-version: ['1.25'] # Match go.mod requirement
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Download wgpu-native
shell: bash
env:
WGPU_VERSION: "v27.0.4.0"
run: |
set -e
case "${{ matrix.os }}" in
ubuntu-latest)
ASSET="wgpu-linux-x86_64-release.zip"
LIB_NAME="libwgpu_native.so"
;;
macos-latest)
ASSET="wgpu-macos-aarch64-release.zip"
LIB_NAME="libwgpu_native.dylib"
;;
windows-latest)
ASSET="wgpu-windows-x86_64-msvc-release.zip"
LIB_NAME="wgpu_native.dll"
;;
esac
echo "Downloading wgpu-native ${WGPU_VERSION} (${ASSET})..."
curl -fsSL "https://github.com/gfx-rs/wgpu-native/releases/download/${WGPU_VERSION}/${ASSET}" -o wgpu.zip
unzip -o wgpu.zip -d wgpu-native
find wgpu-native -name "${LIB_NAME}" -exec cp {} . \;
ls -la "${LIB_NAME}"
echo "WGPU_NATIVE_PATH=$PWD/${LIB_NAME}" >> $GITHUB_ENV
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run go vet
if: matrix.os == 'ubuntu-latest'
run: CGO_ENABLED=0 go vet ./wgpu/...
- name: Build library
shell: bash
run: |
if [ "${{ matrix.os }}" != "windows-latest" ]; then
CGO_ENABLED=0 go build -v ./wgpu/...
else
go build -v ./...
fi
- name: Build examples (Windows only)
if: matrix.os == 'windows-latest'
run: go build -v ./examples/...
- name: Run tests (no GPU in CI)
shell: bash
run: |
if [ "${{ matrix.os }}" != "windows-latest" ]; then
CGO_ENABLED=0 go test -v -coverprofile=coverage.txt -covermode=atomic ./wgpu/... -run "Mat4|Vec3|StructSizes|CheckInit|WGPUError|Fuzz|NullGuard"
else
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./wgpu/... -run "Mat4|Vec3|StructSizes|CheckInit|WGPUError|Fuzz|NullGuard"
fi
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.25'
uses: codecov/codecov-action@v5
with:
use_oidc: true
slug: go-webgpu/webgpu
files: ./coverage.txt
flags: unittests
name: codecov-webgpu
fail_ci_if_error: false
verbose: true
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
env:
CGO_ENABLED: 0
with:
version: latest
args: --timeout=5m ./wgpu/...
# Formatting check
formatting:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "ERROR: The following files are not formatted:"
gofmt -l .
echo ""
echo "Run 'go fmt ./...' to fix formatting issues."
exit 1
fi
echo "All files are properly formatted ✓"
# Benchmarks (informational only)
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
continue-on-error: true # Don't fail CI on benchmark failures
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true
- name: Run benchmarks
run: |
echo "=== Math Benchmarks ==="
CGO_ENABLED=0 go test -bench=Benchmark -benchmem ./wgpu/... -run "^$" || true
echo ""
echo "Note: GPU benchmarks require wgpu-native and are skipped in CI"