Skip to content

Commit ae941b7

Browse files
authored
Add a basic reusable go test workflow (#20)
Add a basic reusable go test workflow that runs go test with and without race detector with options to pick which.
1 parent 95f64ee commit ae941b7

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/go-test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Go
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
go-version:
7+
required: false
8+
type: string
9+
default: 'stable'
10+
test:
11+
required: false
12+
type: boolean
13+
default: true
14+
race:
15+
required: false
16+
type: boolean
17+
default: true
18+
19+
jobs:
20+
test:
21+
name: ${{ matrix.name }}
22+
runs-on: ubuntu-latest
23+
if: inputs.test || inputs.race
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- name: Test
29+
flags: ''
30+
enabled: ${{ inputs.test }}
31+
- name: Test (race)
32+
flags: '-race'
33+
enabled: ${{ inputs.race }}
34+
exclude:
35+
- enabled: false
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v6
39+
- name: Set up Go
40+
uses: actions/setup-go@v6
41+
with:
42+
go-version: '${{ inputs.go-version }}'
43+
- name: Run repo-specific setup
44+
uses: ./.github/actions/go-test-setup
45+
if: hashFiles('./.github/actions/go-test-setup') != ''
46+
- name: Run tests
47+
run: go test ${{ matrix.flags }} ./...

0 commit comments

Comments
 (0)