-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
139 lines (120 loc) · 3.67 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
---
version: "3"
vars:
GIT_ROOT:
sh: git rev-parse --show-toplevel
MAIN_PACKAGE: main.go
OS_TAGS:
sh: |
if grep -iq "ubuntu" /etc/os-release; then
echo "-tags=ubuntu"
else
echo ""
fi
includes:
docs:
taskfile: ./docs
dir: ./docs
bats:
taskfile: ./test
dir: ./test
tasks:
deps:
desc: Install dependencies
cmds:
- npm install -g @redocly/cli
- go install github.com/spf13/cobra-cli@latest
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install github.com/segmentio/golines@latest
- go install github.com/boumenot/gocover-cobertura@latest
- go install mvdan.cc/gofumpt@latest
- go install github.com/jstemmer/go-junit-report@latest
- go install github.com/air-verse/air@latest
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
# - go install github.com/goreleaser/goreleaser@latest
- task bats:deps
mod:
desc: Module maintenance
cmds:
- go mod download
- go mod tidy
vet:
desc: Report likely mistakes in packages
cmds:
- $(go env GOPATH)/bin/golangci-lint run --config {{ .GIT_ROOT }}/.golangci.yml
run:
desc: Compile and run Go program
cmds:
- go run {{ .MAIN_PACKAGE }} {{ .CLI_ARGS }}
run-on-linux:
cmds:
- |
if grep -iq "ubuntu" /etc/os-release; then
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
fi
unit:
desc: Test packages
cmds:
- go test {{ .OS_TAGS }} -parallel 5 -race -v ./...
unit:int:
desc: Integration test packages
cmds:
- task: bats:test
test:
desc: Test all
cmds:
- task: mod
- task: fmt:check
- task: vet
- task: unit:cov
- task: unit:int
unit:cov:
desc: Generate coverage
env:
# https://github.com/golang/go/issues/65570
GOEXPERIMENT: nocoverageredesign
cmds:
- task: run-on-linux
- go test {{ .OS_TAGS }} -race -coverprofile=cover.out -v $(go list ./...)
- gocover-cobertura --ignore-files mock.go < cover.out > cobertura.xml
- go tool cover -func=cover.out
unit:cov:map:
desc: Generate coverage and show heatmap
cmds:
- task: unit:cov
- go tool cover -html=cover.out
fmt:
desc: Reformat files whose formatting differs from `go_fmt_command`
cmds:
- find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' | xargs gofumpt -l -w
- find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' | xargs golines --base-formatter=gofumpt -w
fmt:check:
desc: Check files whose formatting differs from `go_fmt_command`
cmds:
# https://github.com/mvdan/gofumpt/issues/114
- test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' | xargs gofumpt -d -e | tee /dev/stderr)"
- test -z "$(find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' | xargs golines --dry-run --base-formatter=gofumpt -l | tee /dev/stderr)"
dev:serve:
desc: Serve the API on an Ubuntu Linux VM
cmds:
- ssh -L 8080:localhost:8080 nerd.lab
docker:build:
desc: Build an image from a Dockerfile
cmds:
- docker build -t osapi:latest .
docker:serve:
desc: Serve the API on a Docker instance
cmds:
- docker run -it -p 8080:8080 osapi:latest
serve:
desc: Live reload of server
env:
IGNORE_LINUX: true
cmds:
- air server
generate:
desc: Generate Go files by processing source
cmds:
- redocly join --prefix-tags-with-info-prop title -o internal/client/gen/api.yaml internal/api/*/gen/api.yaml
- go generate ./...
- task: docs:generate