-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
148 lines (125 loc) · 4.07 KB
/
Copy pathTaskfile.yml
File metadata and controls
148 lines (125 loc) · 4.07 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
# https://taskfile.dev
#
# Tasks for the dotenv module. Run them from this directory, or from the repo
# root as `task dotenv:<task>` — the root Taskfile includes this file.
#
# Every module carries the same task names on purpose: `task test` means the
# same thing everywhere, so moving between modules costs no re-learning.
version: "3"
includes:
# The CLI module carries its own Taskfile; `task cli:build`, `task cli:ci`,
# etc. proxy into it with the right working directory.
cli:
taskfile: ./cli/Taskfile.yml
dir: ./cli
vars:
FUZZ_TARGETS: FuzzParseRender FuzzParseIsIdempotent FuzzSetRoundTrip FuzzSetIsIdempotent FuzzExpandTerminates
tasks:
default:
desc: List available tasks
cmds:
- task --list
silent: true
test:
desc: Run tests
cmds:
- go test ./...
test:race:
desc: Run tests with the race detector
cmds:
- go test -race ./...
test:cover:
desc: Report statement coverage
cmds:
- go test -coverprofile=cover.out ./...
- go tool cover -func=cover.out | tail -1
test:cover:html:
desc: Open the coverage report in a browser
deps: [test:cover]
cmds:
- go tool cover -html=cover.out
test:uncovered:
desc: List functions below 100% coverage
cmds:
- go test -coverprofile=cover.out ./... > /dev/null
- 'go tool cover -func=cover.out | grep -v "100.0%" || echo "everything is covered"'
cover:
desc: Statement coverage for BOTH modules — the numbers the README badge quotes
cmds:
- echo "── library"
- task: test:cover
- echo "── cli"
- task: cli:test:cover
fuzz:
desc: 'Fuzz one property: task fuzz -- FuzzParseRender [30s]'
vars:
TARGET: '{{index (splitArgs .CLI_ARGS) 0}}'
DURATION: '{{if gt (len (splitArgs .CLI_ARGS)) 1}}{{index (splitArgs .CLI_ARGS) 1}}{{else}}30s{{end}}'
cmds:
# -run "^$" so only the fuzz engine runs; without it the whole unit suite
# executes first and the fuzz budget is spent on startup.
- go test -run "^$" -fuzz "^{{.TARGET}}$" -fuzztime {{.DURATION}} .
fuzz:all:
desc: Fuzz every property for 30s each
cmds:
- for: { var: FUZZ_TARGETS }
cmd: |
echo "── {{.ITEM}}"
go test -run "^$" -fuzz "^{{.ITEM}}$" -fuzztime 30s .
fuzz:list:
desc: List the fuzz properties in this module
cmds:
- 'grep -h "^func Fuzz" *_test.go | sed "s/func \\(Fuzz[A-Za-z]*\\).*/ \\1/"'
bench:
desc: Run benchmarks with allocation counts
cmds:
- go test -run "^$" -bench . -benchmem .
vet:
desc: Run go vet
cmds:
- go vet ./...
lint:
desc: Run golangci-lint (and staticcheck) when installed
cmds:
# Look in PATH first, then GOPATH/bin — `go install` puts binaries there
# but shells often omit it from PATH, which made this task silently skip
# a linter that was actually installed.
- |
bin=$(command -v golangci-lint || echo "$(go env GOPATH)/bin/golangci-lint")
[ -x "$bin" ] && "$bin" run ./... || echo "golangci-lint not installed; skipping"
- |
bin=$(command -v staticcheck || echo "$(go env GOPATH)/bin/staticcheck")
[ -x "$bin" ] && "$bin" ./... || echo "staticcheck not installed; skipping"
fmt:
desc: Format the source
cmds:
- gofmt -w .
fmt:check:
desc: Fail when the source is unformatted
cmds:
- |
out=$(gofmt -l .)
if [ -n "$out" ]; then echo "gofmt needed on:"; echo "$out"; exit 1; fi
tidy:
desc: Tidy go.mod and go.sum
cmds:
- go mod tidy
doc:
desc: Print the package's exported API
cmds:
- go doc -all .
deps:
desc: Show this module's third-party dependencies
cmds:
- 'go list -deps ./... | grep "\." | grep -v ubgo/dotenv | sort -u || echo "none — stdlib only"'
ci:
desc: The full gate — library AND cli — format, vet, race tests
cmds:
- task: fmt:check
- task: vet
- task: test:race
- task: cli:ci
clean:
desc: Remove coverage artifacts
cmds:
- rm -f cover.out cover.html