-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
219 lines (193 loc) · 6.95 KB
/
Copy pathTaskfile.yml
File metadata and controls
219 lines (193 loc) · 6.95 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
vars:
BINARY: chezit
BIN_DIR: bin
GOLANGCI_LINT_VERSION:
sh: cat .golangci-lint-version
# renovate: datasource=github-releases depName=caarlos0/svu
SVU_VERSION: '3.4.1'
# renovate: datasource=github-releases depName=goreleaser/goreleaser
GORELEASER_VERSION: '2.16.0'
tasks:
default:
desc: List available tasks
internal: true
silent: true
cmds:
- task --list-all
build:
desc: Build the binary
sources: ['**/*.go', '!**/*_test.go', go.mod, go.sum]
generates: ['{{.BIN_DIR}}/{{.BINARY}}']
cmds:
- go build -o {{.BIN_DIR}}/{{.BINARY}} ./cmd/chezit
test:
desc: Run tests (pass args via --, e.g. task test -- -run TestGolden)
cmds:
- go test -v {{.CLI_ARGS}} ./cmd/... ./internal/...
test-update:
desc: Regenerate golden files (pass test filter via --, e.g. task test-update -- -run TestGoldenStatusTab)
cmds:
- go test -v {{.CLI_ARGS}} ./internal/tui/ -args -update
test-cover:
desc: Run tests with coverage report (scoped to internal packages)
cmds:
- go test -coverprofile=coverage.out -coverpkg=./internal/... ./...
- go tool cover -html=coverage.out -o coverage.html
install:
desc: Build and install as chezit-dev to ~/.local/bin (won't conflict with Homebrew release)
deps: [build]
cmds:
- mkdir -p $HOME/.local/bin
- cp {{.BIN_DIR}}/{{.BINARY}} $HOME/.local/bin/chezit-dev
clean:
desc: Remove build artifacts
cmds:
- rm -f {{.BIN_DIR}}/{{.BINARY}} coverage.out coverage.html
lint:install:
desc: Install golangci-lint to bin/
internal: true
status:
- test -x ./bin/golangci-lint
- ./bin/golangci-lint version 2>&1 | grep -qF '{{.GOLANGCI_LINT_VERSION}}'
cmds:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b {{.BIN_DIR}} v{{.GOLANGCI_LINT_VERSION}}
svu:install:
desc: Install svu to bin/
internal: true
status:
- test -x ./bin/svu
- './bin/svu --version 2>&1 | grep -qF ''{{.SVU_VERSION}}'''
cmds:
- 'GOBIN="$(pwd)/bin" go install github.com/caarlos0/svu/v3@v{{.SVU_VERSION}}'
goreleaser:install:
desc: Install goreleaser to bin/
internal: true
status:
- test -x ./bin/goreleaser
- './bin/goreleaser --version 2>&1 | grep -qF ''{{.GORELEASER_VERSION}}'''
cmds:
- 'GOBIN="$(pwd)/bin" go install github.com/goreleaser/goreleaser/v2@v{{.GORELEASER_VERSION}}'
lint:
desc: Run golangci-lint (version from .golangci-lint-version)
sources: ['**/*.go', go.mod, go.sum, .golangci.yml]
deps: [lint:install]
cmds:
- ./bin/golangci-lint run --timeout=5m {{.CLI_ARGS}}
fmt:
desc: Format Go files (gofumpt + gci via golangci-lint)
deps: [lint:install]
cmds:
- ./bin/golangci-lint fmt {{.CLI_ARGS}}
check-fmt:
desc: Check that all Go files are formatted (gofumpt + gci)
sources: ['**/*.go']
deps: [lint:install]
cmds:
- ./bin/golangci-lint fmt --diff
run:
desc: Build and run
deps: [build]
cmds:
- ./{{.BIN_DIR}}/{{.BINARY}}
run-debug:
desc: Build and run with debug message logging (task run-debug -- /path/to/log)
deps: [build]
vars:
LOG_FILE: '{{.CLI_ARGS | default "/tmp/chezit-debug.log"}}'
cmds:
- echo "Debug log:{{" "}}{{.LOG_FILE}}"
- echo "Tail in another terminal:{{" "}}tail -f {{.LOG_FILE}}"
- CHEZIT_DEBUG={{.LOG_FILE}} ./{{.BIN_DIR}}/{{.BINARY}}
tidy:
desc: Tidy module dependencies
cmds:
- go mod tidy
check:
desc: Run all checks (fmt, lint, test)
deps: [check-fmt, lint, test]
docs:
desc: Start local pkgsite documentation server on :6060
cmds:
- echo "Starting pkgsite at http://localhost:6060"
- go run golang.org/x/pkgsite/cmd/pkgsite@latest -http=:6060 .
vulncheck:
desc: Run govulncheck (fetches latest automatically)
cmds:
- go run golang.org/x/vuln/cmd/govulncheck@latest ./...
release:
desc: "Create and push a release tag (task release BUMP=patch or VERSION=v1.2.3)"
summary: |
Create and push a release tag, triggering the GitHub release workflow.
Usage:
task release BUMP=patch # v0.1.1 → v0.1.2
task release BUMP=minor # v0.1.1 → v0.2.0
task release BUMP=major # v0.1.1 → v1.0.0
task release VERSION=v2.0.0 # explicit version
deps: [svu:install]
vars:
TAG:
sh: |
git fetch --tags --quiet
if [ -n "{{.VERSION}}" ]; then
version="{{.VERSION}}"
echo "v${version#v}"
elif [ -n "{{.BUMP}}" ]; then
./bin/svu "{{.BUMP}}"
else
echo "_"
fi
prompt: "Create and push {{.TAG}}?"
preconditions:
- sh: '[ -n "{{.VERSION}}" ] || [ -n "{{.BUMP}}" ]'
msg: 'Set BUMP (patch|minor|major) or VERSION (e.g. task release BUMP=patch)'
- sh: 'test -z "$(git status --porcelain)"'
msg: 'Working tree is dirty — commit or stash changes first'
- sh: 'git diff --quiet @{upstream}.. 2>/dev/null'
msg: 'Unpushed commits — push to remote before releasing'
- sh: 'echo "{{.TAG}}" | grep -Eq "^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$"'
msg: 'Invalid version format: {{.TAG}} (expected vX.Y.Z or vX.Y.Z-pre.N)'
- sh: '! git rev-parse "{{.TAG}}" >/dev/null 2>&1'
msg: 'Tag {{.TAG}} already exists locally'
- sh: 'test -z "$(git ls-remote --tags origin "{{.TAG}}")"'
msg: 'Tag {{.TAG}} already exists on remote'
cmds:
- git tag -a "{{.TAG}}" -m "Release {{.TAG}}"
- git push origin "{{.TAG}}" || { git tag -d "{{.TAG}}"; exit 1; }
- |
echo "Tag {{.TAG}} pushed."
echo "Status: gh run list --workflow=release.yml --branch {{.TAG}}"
echo "Watch: gh run watch -w release.yml"
release-dry:
desc: Dry-run release (snapshot build, nothing published)
deps: [goreleaser:install]
cmds:
- ./bin/goreleaser release --snapshot --clean --skip=homebrew
- echo "Snapshot build complete. Artifacts in dist/"
record:
desc: "Record demo GIFs (all, or task record -- overview for one)"
deps: [build]
preconditions:
- sh: command -v vhs >/dev/null 2>&1
msg: "vhs not found — install with: brew install vhs"
- sh: command -v chezmoi >/dev/null 2>&1
msg: "chezmoi not found — install with: brew install chezmoi"
cmds:
- .vhs/record.sh {{.CLI_ARGS}}
version:
desc: Show current version from git tags
deps: [svu:install]
cmds:
- git fetch --tags --quiet
- ./bin/svu current
setup:
desc: Install dev tools and git hooks
deps: [lint:install, svu:install, goreleaser:install]
cmds:
- |
if ! command -v lefthook >/dev/null 2>&1; then
echo "Installing lefthook..."
go install github.com/evilmartians/lefthook/v2@latest
fi
- lefthook install