Testing Workflow¶
The test.yml workflow runs Go tests with comprehensive options.
Usage¶
jobs:
test:
uses: go-gamma/actions/.github/workflows/test.yml@v1
with:
go-version: '1.24'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
What It Does¶
- Checkout - Clones your repository
- Setup Go - Installs Go with caching
- Download deps - Runs
go mod download - go vet - Static analysis
- go test - Runs tests with options
- Coverage - Uploads to Codecov
Test Command¶
The workflow runs:
Inputs¶
| Input | Type | Default | Description |
|---|---|---|---|
go-version | string | '1.24' | Go version |
go-version-file | string | '' | Path to go.mod |
working-directory | string | '.' | Code directory |
race-detection | boolean | true | Enable -race |
test-flags | string | '-v -shuffle=on' | Additional flags |
upload-coverage | boolean | true | Upload to Codecov |
Outputs¶
| Output | Description |
|---|---|
coverage-percentage | Test coverage as percentage |
Examples¶
With Custom Flags¶
jobs:
test:
uses: go-gamma/actions/.github/workflows/test.yml@v1
with:
go-version: '1.24'
test-flags: '-v -shuffle=on -count=1 -timeout=30m'
Without Race Detection¶
jobs:
test:
uses: go-gamma/actions/.github/workflows/test.yml@v1
with:
go-version: '1.24'
race-detection: false # Faster, less thorough
Using Coverage Output¶
jobs:
test:
uses: go-gamma/actions/.github/workflows/test.yml@v1
with:
go-version: '1.24'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
check-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- run: |
echo "Coverage: ${{ needs.test.outputs.coverage-percentage }}%"
Race Detection¶
The -race flag enables Go's race detector, which finds data races:
Performance Impact
Race detection adds ~2-10x overhead. For large test suites, consider disabling on non-main branches.