-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (59 loc) · 1.66 KB
/
Copy pathgo-test.yml
File metadata and controls
63 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Go Test
on:
workflow_call:
inputs:
path:
description: 'Working directory (path to module root)'
required: false
default: '.'
type: string
go_version:
description: 'Go version to use'
required: false
default: 'stable'
type: string
race:
description: 'Enable race detector (-race)'
required: false
default: false
type: boolean
run:
description: 'Test filter passed to -run'
required: false
default: ''
type: string
args:
description: 'Extra arguments passed to go test'
required: false
default: ''
type: string
runner:
description: 'Runner label'
required: false
default: 'self-hosted'
type: string
jobs:
go-test:
runs-on: ${{ inputs.runner }}
defaults:
run:
working-directory: ${{ inputs.path }}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: ${{ inputs.go_version }}
cache-dependency-path: ${{ inputs.path }}/go.sum
- name: Test
env:
RACE: ${{ inputs.race }}
RUN_FILTER: ${{ inputs.run }}
EXTRA_ARGS: ${{ inputs.args }}
run: |
ARGS=()
[ "${RACE}" == "true" ] && ARGS+=(-race)
[ -n "${RUN_FILTER}" ] && ARGS+=(-run "${RUN_FILTER}")
[ -n "${EXTRA_ARGS}" ] && ARGS+=(${EXTRA_ARGS})
go test "${ARGS[@]}" ./...