-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskfile.yml
More file actions
116 lines (102 loc) · 3.47 KB
/
Taskfile.yml
File metadata and controls
116 lines (102 loc) · 3.47 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
version: '3'
env:
# Keep Go build artifacts and module downloads inside the repo so local runs
# don't need the global Go cache dirs (useful in sandboxed environments).
GOCACHE: '{{.TASKFILE_DIR}}/.gocache/go-build'
GOMODCACHE: '{{.TASKFILE_DIR}}/.gocache/go-mod'
vars:
VERSION:
sh: git describe --tags --always --dirty
GOLANGCI_LINT_VERSION: v1.64.8
tasks:
default:
desc: Install this repo's ergo build into your Go bin (alias for `task install`)
silent: true
cmds:
- task: install
install:
desc: Compile with version metadata and install `ergo` to GOBIN (or GOPATH/bin)
silent: true
cmds:
- printf '%s\n' "[install] go install ./cmd/ergo"
- go install -ldflags "-X main.version={{.VERSION}}" ./cmd/ergo
- |
set -euo pipefail
bin="$(go env GOBIN)"
if [[ -z "${bin}" ]]; then
gopath="$(go env GOPATH | cut -d: -f1)"
bin="${gopath}/bin"
fi
printf '%s\n' "Installed ergo {{.VERSION}} to ${bin}/ergo"
build:
desc: Build a local versioned binary at ./bin/ergo (no global install)
silent: true
cmds:
- printf '%s\n' "[build] bin/ergo"
- mkdir -p bin
- go build -ldflags "-X main.version={{.VERSION}}" -o bin/ergo ./cmd/ergo
- printf '%s\n' "Built bin/ergo {{.VERSION}}"
run:
desc: Run ergo from source via `go run` (pass args like `task run -- list`)
silent: true
cmds:
- |
set -euo pipefail
args="{{.CLI_ARGS}}"
if [[ -n "${args}" ]]; then
printf '%s\n' "[run] ergo ${args}"
else
printf '%s\n' "[run] ergo (no args)"
fi
go run ./cmd/ergo {{.CLI_ARGS}}
test:
desc: Run full test suite with the race detector (matches correctness gate)
silent: true
cmds:
- printf '%s\n' "[test] go test -race ./..."
- go test -race ./...
cover:
desc: Run race-enabled tests and print total code coverage
silent: true
cmds:
- printf '%s\n' "[cover] go test -race -coverprofile=coverage.out ./..."
- go test -race -coverprofile=coverage.out ./...
- printf '%s\n' "[cover] go tool cover -func=coverage.out (total)"
- go tool cover -func=coverage.out | tail -n 1
bench:
desc: Run all benchmarks with allocation stats (`-benchmem`)
silent: true
cmds:
- printf '%s\n' "[bench] go test -bench=. -benchmem ./..."
- go test -bench=. -benchmem ./...
fmt:
desc: Gofmt all Go package directories in this repo
silent: true
cmds:
- printf '%s\n' "[fmt] gofmt -w (go list ./...)"
- |
set -euo pipefail
# Avoid formatting third-party sources now that we use a repo-local GOMODCACHE.
gofmt -w $(go list -f '{{"{{"}}.Dir{{"}}"}}' ./... | sort -u)
vet:
desc: Go vet static analysis for suspicious constructs across all packages
silent: true
cmds:
- printf '%s\n' "[vet] go vet ./..."
- go vet ./...
lint:
desc: Run pinned golangci-lint ruleset (same linter version as CI)
silent: true
cmds:
- GOLANGCI_LINT_VERSION={{.GOLANGCI_LINT_VERSION}} ./scripts/golangci-lint.sh run ./...
ci:
desc: Execute CI parity script (tidy, lint, and tests)
silent: true
cmds:
- GOLANGCI_LINT_VERSION={{.GOLANGCI_LINT_VERSION}} ./scripts/ci.sh
clean:
desc: Remove local build outputs and coverage artifacts
silent: true
cmds:
- printf '%s\n' "[clean] rm -rf bin/ dist/ coverage.out"
- rm -rf bin/ dist/ coverage.out