Repository navigation
Expand file tree
/
Copy pathTaskfile.dist.yaml
More file actions
308 lines (308 loc) · 8.57 KB
/
Copy pathTaskfile.dist.yaml
File metadata and controls
308 lines (308 loc) · 8.57 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# Taskfile.dist.yaml
#
# Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.
# https://taskfile.dev/installation/
#
# To see all available tasks:
# $ task --list
#
version: '3'
vars:
BINNAME: dist/defacto2-server # build output, binary filename (without any extensions)
dotenv: ['./init/.env.local'] # INFO: some IDEs hide the file, it is in the repo root: "init/.env.local"
tasks:
default:
aliases:
- '_'
desc: 'Task runner for the Defacto2 web server source code.'
cmds:
- task --list-all
silent: true
_init:
silent: false
desc: 'Initialize this project for the first time after a git clone.'
cmds:
- cmd: go install github.com/goreleaser/goreleaser/v2@latest
- cmd: go install github.com/aarondl/sqlboiler/v4@latest
- cmd: go install github.com/aarondl/sqlboiler/v4/drivers/sqlboiler-psql@latest
- cmd: go mod tidy
assets:
desc: 'Build, compile and compress the web serve CSS and JS assets.'
cmds:
- echo "Building assets..."
- go run -modfile=runner/go.mod runner/runner.go
- echo "Done!"
aliases:
- 'js'
build:
desc: 'Build the binary of the web server.'
deps: [assets]
cmds:
- cmd: echo "Building..."
- cmd: go build -o {{.BINNAME}} -v server.go
platforms: [linux, darwin, freebsd]
aliases:
- 'bin'
build-release:
aliases:
- 'br'
desc: 'Build the release package of the web server embeded with the git version tag.'
deps: [assets]
cmds:
- cmd: echo "Git status results:"
- cmd: git status
- cmd: echo "Building snapshot..."
- cmd: goreleaser build --clean --config init/.goreleaser.yaml
- cmd: echo "Done!"
build-snapshot:
aliases:
- 'bs'
desc: 'Build the release package of the web server without a git version tag.'
deps: [assets]
cmds:
- cmd: echo "Building snapshot..."
- cmd: goreleaser build --snapshot --clean --config init/.goreleaser.yaml
- cmd: echo "Done!"
build-race:
desc: 'Build the binary of the web server with race detection.'
deps: [assets]
cmds:
- cmd: echo "Building with race conditions..."
- cmd: go build -o {{.BINNAME}} -race -v server.go
platforms: [linux, darwin, freebsd]
- cmd: ./{{.BINNAME}} --version
platforms: [linux, darwin]
- cmd: echo "Done!"
aliases:
- 'race'
built-run:
desc: 'Run the previously built binary.'
cmds:
- ./{{.BINNAME}}
platforms: [linux, darwin, freebsd]
aliases:
- 'run'
doc:
aliases:
- 'd'
desc: 'Generate and browse the application module documentation.'
cmds:
- cmd: go tool pkgsite -http localhost:8090
silent: true
lints:
aliases:
- 'ls'
silent: false
desc: Runs the formatters and linters over the source code.
ignore_error: true
cmds:
- cmd: clear
platforms: [linux, darwin, freebsd]
- cmd: gci write ./..
platforms: [linux]
- cmd: go tool gofumpt -l -w -extra .
- cmd: go fix ./...
- cmd: pnpm exec eslint assets/js/
- cmd: pnpm exec spectral lint public/json/openapi.json
- cmd: pnpm exec stylelint --fix assets/css/*.css
- cmd: golangci-lint run -c init/.golangci.yaml
lint:
aliases:
- 'l'
silent: false
desc: Lint the Go source code.
ignore_error: true
cmds:
- cmd: clear
platforms: [linux, darwin, freebsd]
- cmd: golangci-lint run -c init/.golangci.yaml
lint-h:
aliases:
- 'lh'
silent: false
desc: Lint the HTML and template source code.
ignore_error: true
cmds:
- cmd: clear
platforms: [linux, darwin, freebsd]
- cmd: pnpm exec hihtml --check-code --input view/
lint-js:
aliases:
- 'lj'
silent: false
desc: Lint the CSS and JS source code.
ignore_error: true
cmds:
- cmd: clear
platforms: [linux, darwin, freebsd]
- cmd: pnpm exec eslint assets/js/
- cmd: pnpm exec spectral lint public/json/openapi.json
- cmd: pnpm exec stylelint --fix assets/css/*.css
nil:
aliases:
- 'n'
desc: 'Run the static analysis techniques to catch Nil dereferences.'
cmds:
# ignore server/model package because the database uses nil values
# skip tests for performance
- go tool nilaway -test=false -exclude-pkgs=github.com/Defacto2/server/model ./...
pkg-list:
aliases:
- 'list'
silent: false
desc:
List the updates for the web server dependencies.
# To update run, go get github.com/example/package@latest && go mod tidy.
cmds:
- |
go list -u -m $(go list -m -f '{{`{{if not .Indirect}}{{.Path}}{{end}}`}}' all)
pkg-js:
aliases:
- 'js'
desc: Update to the latest JavaScript dependencies.
cmds:
- cmd: pnpm up --interactive --latest
pkg-patch:
aliases:
- 'patch'
silent: false
desc: Update and apply patches to the web server dependencies.
cmds:
- cmd: go get -u=patch -x
- cmd: go mod verify
- cmd: go mod tidy
pkg-update:
aliases:
- 'update'
silent: false
desc: Update the web server dependencies.
cmds:
- cmd: go get -u -x
- cmd: go get go.uber.org/nilaway/cmd/nilaway@latest
- cmd: go mod verify
- cmd: go mod tidy
serve:
aliases:
- 'http'
desc: 'Run the internal web server in development mode with live reload.'
cmds:
- task: serve-linux
serve-https:
aliases:
- 'https'
desc: 'Run the internal web server in development http and https mode with live reload.'
cmds:
- task: serve-linux-x2
serve-fix:
aliases:
- 'fix'
desc: 'Run the internal web server with the fix flag.'
cmds:
- cmd: go run server.go fix
serve-prod:
aliases:
- 'prod'
desc: 'Run the internal web server with live reload.'
cmds:
- task: serve-air-prod
serve-linux:
internal: true
platforms: [linux, freebsd, darwin]
env:
D2_PROD_MODE: false
PS_HOST: localhost
deps: [assets]
cmds:
- go tool air -c init/.air.toml
serve-linux-x2:
internal: true
platforms: [linux, freebsd, darwin]
env:
D2_PROD_MODE: false
PS_HOST: localhost
D2_TLS_PORT: 2323
deps: [assets]
cmds:
- go tool air -c init/.air.toml
serve-air-prod:
internal: true
platforms: [darwin, linux, freebsd]
env:
D2_PROD_MODE: true
cmds:
- go tool air -c init/.air.toml
spell:
aliases:
- 'sc'
desc: 'Run the spell checker on the markdown tidbits.'
cmds:
- cmd: clear
platforms: [linux, darwin, freebsd]
- cmd: find public/md/tidbit/ -name "*.md" | xargs pnpm exec mdspell --report --ignore-numbers --ignore-acronyms --en-us
test:
aliases:
- 't'
desc: 'Run the test suite.'
cmds:
#- set -o pipefail && go test ./... -json | tparse -all
- go test -count 1 ./...
testr:
aliases:
- 'tr'
desc: 'Run the test suite with the slower race detection.'
cmds:
#- set -o pipefail && go test ./... -json | tparse -all
- go test -count 1 -race ./...
testc:
aliases:
- 'tc'
desc: 'Run the test suite with coverage output to the browser.'
cmds:
- go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out
testf:
aliases:
- 'tf'
desc: 'Run each fuzz test for 1 minute.'
cmds:
- go test -fuzz=FuzzSearch -fuzztime=1m
- go test -fuzz=FuzzSnippet -fuzztime=1m
- go test -fuzz=FuzzAdd -fuzztime=1m
testb:
aliases:
- 'tb'
desc: 'Run the benchmark suite.'
cmds:
- go test -run=^$ -bench=. ./...
testp:
aliases:
- 'tm'
desc: 'Run the benchmark suite with both CPU and memory allocations.'
cmds:
- go test -run=^$ -bench=. -benchmem ./...
testbf:
aliases:
- 'tbf'
desc: 'Run the benchmark suite with fail fast.'
cmds:
- go test -run=^$ -bench=. -failfast ./...
testimg:
desc: 'Generate image test assets for a visual confirmation.'
cmds:
- echo "Building assets..."
- go run internal/runner/runner.go
- echo "Check the temporary working directory for the images"
aliases:
- 'img'
version:
aliases:
- 'ver'
silent: false
desc: Print the versions of the build and compiler tools.
ignore_error: true
cmds:
- cmd: go version
- cmd: go tool gofumpt --version
- cmd: task --version
- cmd: golangci-lint --version
- cmd: goreleaser --version
- cmd: go tool air -v