1# https://taskfile.dev
2
3version: "3"
4
5vars:
6 VERSION:
7 sh: git describe --long 2>/dev/null || echo ""
8
9env:
10 CGO_ENABLED: 0
11 GOEXPERIMENT: greenteagc
12
13tasks:
14 lint:install:
15 desc: Install golangci-lint
16 cmds:
17 - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
18 env:
19 GOTOOLCHAIN: go1.25.0
20
21 lint:
22 desc: Run base linters
23 cmds:
24 - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
25 env:
26 GOEXPERIMENT: null
27
28 lint:fix:
29 desc: Run base linters and fix issues
30 cmds:
31 - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
32 env:
33 GOEXPERIMENT: null
34
35 build:
36 desc: Run build
37 vars:
38 LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
39 cmds:
40 - go build {{.LDFLAGS}} .
41 generates:
42 - crush
43
44 run:
45 desc: Run build
46 cmds:
47 - go build -o crush .
48 - ./crush {{.CLI_ARGS}}
49
50 test:
51 desc: Run tests
52 cmds:
53 - go test ./... {{.CLI_ARGS}}
54
55 test:record:
56 desc: Run tests and record all VCR cassettes again
57 aliases: [record]
58 cmds:
59 - rm -r internal/agent/testdata
60 - go test -v -count=1 -timeout=1h ./internal/agent
61
62 fmt:
63 desc: Run gofumpt
64 cmds:
65 - gofumpt -w .
66
67 dev:
68 desc: Run with profiling enabled
69 env:
70 CRUSH_PROFILE: true
71 cmds:
72 - go run .
73
74 install:
75 desc: Install the application
76 vars:
77 LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
78 cmds:
79 - task: fetch-tags
80 - go install {{.LDFLAGS}} -v .
81
82 profile:cpu:
83 desc: 10s CPU profile
84 cmds:
85 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
86
87 profile:heap:
88 desc: Heap profile
89 cmds:
90 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
91
92 profile:allocs:
93 desc: Allocations profile
94 cmds:
95 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
96
97 schema:
98 desc: Generate JSON schema for configuration
99 cmds:
100 - go run main.go schema > schema.json
101 - echo "Generated schema.json"
102 generates:
103 - schema.json
104
105 hyper:
106 desc: Update Hyper embedded provider.json
107 cmds:
108 - go generate ./internal/agent/hyper/...
109 generates:
110 - ./internal/agent/hyper/provider.json
111
112 release:
113 desc: Create and push a new tag following semver
114 vars:
115 NEXT:
116 sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
117 prompt: "This will release {{.NEXT}}. Continue?"
118 preconditions:
119 - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
120 msg: Not on main branch
121 - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
122 msg: "Git is dirty"
123 cmds:
124 - task: fetch-tags
125 - git commit --allow-empty -m "{{.NEXT}}"
126 - git tag --annotate --sign -m "{{.NEXT}}" {{.NEXT}} {{.CLI_ARGS}}
127 - echo "Pushing {{.NEXT}}..."
128 - git push origin main --follow-tags
129
130 fetch-tags:
131 cmds:
132 - git tag -d nightly || true
133 - git fetch --tags
134
135 deps:
136 desc: Update Fantasy and Catwalk
137 cmds:
138 - go get charm.land/fantasy
139 - go get github.com/charmbracelet/catwalk
140 - go mod tidy