-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTaskfile.yaml
82 lines (74 loc) · 2.23 KB
/
Taskfile.yaml
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
version: "3"
vars:
BUILD_ROOT: "{{ .ROOT_DIR }}/build"
GO_VERSION: 1.23.1
GO_BUILD_ROOT: '{{.BUILD_ROOT}}/go/{{.GO_VERSION}}'
MODULES:
sh: find . -maxdepth 2 -name go.mod -execdir pwd \;
PATH_PREFIX: PATH={{.BUILD_ROOT}}/bin:{{.GO_BUILD_ROOT}}/bin:{{.BUILD_ROOT}}/bin/go:$PATH GOBIN={{ .BUILD_ROOT }}/bin/go GOROOT=
includes:
install: taskfiles/install.yaml
proto: taskfiles/proto.yaml
tasks:
lint:
desc: Lint all Go code
deps: ['install:golangci-lint']
cmds:
- for: { var: MODULES }
task: lint:dir
vars:
DIRECTORY: '{{.ITEM}}'
lint:dir:
label: lint:dir {{ .DIRECTORY }}
desc: Lint Go code on the provided directory
deps: ['install:golangci-lint']
vars:
DIRECTORY: '{{ .DIRECTORY }}'
dir: '{{.DIRECTORY}}'
cmds:
- '{{ .BUILD_ROOT }}/bin/go/golangci-lint run --config {{ .ROOT_DIR }}/.golangci.yaml --timeout 10m ./...'
fmt:
desc: Run all formatters
cmds:
- for: { var: MODULES }
task: fmt:dir
vars:
DIRECTORY: '{{.ITEM}}'
fmt:dir:
label: fmt:dir {{ .DIRECTORY }}
desc: Run all of the Go formatters on the provided directory, excluding any generated folders
deps:
- 'install:go'
- 'install:gofumpt'
- 'install:goimports'
- 'install:gci'
vars:
DIRECTORY: '{{ .DIRECTORY }}'
sources:
- '{{ .DIRECTORY }}/**/*.go'
cmds:
- '{{ .BUILD_ROOT }}/bin/go/goimports -l -w -local "github.com/redpanda-data/common-go" {{.DIRECTORY}}'
- '{{ .BUILD_ROOT }}/bin/go/gofumpt -l -w {{.DIRECTORY}}'
- '{{ .BUILD_ROOT }}/bin/go/gci write -s default -s standard -s "prefix(github.com/redpanda-data/common-go)" {{.DIRECTORY}}'
- if [[ $CI == "true" ]]; then git --no-pager diff --exit-code; fi
test:
desc: Run all tests
deps:
- 'fmt'
- 'lint'
cmds:
- for: { var: MODULES }
task: test:dir
vars:
DIRECTORY: '{{.ITEM}}'
test:dir:
label: test:dir {{ .DIRECTORY }}
desc: Run Go tests in the provided directory
deps:
- 'install:go'
vars:
DIRECTORY: '{{ .DIRECTORY }}'
dir: '{{.DIRECTORY}}'
cmds:
- |
{{ .PATH_PREFIX }} go test -v -race {{.CLI_ARGS | default "./..." }}