go-devops/.forgejo/workflows/go-test.yml
Snider cd7e728280 feat: absorb core/ci commands + add reusable workflows
Merge core/ci repo into go-devops:
- cmd/ci: release publish, init, changelog, version commands
- cmd/sdk: API diff and OpenAPI validation commands

Add reusable Forgejo Actions workflows:
- security-scan.yml: govulncheck + gitleaks + trivy
- go-test.yml: test with optional race/coverage
- docker-publish.yml: build + push to registry

Other repos can call these via:
  uses: core/go-devops/.forgejo/workflows/security-scan.yml@main

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-21 21:01:46 +00:00

45 lines
1.1 KiB
YAML

# Reusable Go test workflow
# Usage: uses: core/go-devops/.forgejo/workflows/go-test.yml@main
name: Go Test
on:
workflow_call:
inputs:
go-version:
description: Go version to use
type: string
default: '1.26'
race:
description: Enable race detector
type: boolean
default: false
coverage:
description: Generate coverage report
type: boolean
default: false
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: Run tests
run: |
FLAGS="-v"
if [ "${{ inputs.race }}" = "true" ]; then
FLAGS="$FLAGS -race"
fi
if [ "${{ inputs.coverage }}" = "true" ]; then
FLAGS="$FLAGS -coverprofile=coverage.out"
fi
go test $FLAGS ./...
- name: Coverage summary
if: inputs.coverage
run: go tool cover -func=coverage.out | tail -1