Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: CI

# CI Strategy:
# - Tests run on Linux, macOS, and Windows (cross-platform shared interfaces)
# - Go 1.25+ required (matches go.mod requirement)
# - Pure Go: zero external dependencies (only gputypes)
#
# Branch Strategy (GitHub Flow):
# - main branch: Production-ready code
# - Feature branches: Tested via pull_request trigger
# - Pull requests: Must pass all checks before merge

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
# Build verification - Cross-platform
build:
name: Build - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.25']

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 dependencies
run: go mod download

- name: Verify dependencies
run: go mod verify

- name: Build all packages
run: go build ./...

# Unit tests - Cross-platform
test:
name: Test - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.25']

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 dependencies
run: go mod download

- name: Run go vet
if: matrix.os == 'ubuntu-latest'
run: go vet ./...

- name: Run tests with race detector
shell: bash
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-gpucontext

# Linting
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
with:
version: latest
args: --timeout=5m

# Code formatting check
formatting:
name: 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"

# Dependency freshness check
# Uses go-mod-outdated (https://github.com/psampaz/go-mod-outdated)
deps:
name: Dependencies
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: Install go-mod-outdated
run: go install github.com/psampaz/go-mod-outdated@latest

- name: Check direct dependencies for updates
run: |
echo "## Direct Dependencies with Updates"
OUTDATED=$(go list -u -m -json all 2>/dev/null | go-mod-outdated -update -direct || true)
if [ -n "$OUTDATED" ]; then
echo "$OUTDATED"
echo "::warning::Some direct dependencies have updates available"
else
echo "All direct dependencies are up to date!"
fi

- name: Check ecosystem dependencies
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "## Ecosystem Dependencies"
WARNINGS=0

check_dep() {
local DEP=$1 REPO=$2
LOCAL=$(grep "$DEP" go.mod 2>/dev/null | grep -v "^module" | awk '{print $2}')
[ -z "$LOCAL" ] && return 0

LATEST=$(gh release view --repo "$REPO" --json tagName -q '.tagName' 2>/dev/null || echo "")
[ -z "$LATEST" ] && { echo "⚠️ $DEP: $LOCAL (cannot verify)"; return 0; }

if [ "$LOCAL" = "$LATEST" ]; then
echo "✅ $DEP: $LOCAL"
else
echo "❌ $DEP: $LOCAL → $LATEST available"
WARNINGS=$((WARNINGS + 1))
fi
}

check_dep "github.com/gogpu/gputypes" "gogpu/gputypes"

[ $WARNINGS -gt 0 ] && echo "::warning::$WARNINGS ecosystem dep(s) outdated"
exit 0
142 changes: 142 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# GolangCI-Lint v2 Configuration for gogpu/gpucontext - Shared Interfaces
# Documentation: https://golangci-lint.run/docs/configuration/

version: "2"

run:
timeout: 5m
tests: true

linters:
enable:
# Code quality and complexity
- gocyclo # Check cyclomatic complexity
- gocognit # Check cognitive complexity
- funlen # Check function length
- maintidx # Maintainability index
- cyclop # Check cyclomatic complexity (alternative)
- nestif # Reports deeply nested if statements

# Bug detection
- govet # Standard Go vet
- staticcheck # Comprehensive static analysis
- errcheck # Check that errors are handled
- errorlint # Check error wrapping
- gosec # Security issues
- nilnil # Check that functions don't return nil both ways
- nilerr # Check nil error returns
- ineffassign # Detect ineffectual assignments

# Code style and consistency
- misspell # Check for misspelled words
- whitespace # Check for trailing whitespace
- unconvert # Remove unnecessary type conversions
- unparam # Detect unused function parameters

# Naming conventions
- errname # Check error naming conventions
- revive # Fast, configurable, extensible linter

# Performance
- prealloc # Find slice declarations that could be preallocated
- makezero # Find slice declarations with non-zero initial length

# Code practices
- goconst # Find repeated strings that could be constants
- gocritic # Comprehensive code checker
- goprintffuncname # Check printf-like function names
- nolintlint # Check nolint directives are used correctly
- nakedret # Checks for naked returns

# Additional quality checkers
- dupl # Detect duplicate code
- dogsled # Check for assignments with too many blank identifiers
- durationcheck # Check for two durations multiplied together

settings:
govet:
enable:
- copylocks
disable:
- fieldalignment

gocyclo:
min-complexity: 20

cyclop:
max-complexity: 20

funlen:
lines: 120
statements: 60

gocognit:
min-complexity: 30

misspell:
locale: US

nestif:
min-complexity: 4

goconst:
min-occurrences: 4
ignore-string-values:
- "Unknown"

revive:
rules:
- name: var-naming
- name: error-return
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id

gocritic:
enabled-tags:
- diagnostic
- style
- performance

disabled-checks:
- commentFormatting
- whyNoLint
- unnamedResult
- commentedOutCode
- octalLiteral
- paramTypeCombine

settings:
hugeParam:
sizeThreshold: 256

exclusions:
rules:
# Test files - allow more flexibility
- path: _test\.go
linters:
- gocyclo
- cyclop
- funlen
- maintidx
- errcheck
- gosec
- goconst
- dupl
- gocognit

issues:
max-issues-per-linter: 0
max-same-issues: 0
new: false
4 changes: 0 additions & 4 deletions device_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ type DeviceProvider interface {
// Some implementations may not expose the adapter.
Adapter() Adapter
}

// DeviceHandle is an alias for DeviceProvider for backward compatibility.
// Deprecated: Use DeviceProvider instead.
type DeviceHandle = DeviceProvider
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// - DeviceProvider: Interface for providing GPU device and queue
// - EventSource: Interface for window/input events (keyboard, mouse)
// - TouchEventSource: Interface for touch input (multi-touch, gestures)
// - PointerEventSource: Interface for unified pointer events (W3C Level 3)
// - ScrollEventSource: Interface for detailed scroll events
// - Texture: Minimal interface for GPU textures
// - TextureDrawer: Interface for drawing textures (2D rendering)
// - TextureCreator: Interface for creating textures from pixel data
Expand Down
Loading
Loading