mirror of
https://github.com/agresdominik/ci-pipelines.git
synced 2026-07-21 19:10:54 +00:00
feat(languages): go test pipeline
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
name: Go Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
go-version-file:
|
||||||
|
description: "Path to go.mod for version resolution"
|
||||||
|
type: string
|
||||||
|
default: "go.mod"
|
||||||
|
run-race:
|
||||||
|
description: "Enable race detector"
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
timeout:
|
||||||
|
description: "Test timeout (go test -timeout)"
|
||||||
|
type: string
|
||||||
|
default: "20m"
|
||||||
|
coverage:
|
||||||
|
description: "Upload coverage report as artifact"
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: go test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: ${{ inputs.go-version-file }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
ARGS="-timeout ${{ inputs.timeout }}"
|
||||||
|
if [ "${{ inputs.run-race }}" = "true" ]; then
|
||||||
|
ARGS="$ARGS -race"
|
||||||
|
fi
|
||||||
|
if [ "${{ inputs.coverage }}" = "true" ]; then
|
||||||
|
ARGS="$ARGS -coverprofile=coverage.out -covermode=atomic"
|
||||||
|
fi
|
||||||
|
go test $ARGS ./...
|
||||||
|
|
||||||
|
- name: Upload coverage report
|
||||||
|
if: ${{ inputs.coverage }}
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: coverage-report
|
||||||
|
path: coverage.out
|
||||||
|
retention-days: 7
|
||||||
Reference in New Issue
Block a user