-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
105 lines (89 loc) · 2.77 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
version: '3'
vars:
APP_NAME: wombat
DOCKER_IMAGE: "ghcr.io/wombatwisdom/{{.APP_NAME}}"
TARGET_DIR: ./target
TARGET_BIN: "{{.TARGET_DIR}}/bin"
LD_FLAGS: -w -s
GO_FLAGS: ""
GOMAXPROCS: 1
DATE:
sh: 'date +"%Y-%m-%dT%H:%M:%SZ"'
VERSION:
sh: git describe --tags 2> /dev/null || echo "v0.0.0"
VER_CUT:
sh: echo {{.VERSION}} | cut -c2-
VER_MAJOR:
sh: echo {{.VER_CUT}} | cut -d. -f1
VER_MINOR:
sh: echo {{.VER_CUT}} | cut -d. -f2
VER_PATCH:
sh: echo {{.VER_CUT}} | cut -d. -f3
VER_RC:
sh: echo {{.VER_PATCH}} | cut -f2 -d-
VER_FLAGS: '-X main.Version={{.VERSION}} -X main.DateBuilt={{.DATE}}'
tasks:
godir:
cmd: which go
deps:
desc: Install dependencies
cmd: go mod tidy
build:
desc: Build the application
deps:
- deps
cmd: go build {{.GO_FLAGS}} -tags "{{.TAGS}}" -ldflags "{{.LD_FLAGS}} {{.VER_FLAGS}}" -o {{.TARGET_BIN}}/{{.APP_NAME}} ./cmd/{{.APP_NAME}}/*.go
tools:
desc: Build the tools
deps:
- deps
cmds:
- go build {{.GO_FLAGS}} -tags "{{.TAGS}}" -ldflags "{{.LD_FLAGS}} {{.VER_FLAGS}}" -o {{.TARGET_BIN}}/docs_gen ./cmd/docs_gen/*.go
install:
desc: Install the application
deps:
- build
vars:
INSTALL_DIR: "{{.GOPATH}}/bin"
cmds:
- install -d {{.INSTALL_DIR}}
- rm -f {{.INSTALL_DIR}}/{{.APP_NAME}}
- cp {{.TARGET_BIN}}/* {{.INSTALL_DIR}}/
docker:
cmds:
- docker build -f ./resources/docker/Dockerfile . -t {{.DOCKER_IMAGE}}:{{.VER_CUT}}
- docker tag {{.DOCKER_IMAGE}}:{{.VER_CUT}} {{.DOCKER_IMAGE}}:latest
fmt:
cmds:
- go list -f {{.Dir}} ./... | xargs -I{} gofmt -w -s {}
- go list -f {{.Dir}} ./... | xargs -I{} goimports -w -local github.com/wombatwisdom/wombat {}
- go mod tidy
lint:
cmds:
- go vet {{.GO_FLAGS}} ./...
- golangci-lint -j 10 run --timeout 1h --verbose cmd/... internal/... public/...
test:
deps:
- build
cmds:
- 'go test {{.GO_FLAGS}} -ldflags "{{.LD_FLAGS}}" -timeout 3m ./...'
test-race:
deps:
- build
cmd: go test {{.GO_FLAGS}} -ldflags "{{.LD_FLAGS}}" -timeout 3m -race ./...
test-integration:
prompt: |-
WARNING! Running the integration tests in their entirety consumes a huge amount of computing resources and is
likely to time out on most machines. It's recommended that you instead run the integration suite for connectors
you are working selectively with `go test -run 'TestIntegration/kafka' ./...` and so on.
Are you sure you want to continue?
cmd: go test {{.GO_FLAGS}} -ldflags "{{.LD_FLAGS}}" -run "^Test.*Integration.*$$" -timeout 5m ./...
clean:
cmds:
- rm -rf {{.TARGET_DIR}}
docs:
# deps:
# - build
# - tools
cmds:
- go run ./cmd/docs_gen