Skip to content

ci: upgrade Codecov to v5 with OIDC tokenless upload #43

ci: upgrade Codecov to v5 with OIDC tokenless upload

ci: upgrade Codecov to v5 with OIDC tokenless upload #43

Workflow file for this run

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"