-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
150 lines (124 loc) · 3.69 KB
/
Taskfile.yml
File metadata and controls
150 lines (124 loc) · 3.69 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
version: '3'
vars:
# PKG_LIST: all project packages excluding generated mocks.
PKG_LIST:
sh: go list ./... | grep -v /mocks | tr '\n' ' '
PKG_PATH_LIST:
sh: go list -f '{{"{{.Dir}}"}}' {{.PKG_LIST}} | tr '\n' ' '
tasks:
default:
desc: "List available tasks"
cmds:
- task --list
build:
desc: "Build the binary into ./structalign"
cmds:
- go build -o structalign .
install:
desc: "Install the binary into $GOBIN / $GOPATH/bin"
cmds:
- go install .
test:
desc: "Run tests via gotestsum (pass flags after --, e.g. -- -update)"
cmds:
- gotestsum -f standard-verbose -- {{.PKG_PATH_LIST}} {{.CLI_ARGS}}
test:race:
desc: "Run tests with the race detector"
cmds:
- gotestsum -f standard-verbose -- -race {{.PKG_PATH_LIST}} {{.CLI_ARGS}}
test:coverage:
desc: "Run tests with coverage report"
cmds:
- gotestsum -f standard-verbose -- -covermode=atomic -count=1 -coverprofile=coverage.txt {{.PKG_PATH_LIST}} {{.CLI_ARGS}}
test:update:
desc: "Regenerate the .golden fixtures"
cmds:
- go test ./... -update
lint:
desc: "Run golangci-lint"
cmds:
- golangci-lint run {{.PKG_PATH_LIST}}
lint:fix:
desc: "Run golangci-lint with --fix"
cmds:
- golangci-lint run --fix {{.PKG_PATH_LIST}}
consistent:
desc: "Check code-pattern consistency with go-consistent"
cmds:
- go-consistent {{.PKG_PATH_LIST}}
format:
desc: "Format with golangci-lint's formatters"
cmds:
- golangci-lint fmt {{.PKG_PATH_LIST}}
generate:
desc: "Regenerate code and mocks"
cmds:
- task: generate:code
- task: generate:mocks
generate:code:
desc: "Regenerate code with go generate"
cmds:
- go generate {{.PKG_PATH_LIST}}
generate:mocks:
desc: "Regenerate mocks with mockery (skipped when .mockery.yaml is absent)"
cmds:
- mockery
status:
- test ! -f .mockery.yaml
smoke:
desc: "Exercise both modes against the bundled sample"
cmds:
- go run . -inspect ./_example
- |
if go run . ./_example; then
echo "expected non-zero exit when reorderings are found"; exit 1
fi
tidy:
desc: "Run go mod tidy"
cmds:
- go mod tidy
tidy:check:
desc: "Fail if go.mod/go.sum are not tidy"
cmds:
- go mod tidy
- git diff --exit-code go.mod go.sum
ci:
desc: "Full pre-push gate: mirrors the GitHub Actions checks"
cmds:
- task: tidy:check
- task: lint
- task: consistent
- go build {{.PKG_PATH_LIST}}
- task: test
- task: smoke
changelog:
desc: "Regenerate CHANGELOG.md from git history"
cmds:
- git cliff -o CHANGELOG.md
changelog:unreleased:
desc: "Preview the next release's changelog section"
cmds:
- git cliff --unreleased
release:
desc: "Write CHANGELOG.md for a release: task release TAG=v0.3.0"
cmds:
- "test -n '{{.TAG}}' || (echo 'usage: task release TAG=vX.Y.Z'; exit 1)"
- git cliff --tag {{.TAG}} -o CHANGELOG.md
snapshot:
desc: "Build a local snapshot release with GoReleaser (no publish)"
cmds:
- goreleaser release --snapshot --clean
release-check:
desc: "Validate .goreleaser.yaml"
cmds:
- goreleaser check
screenshot:
desc: "Regenerate docs/diff.png (needs python3 + pillow)"
cmds:
- ./structalign -color=always -type=Record ./_example > /tmp/structalign-diff.ansi || true
- python3 docs/ansi2png.py /tmp/structalign-diff.ansi docs/diff.png "$ structalign -type=Record ./_example"
deps: [build]
clean:
desc: "Remove build and coverage artifacts"
cmds:
- rm -rf structalign dist/ coverage.* *.out