-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
197 lines (170 loc) · 4.34 KB
/
Taskfile.yml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# https://taskfile.dev
version: '3'
env:
BINARY_NAME: hoomy
GO111MODULE: on
GOPROXY: https://proxy.golang.org,direct
# static file dirs
TOOL_DIR: .tool
TMP_DIR: .tmp
vars:
NAME: 'hoomy'
DOCKER: '{{default "docker" .DOCKER}}'
tasks:
default:
desc: Runs the default tasks
cmds:
- task: ci
binny:
internal: true
# desc: Get the binny tool
generates:
- "{{ .TOOL_DIR }}/binny"
status:
- "test -f {{ .TOOL_DIR }}/binny"
cmd: "curl -sSfL https://raw.githubusercontent.com/anchore/binny/main/install.sh | sh -s -- -b .tool"
silent: true
tools:
desc: Install all tools needed for CI and local development
deps: [ binny ]
aliases:
- bootstrap
generates:
- ".binny.yaml"
- "{{ .TOOL_DIR }}/*"
status:
- "{{ .TOOL_DIR }}/binny check -v"
cmd: "{{ .TOOL_DIR }}/binny install -v"
silent: true
update-tools:
desc: Update pinned versions of all tools to their latest available versions
deps: [ binny ]
generates:
- ".binny.yaml"
- "{{ .TOOL_DIR }}/*"
cmd: "{{ .TOOL_DIR }}/binny update -v"
silent: true
list-tools:
desc: List all tools needed for CI and local development
deps: [ binny ]
cmd: "{{ .TOOL_DIR }}/binny list"
silent: true
list-tool-updates:
desc: List all tools that are not up to date relative to the binny config
deps: [ binny ]
cmd: "{{ .TOOL_DIR }}/binny list --updates"
silent: true
dev:
desc: Setup git hooks
cmds:
- ln -s ../../scripts/pre-commit.sh .git/hooks/pre-commit
setup:
desc: Install dependencies
cmds:
- go mod tidy
build:
desc: Build the binary
generates:
- '{{.TOOL_DIR }}/{{.BINARY_NAME}}'
cmds:
- 'go build -o {{.TOOL_DIR}}/{{.BINARY_NAME}} cmd/{{.NAME}}/main.go {{.CLI_ARGS}}'
run:
silent: true
desc: Run the binary
method: none
dir: 'cmd/{{.NAME}}'
sources:
- ./**/*.go
dotenv:
- '.env'
- '.env.dist'
cmds:
- go run . {{.CLI_ARGS}}
help:
desc: Get binary help
method: none
dir: 'cmd/{{.NAME}}'
sources:
- ./**/*.go
cmds:
- go run . --help {{.CLI_ARGS}}
test:
desc: Run tests
dir: 'cmd/{{.NAME}}'
env:
LC_ALL: C
vars:
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}'
SOURCE_FILES: '{{default "./..." .SOURCE_FILES}}'
TEST_PATTERN: '{{default "." .TEST_PATTERN}}'
cmds:
- go test {{.TEST_OPTIONS}} -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -run {{.TEST_PATTERN}} -timeout=5m
cover:
desc: Open the cover tool
dir: 'cmd/{{.NAME}}'
cmds:
- go tool cover -html=coverage.txt
fmt:
desc: gofumpt all code
cmds:
- '{{ .TOOL_DIR }}/gofumpt -w -l .'
lint:go:
desc: Lint the code with golangci-lint
cmds:
- '{{ .TOOL_DIR }}/golangci-lint run ./...'
lint:
desc: Lint all
dir: 'cmd/{{.NAME}}'
cmds:
- task: lint:go
ci:
desc: Run all CI steps
cmds:
- task: tools
- task: setup
- task: fmt
- task: lint
docs:generate:
desc: Generate docs
cmds:
- cp -rf CONTRIBUTING.md www/docs/contributing.md
- cp -rf DEVELOPMENT.md www/docs/development.md
- cp -rf USERS.md www/docs/users.md
- cp -rf SECURITY.md www/docs/security.md
sources:
- DEVELOPMENT.md
- CONTRIBUTING.md
- USERS.md
- SECURITY.md
generates:
- www/docs/development.md
- www/docs/contributing.md
- www/docs/users.md
- www/docs/security.md
docs:serve:
desc: Start documentation server
cmds:
- task: docs:generate
- '{{.DOCKER}} run --rm -p 8000:8000 -v ${PWD}/www:/docs docker.io/squidfunk/mkdocs-material'
docs:build:
desc: Build docs
cmds:
- task: docs:generate
- '{{.DOCKER}} run --rm -v ${PWD}/www:/docs docker.io/squidfunk/mkdocs-material build'
release:
desc: Create a new tag
vars:
NEXT:
sh: svu n
cmds:
- git tag {{.NEXT}}
- echo {{.NEXT}}
- git push origin --tags
goreleaser:snapshot:
desc: Run GoReleaser either in snapshot or release mode
cmds:
- goreleaser release --clean --snapshot
goreleaser:
desc: Run GoReleaser either in snapshot or release mode
cmds:
- goreleaser release --clean