-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
115 lines (105 loc) · 3.7 KB
/
Taskfile.yaml
File metadata and controls
115 lines (105 loc) · 3.7 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
111
112
113
114
115
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 ! -path "*/proto/*" -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
build: taskfiles/build.yaml
tasks:
check-project-meta:
desc: Check project metadata files (licenses, README, etc)
cmds:
- for: { var: MODULES }
task: check-project-meta:dir
vars:
DIRECTORY: '{{.ITEM}}'
# Specal snowflake proto directory
- task: check-project-meta:dir
vars:
DIRECTORY: 'proto'
check-project-meta:dir:
label: check-project-meta:dir {{ .DIRECTORY }}
desc: Check project metadata files (licenses, README, etc) in the provided directory
vars:
DIRECTORY: '{{ .DIRECTORY }}'
BASE:
sh: 'basename {{ .DIRECTORY }}'
dir: '{{.DIRECTORY}}'
cmds:
- '[[ -f "README.md" ]] || (echo "README.md is missing in \"{{ .BASE }}\"" && exit 1)'
- '[[ -f "LICENSE" ]] || (echo "LICENSE is missing in \"{{ .BASE }}\"" && exit 1)'
- 'cat ../.licenseupdater.yaml | grep "directory: {{ .BASE }}" >/dev/null 2>&1 || (echo "License information for \"{{ .BASE }}\" is missing in .licenseupdater.yaml" && exit 1)'
- 'cat ../.github/CODEOWNERS | grep "/{{ .BASE }}/" >/dev/null 2>&1 || (echo "CODEOWNERS entry for \"/{{ .BASE }}/\" is missing in .github/CODEOWNERS" && exit 1)'
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
deps: ['build:licenseupdater', 'install:gomplate']
cmds:
- '{{ .BUILD_ROOT }}/bin/licenseupdater'
- '{{ .BUILD_ROOT }}/bin/go/gomplate -d licenses=.licenseupdater.yaml -f README.md.tmpl > README.md'
- for: { var: MODULES }
task: fmt:dir
vars:
DIRECTORY: '{{.ITEM}}'
- task: fmt:dir
vars:
DIRECTORY: 'kube/example'
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 "./..." }}