Problem: - store/test/TestMain checks if DRIVER env var is set - If not set, it runs tests for all 3 drivers (sqlite, mysql, postgres) by spawning child 'go test' processes - This conflicts with t.Parallel() in individual tests - CI workflow didn't set DRIVER, triggering multi-driver execution Solution: - Set DRIVER=sqlite in GitHub Actions workflow - TestMain will run tests once with SQLite driver - Tests run in parallel with t.Parallel() as intended - Avoids spawning child processes and race conditions Why SQLite: - Fastest test execution (no container startup) - Sufficient for CI validation - MySQL/Postgres can be tested locally when needed This fixes the 'table already exists' errors and test flakiness in CI while maintaining parallel execution benefits.
86 lines
2.1 KiB
YAML
86 lines
2.1 KiB
YAML
name: Backend Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "go.mod"
|
|
- "go.sum"
|
|
- "**.go"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
go-static-checks:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 1.25
|
|
cache: true
|
|
cache-dependency-path: go.sum
|
|
|
|
- name: Verify go.mod is tidy
|
|
run: |
|
|
go mod tidy -go=1.25
|
|
git diff --exit-code
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v8
|
|
with:
|
|
version: v2.4.0
|
|
args: --timeout=3m
|
|
|
|
go-tests:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
test-group:
|
|
- store
|
|
- server
|
|
- plugin
|
|
- other
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: 1.25
|
|
cache: true
|
|
cache-dependency-path: go.sum
|
|
|
|
- name: Run tests - ${{ matrix.test-group }}
|
|
run: |
|
|
case "${{ matrix.test-group }}" in
|
|
store)
|
|
go test -v -race -coverprofile=coverage.out -covermode=atomic ./store/...
|
|
;;
|
|
server)
|
|
go test -v -race -coverprofile=coverage.out -covermode=atomic ./server/...
|
|
;;
|
|
plugin)
|
|
go test -v -race -coverprofile=coverage.out -covermode=atomic ./plugin/...
|
|
;;
|
|
other)
|
|
go test -v -race -coverprofile=coverage.out -covermode=atomic \
|
|
./cmd/... ./internal/... ./proto/...
|
|
;;
|
|
esac
|
|
env:
|
|
DRIVER: sqlite # Use SQLite for fastest test execution
|
|
|
|
- name: Upload coverage
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
files: ./coverage.out
|
|
flags: ${{ matrix.test-group }}
|
|
fail_ci_if_error: false
|