-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
138 lines (122 loc) · 3.78 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
version: "3"
includes:
tools:
taskfile: tools/Taskfile.yaml
dir: tools
vars:
GOIMPORTS_REVISER_COMPANY_PREFIXES: ""
GO_SRC_DIR: .
GO_TOOLS_FILE: tools/tools.go
GO_ENTRY_POINT: cmd/human-data-enricher
tasks:
# ---------------------------------------------------------------------------- #
# Actions #
# ---------------------------------------------------------------------------- #
# ----------------------------------- lint ----------------------------------- #
lint:
desc: "Lint and format source code"
aliases: ["l"]
vars:
SRC_DIR: '{{default "." .GO_SRC_DIR}}'
COMPANY_PREFIXES: '{{default "" .GOIMPORTS_REVISER_COMPANY_PREFIXES}}'
cmd:
task: _lint
vars:
SRC_DIR: "{{.SRC_DIR}}"
COMPANY_PREFIXES: "{{.COMPANY_PREFIXES}}"
DOCKERFILE: "{{.CONTAINER_FILE}}"
# ----------------------------------- build ---------------------------------- #
build:
desc: "Build source code into executable"
aliases: ["b"]
vars:
SRC_DIR: '{{default "." .GO_SRC_DIR}}'
_ENTRY_POINT: '{{default "./" .GO_ENTRY_POINT}}'
ENTRY_POINT: '{{if (not (hasPrefix "./" ._ENTRY_POINT))}}{{(printf "./%s" ._ENTRY_POINT)}}{{else}}{{._ENTRY_POINT}}{{end}}'
cmd:
task: _build
vars:
SRC_DIR: "{{.SRC_DIR}}"
ENTRY_POINT: "{{.ENTRY_POINT}}"
build:dry:
desc: "Try to build the application without creating any executables"
aliases: ["bd"]
cmd:
task: _build:dry
# ---------------------------------------------------------------------------- #
# Lint action #
# ---------------------------------------------------------------------------- #
lint:golangci:
internal: true
requires:
vars: ["SRC_DIR"]
dir: "{{.SRC_DIR}}"
cmd: golangci-lint run
lint:goimports-reviser:
internal: true
requires:
vars: ["SRC_DIR", "COMPANY_PREFIXES"]
cmd: GO_SRC_PATH={{.SRC_DIR}} COMPANY_PREFIXES={{.COMPANY_PREFIXES}} ./script/goimports-reviser.sh
lint:gofumpt:
internal: true
requires:
vars: ["SRC_DIR"]
cmd: gofumpt -l -w -extra {{.SRC_DIR}}
lint:golines:
internal: true
requires:
vars: ["SRC_DIR"]
cmd: SRC_PATH={{.SRC_DIR}} ./script/golines.sh
lint:go-vet:
internal: true
requires:
vars: ["SRC_DIR"]
cmd: go vet {{.SRC_DIR}}/...
__lint:
internal: true
requires:
vars: ["SRC_DIR", "COMPANY_PREFIXES", "DOCKERFILE"]
deps:
- task: "lint:golangci"
vars:
SRC_DIR: "{{.SRC_DIR}}"
- task: "lint:goimports-reviser"
vars:
SRC_DIR: "{{.SRC_DIR}}"
COMPANY_PREFIXES: "{{.COMPANY_PREFIXES}}"
- task: "lint:gofumpt"
vars:
SRC_DIR: "{{.SRC_DIR}}"
- task: "lint:go-vet"
vars:
SRC_DIR: "{{.SRC_DIR}}"
- task: "lint:golines"
vars:
SRC_DIR: "{{.SRC_DIR}}"
_lint:
internal: true
requires:
vars: ["SRC_DIR", "COMPANY_PREFIXES", "DOCKERFILE"]
sources:
- "{{.SRC_DIR}}/**/*.go"
cmd:
task: __lint
vars:
SRC_DIR: "{{.SRC_DIR}}"
COMPANY_PREFIXES: "{{.COMPANY_PREFIXES}}"
DOCKERFILE: "{{.DOCKERFILE}}"
# ---------------------------------------------------------------------------- #
# Build action #
# ---------------------------------------------------------------------------- #
_build:
internal: true
requires:
vars: ["ENTRY_POINT"]
generates:
- "main"
sources:
- "{{.SRC_DIR}}/**/*.go"
cmd: go build -v -o main {{.ENTRY_POINT}}
_build:dry:
internal: true
cmd: go build -v ./...