Repository navigation
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
236 lines (206 loc) · 6.66 KB
/
Copy pathTaskfile.yaml
File metadata and controls
236 lines (206 loc) · 6.66 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# https://taskfile.dev
version: "3"
vars:
VERSION:
sh: git describe --long 2>/dev/null || echo ""
RACE:
sh: test -f race.log && echo "1" || echo ""
env:
CGO_ENABLED: 1
GOEXPERIMENT: greenteagc
tasks:
lint:install:
desc: Install golangci-lint
cmds:
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
env:
GOTOOLCHAIN: go1.25.0
lint:
desc: Run base linters
cmds:
- task: lint:log
- golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
env:
GOEXPERIMENT: null
lint:log:
desc: Check that log messages start with capital letters
cmds:
- ./scripts/check_log_capitalization.sh
lint:fix:
desc: Run base linters and fix issues
cmds:
- golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
env:
GOEXPERIMENT: null
build:
desc: Run build
deps:
- docs:embed
vars:
LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/hackafterdark/phosphor/internal/version.Version={{.VERSION}} -X github.com/hackafterdark/phosphor/pkg/phosphordocs.Version={{.VERSION}}"{{end}}'
cmds:
- "go build -v {{if .RACE}}-race{{end}} {{.LDFLAGS}} ."
sources:
- ./**/*.go
- go.mod
- pkg/agent/**/*.md
- pkg/agent/**/*.md.tpl
- pkg/agent/hyper/provider.json
- pkg/phosphordocs/content/**
generates:
- phosphor{{exeExt}}
run:
desc: Run build
cmds:
- task: build
- "./phosphor{{exeExt}} {{.CLI_ARGS}} {{if .RACE}}2>race.log{{end}}"
run:catwalk:
desc: Run build with local Catwalk
env:
CATWALK_URL: http://localhost:8080
cmds:
- task: build
- ./phosphor{{exeExt}} {{.CLI_ARGS}}
run:onboarding:
desc: Run build with custom config to test onboarding
env:
PHOSPHOR_GLOBAL_DATA: tmp/onboarding/data
PHOSPHOR_GLOBAL_CONFIG: tmp/onboarding/config
cmds:
- task: build
- rm -rf tmp/onboarding
- ./phosphor{{exeExt}} {{.CLI_ARGS}}
test:
desc: Run tests
cmds:
- go test -race -failfast ./... {{.CLI_ARGS}}
test:record:
desc: Run tests and record all VCR cassettes again
aliases: [record]
cmds:
- rm -r pkg/agent/testdata
- go test -v -count=1 -timeout=1h ./pkg/agent
fmt:
desc: Run gofumpt
cmds:
- gofumpt -w .
fmt:html:
desc: Run prettier on HTML/CSS/JS files
cmds:
- prettier --write internal/cmd/stats/index.html internal/cmd/stats/index.css internal/cmd/stats/index.js
modernize:
desc: Run modernize
cmds:
- go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix -test ./...
dev:
desc: Run with profiling enabled
env:
PHOSPHOR_PROFILE: true
cmds:
- go run .
install:
desc: Install the application
vars:
LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/hackafterdark/phosphor/internal/version.Version={{.VERSION}} -X github.com/hackafterdark/phosphor/pkg/phosphordocs.Version={{.VERSION}}"{{end}}'
cmds:
- task: fetch-tags
- go install {{.LDFLAGS}} -v .
sources:
- ./**/*.go
- go.mod
- pkg/agent/**/*.md
- pkg/agent/**/*.md.tpl
- pkg/agent/hyper/provider.json
- pkg/phosphordocs/content/**
profile:cpu:
desc: 10s CPU profile
cmds:
- go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
profile:heap:
desc: Heap profile
cmds:
- go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
profile:allocs:
desc: Allocations profile
cmds:
- go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
schema:
desc: Generate JSON schema for configuration
cmds:
- go run main.go schema > schema.json
- echo "Generated schema.json"
generates:
- schema.json
hyper:
desc: Update Hyper embedded provider.json
cmds:
- go generate ./pkg/agent/hyper/...
generates:
- ./pkg/agent/hyper/provider.json
docs:embed:
desc: Regenerate the embedded docs corpus (pkg/phosphordocs/content) from docs/
cmds:
- go run github.com/hackafterdark/phosphor/pkg/phosphordocs/gen
sources:
- docs/**/*
- pkg/phosphordocs/gen/*.go
- pkg/phosphordocs/allowlist.go
- go.mod
generates:
- pkg/phosphordocs/content/**
docs:embed:check:
desc: Fail if the embedded docs corpus has drifted from the canonical docs/
cmds:
- go test -count=1 github.com/hackafterdark/phosphor/pkg/phosphordocs -run TestDriftGuard
release:
desc: Create and push a new tag following semver
vars:
NEXT:
sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
prompt: "This will release {{.NEXT}}. Continue?"
preconditions:
- sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
msg: Not on main branch
- sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
msg: "Git is dirty"
- sh: "go test -count=1 github.com/hackafterdark/phosphor/pkg/phosphordocs -run TestDriftGuard"
msg: "Embedded docs corpus is stale relative to docs/ — run `task docs:embed` and commit pkg/phosphordocs/content"
- sh: 'gh run list --workflow build.yml --branch main --commit $(git rev-parse HEAD) --status success --json conclusion -q ".[0].conclusion" | grep -q success'
msg: "CI build (build.yml) for this commit failed or not present — push to main and wait for it to go green"
cmds:
- task: fetch-tags
- git commit --allow-empty -m "{{.NEXT}}"
- git tag --annotate --sign -m "{{.NEXT}}" {{.NEXT}} {{.CLI_ARGS}}
- echo "Pushing {{.NEXT}}..."
- git push origin main --follow-tags
fetch-tags:
cmds:
- git tag -d nightly || true
- git fetch --tags
deps:
desc: Update Fantasy and Catwalk
env:
# The Go proxy takes a bit of time to see the latest release. Setting
# these bypass it to ensure we can update to a release from a minute ago.
GOPROXY: direct
GONOSUMDB: charm.land/*
cmds:
- go get charm.land/fantasy@latest
- go get charm.land/catwalk@latest
- go mod tidy
swag:
desc: Generate OpenAPI spec from swag annotations
cmds:
- go run github.com/swaggo/swag/cmd/swag@v1.16.6 init --generalInfo main.go --dir . --output internal/swagger --packageName swagger --parseDependency --parseInternal --parseDepth 5
sources:
- internal/server/*.go
- internal/proto/*.go
- main.go
generates:
- internal/swagger/docs.go
- internal/swagger/swagger.json
- internal/swagger/swagger.yaml
sqlc:
desc: Generate code using SQLC
cmds:
- sqlc generate