-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTaskfile.yml
More file actions
159 lines (134 loc) · 4.24 KB
/
Copy pathTaskfile.yml
File metadata and controls
159 lines (134 loc) · 4.24 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
---
version: "3"
vars:
GIT_ROOT:
sh: git rev-parse --show-toplevel
MAIN_PACKAGE: main.go
includes:
docs:
taskfile: ./docs
dir: ./docs
tasks:
_fmt-deps:
internal: true
cmds:
- go get -tool mvdan.cc/gofumpt
- go get -tool github.com/segmentio/golines
_vet-deps:
internal: true
cmds:
- go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
_cov-deps:
internal: true
cmds:
- go get -tool github.com/boumenot/gocover-cobertura
_mockgen-deps:
internal: true
cmds:
- go get -tool go.uber.org/mock/mockgen
deps:
desc: Install dependencies
cmds:
- task: _fmt-deps
- task: _vet-deps
- task: _cov-deps
- task: _mockgen-deps
- go get github.com/bats-core/bats-core@latest
- bash $(go env GOMODCACHE)/$(go list -m github.com/bats-core/bats-core | tr ' ' @)/install.sh ./test/integration/vendor/bats
deps:check:
desc: Check dependencies needed for development
cmds:
- echo "Dependency check OK"
preconditions:
- sh: "case '{{OS}}' in darwin|linux) true ;; *) false ;; esac"
msg: Operating System '{{OS}}' not supported
- sh: command -v jq
msg: |
'jq' not found in $PATH
Suggested action: 'brew install jq'
mod:
desc: Module maintenance
cmds:
- go mod download
- go mod tidy
vet:
desc: Report likely mistakes in packages
deps:
- _vet-deps
cmds:
- go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --config {{ .GIT_ROOT }}/.golangci.yml
vuln:
desc: Run Go's vulnerability scanner
cmds:
- go tool golang.org/x/vuln/cmd/govulncheck ./...
run:
desc: Compile and run Go program
cmds:
- go run {{ .MAIN_PACKAGE }} {{.CLI_ARGS}}
unit:
desc: Test packages
cmds:
- go test -parallel 5 -race -v ./...
unit:int:
desc: Integration test packages
cmds:
- task: unit:bats
unit:bats:
desc: Integration bats test packages
cmds:
- ./test/integration/vendor/bats/bin/bats test/integration
test:
desc: Test all
cmds:
- task: deps
- task: mod
- task: fmt:check
- task: vet
- task: cov
- task: unit:int
cov:
desc: Generate coverage
deps:
- _cov-deps
cmds:
# NOTE(nic): Exclude mocks and code covered by integration tests from coverage
- go test -race -coverprofile=cover.out -v $(go list ./... | grep -v /mocks | grep -v /cmd | grep -v /pkg/repositories | egrep -v 'v2$')
- go tool github.com/boumenot/gocover-cobertura < cover.out > cobertura.xml
- go tool cover -func=cover.out
cov:map:
desc: Generate coverage and show heatmap
cmds:
- task: cov
- go tool cover -html=cover.out
fmt:
desc: Reformat files whose formatting differs from `go_fmt_command`
deps:
- _fmt-deps
cmds:
- go tool mvdan.cc/gofumpt -l -w .
- go tool github.com/segmentio/golines --base-formatter="go tool mvdan.cc/gofumpt" -w .
fmt:check:
desc: Check files whose formatting differs from `go_fmt_command`
deps:
- _fmt-deps
cmds:
# https://github.com/mvdan/gofumpt/issues/114
- test -z "$(go tool mvdan.cc/gofumpt -d -e . | tee /dev/stderr)"
- test -z "$(go tool github.com/segmentio/golines --dry-run --base-formatter="go tool mvdan.cc/gofumpt" -l . | tee /dev/stderr)"
build:
desc: Build ARCH compatible binary.
cmds:
- goreleaser release --snapshot --clean
build:wheel:
desc: Build ARCH Python wheel. Requires running `task build` first.
cmds:
- python/dist2wheel.py
mockgen:
desc: Generate mock for interface
deps:
- _mockgen-deps
cmds:
- go tool go.uber.org/mock/mockgen -source=internal/git.go -destination=internal/mocks/git/git_mock.go -package=git
- go tool go.uber.org/mock/mockgen -source=internal/repository.go -destination=internal/mocks/repository/repository_mock.go -package=repository
- go tool go.uber.org/mock/mockgen -source=internal/exec.go -destination=internal/mocks/exec/exec_mock.go -package=exec
- go tool go.uber.org/mock/mockgen -source=internal/repository/types.go -destination=internal/mocks/repository/copy_mock.go -package=repository