-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
110 lines (95 loc) · 2.56 KB
/
Taskfile.yaml
File metadata and controls
110 lines (95 loc) · 2.56 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
version: '3'
silent: true
vars:
FORCE_COLOR: true
LINT_VERSION: v2.6.2
tasks:
default:
desc: Show available tasks
cmd: task --list
# Linting.
lint:
desc: Run linter for Go code
cmds:
- task: _lint:go
vars:
FIX: false
lint:fix:
desc: Run linter and automatically fix issues for Go code
cmds:
- task: _lint:go
vars:
FIX: true
# Testing.
test:
desc: Run all Go tests (unit + integration)
cmds:
- task: _test:go:all
vars:
CI: false
test:ci:
desc: Run all Go tests in CI mode
cmds:
- task: _test:go:all
vars:
CI: true
test:unit:
desc: Run Go tests (unit tests only)
cmds:
- task: _test:go:unit
vars:
CI: false
# Utilities.
clean:
desc: Clean generated files and caches
cmds:
- rm -f coverage.out junit.xml
- go clean -cache
- go clean -testcache
# Internal.
_lint:go:
internal: true
deps: [_deps:golangci-lint]
requires:
vars: [FIX]
cmds:
- golangci-lint run --timeout=10m {{if .FIX}}--fix{{end}} ./pkg/...
_test:go:unit:
internal: true
deps: [_deps:gotestsum]
requires:
vars: [CI]
vars:
TEST_SEED: '{{default (now | unixEpoch) .TEST_SEED}}'
cmds:
- printf "to reproduce{{":"}} TEST_SEED=0x%x task test:unit\n" {{.TEST_SEED}}
- TEST_SEED={{.TEST_SEED}} gotestsum {{if .CI}}--junitfile=junit.xml -- -coverprofile=coverage.out -covermode=atomic{{end}} ./pkg/... -tags="!integration"
_test:go:all:
internal: true
deps: [_deps:gotestsum]
requires:
vars: [CI]
vars:
TEST_SEED: '{{default (now | unixEpoch) .TEST_SEED}}'
cmds:
- printf "to reproduce{{":"}} TEST_SEED=0x%x task test\n" {{.TEST_SEED}}
- TEST_SEED={{.TEST_SEED}} gotestsum {{if .CI}}--junitfile=junit.xml -- -coverprofile=coverage.out -covermode=atomic{{end}} ./pkg/...
_deps:golangci-lint:
internal: true
run: once
desc: Install golangci-lint
cmds:
- |
if [ "$(golangci-lint --version 2> /dev/null | awk '{print $4}')" != "{{.LINT_VERSION}}" ]; then
# Force the linter to use our Go version so it doesn’t downgrade.
GOTOOLCHAIN=$(go env GOVERSION) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@{{.LINT_VERSION}}
fi
_deps:gotestsum:
internal: true
run: once
desc: Install gotestsum
cmds:
- |
if ! command -v gotestsum >/dev/null 2>&1; then
go install gotest.tools/gotestsum@latest
fi