Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
145 lines (127 loc) · 2.81 KB
/
Copy pathTaskfile.yml
File metadata and controls
145 lines (127 loc) · 2.81 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
version: "3"
env:
CGO_ENABLED: 0
vars:
min_go_version: 1.18
buildflags: >-
-trimpath -buildvcs=true -ldflags="-s -w"
program:
sh: |-
basename $(go list)
modname:
sh: go list
GOPATH:
sh: |-
go env GOPATH
GOENVBIN:
sh: |-
go env GOBIN
GOBIN: |-
{{ list .GOPATH "bin" | join "/" | default .GOENVBIN }}
run: once
tasks:
default:
silent: true
aliases: ["help", "list"]
cmds:
- task --list
all:
desc: "Build and Test"
cmds:
- task: test
- task: build
lint:
desc: "Run linters & formatters"
cmds:
- cmd: go vet
- cmd: go fix
- task: gofumpt
- task: goimports
test:
desc: "Run tests"
deps:
- lint
cmds:
# - cmd: go test ./... -fullpath
- task: build
- cmd: bin/buildinfo ./bin/buildinfo
- cmd: bin/buildinfo ./bin/example-program
build:
desc: "Build the project"
deps:
- lint
cmds:
# language=sh
- mkdir -p bin
- cmd: go build -o bin/{{.program}} {{.buildflags}}
- cmd: go build -o bin/example-program {{.buildflags}} .
dir: example/aprogram
mod-tidy:
desc: "Tidy go.mod/go.sum to match source code dependencies"
deps:
- go-version-check
cmds:
- cmd: go mod tidy
mod-update:
desc: "update go modules to latest available version"
deps:
- go-version-check
cmds:
- cmd: go get -u
status:
- |-
[[ $(go mod graph | grep -E -v "$(go list)"' go@[01]\.[0-9]+$' | wc -l) -eq 0 ]]
clean:
desc: "Clean build artifacts"
deps:
- go-version-check
cmds:
- cmd: go clean
- cmd: rm -v {{.program}}
method: none
rebuild:
desc: "Completely clean and rebuild the project"
deps:
- clean
cmds:
- task: build
method: none
install:
desc: "Install {{.PROG}} into $"
deps:
- lint
cmds:
# language=sh
- cmd: go install main.go {{.buildflags}}
run:
deps:
- lint
cmds:
# language=sh
- cmd: go run main.go {{ default "--help" .CLI_ARGS }}
method: none
go-version-check:
silent: true
# language=sh
cmd: |-
printf "%s\n" "go version go{{.min_go_version}}" "$(go version)" | \
sort --version-sort --check=silent
gofumpt:
cmd: gofumpt -l -w .
internal: true
preconditions:
- command -v gofumpt
goimports:
cmd: goimports -w .
internal: true
preconditions:
- command -v goimports
install-formatters:
desc: "Install golang.org/x/tools/cmd/goimports and github.com/mvdan/gofumpt"
deps:
- go-version-check
cmds:
- cmd: |-
go install golang.org/x/tools/cmd/goimports@latest {{.buildflags}}
- cmd: |-
go install github.com/mvdan/gofumpt@latest {{.buildflags}}