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