-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
110 lines (103 loc) 路 2.52 KB
/
Copy pathTaskfile.yml
File metadata and controls
110 lines (103 loc) 路 2.52 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
# https://taskfile.dev
version: "3"
dotenv:
- dev.env.sh
- .env
env:
API_BUILD_TIME:
# https://stackoverflow.com/a/7216394
sh: date -u +"%Y-%m-%dT%H:%M:%S"
vars:
DOCKER: '{{if eq OS "linux"}}sudo {{end}}docker'
COMPOSE: "{{.DOCKER}} compose --env-file=.env"
tasks:
install:gofumpt:
status:
- which gofumpt
preconditions:
- sh: which go
msg: "please, install go"
cmds:
# https://github.com/mvdan/gofumpt
- go install mvdan.cc/gofumpt@latest
install:golangci-lint:
status:
- test -f ./bin/golangci-lint
- ./bin/golangci-lint --version | grep -F '2.12.2'
cmds:
# https://golangci-lint.run/welcome/install/#binaries
- >
curl -sSfL
https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh
| sh -s -- -b ./bin v2.12.2
docker:build:
desc: build dev docker image
aliases: [build]
preconditions:
- sh: which docker
msg: "please, install docker"
cmds:
- "{{.COMPOSE}} build --build-arg BUILD_TIME=$API_BUILD_TIME {{.CLI_ARGS}}"
docker:up:
desc: run dev docker containers
aliases: [up]
cmds:
- "{{.COMPOSE}} up {{.CLI_ARGS}}"
docker:down:
desc: stop dev docker containers
aliases: [down]
cmds:
- "{{.COMPOSE}} down {{.CLI_ARGS}}"
# Go commands
serve:
desc: run the dev server
cmds:
- go run ./bin/serve
stock:
desc: see how many units of each item were bought
cmds:
- go run ./bin/stock
orders:
desc: list unfulfilled orders
cmds:
- go run ./bin/orders
token:
desc: generate a new auth token
cmds:
- >
curl -H "Content-Type: application/json"
http://localhost:$API_PORT/dev/token?email=mail@orsinium.dev
| cut -d'"' -f 16
format:
desc: run all code formatters
cmds:
- task: install:gofumpt
- gofumpt -w .
- go mod edit -fmt
- go mod tidy
lint:golangci-lint:
cmds:
- task: install:golangci-lint
- ./bin/golangci-lint run --timeout 120s
lint:govulncheck:
cmds:
- task: install:govulncheck
- govulncheck ./...
lint:
desc: run all linters
cmds:
- task: lint:golangci-lint
# - task: lint:govulncheck
test:
desc: run all tests
cmds:
- go test {{ .CLI_ARGS | default "-count=1 -cover -timeout 10s ./..." }}
all:
desc: run all code formatters, linters, and tests
cmds:
- task: format
- task: lint
- task: test
default:
cmds:
- task: all