Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
290 lines (249 loc) · 9.5 KB
/
Copy pathTaskfile.yml
File metadata and controls
290 lines (249 loc) · 9.5 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
version: '3'
vars:
BINARY_NAME: cm
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
BUILD_TIME:
sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
LDFLAGS: -s -w -X main.Version={{.VERSION}} -X main.BuildTime={{.BUILD_TIME}}
tasks:
default:
desc: Show available tasks
cmds:
- task --list
# ── Testing ────────────────────────────────────────────────────────
test:
desc: Run all tests
cmds:
- go test ./... -v
test:coverage:
desc: Run tests with coverage report
cmds:
- go test ./... -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- echo 'Coverage report generated at coverage.html'
# ── Build ──────────────────────────────────────────────────────────
build:
desc: Build CLI for current platform
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY_NAME}} ./cmd/calcmark
- echo 'Built {{.BINARY_NAME}}'
build:all:
internal: true
deps:
- build:linux
- build:darwin
- build:windows
build:linux:
internal: true
cmds:
- mkdir -p dist
- GOOS=linux GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o dist/{{.BINARY_NAME}}-linux-amd64 ./cmd/calcmark
- GOOS=linux GOARCH=arm64 go build -ldflags "{{.LDFLAGS}}" -o dist/{{.BINARY_NAME}}-linux-arm64 ./cmd/calcmark
- echo 'Built Linux binaries'
build:darwin:
internal: true
cmds:
- mkdir -p dist
- GOOS=darwin GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o dist/{{.BINARY_NAME}}-darwin-amd64 ./cmd/calcmark
- GOOS=darwin GOARCH=arm64 go build -ldflags "{{.LDFLAGS}}" -o dist/{{.BINARY_NAME}}-darwin-arm64 ./cmd/calcmark
- echo 'Built macOS binaries'
build:windows:
internal: true
cmds:
- mkdir -p dist
- GOOS=windows GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o dist/{{.BINARY_NAME}}-windows-amd64.exe ./cmd/calcmark
- echo 'Built Windows binary'
build:vscode:
desc: Build the VS Code extension (and cm binary)
deps:
- build
dir: editors/vscode-calcmark
cmds:
- npm install --no-audit --no-fund
- npm run compile
- echo '✓ VS Code extension built to editors/vscode-calcmark/out/'
run:vscode:
desc: Build and launch VS Code with the CalcMark extension loaded
deps:
- build:vscode
cmds:
- pkill -f "extensionDevelopmentPath" 2>/dev/null || true
- rm -rf ~/Library/Application\ Support/Code/CachedExtensionVSIXs 2>/dev/null || true
- echo 'Launching VS Code with CalcMark extension...'
- echo 'Open any .cm file to test.'
- |
ROOT="{{.ROOT_DIR}}"
CODE=""
for candidate in \
"$(command -v code 2>/dev/null)" \
"/usr/local/bin/code" \
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" \
"$(command -v cursor 2>/dev/null)"; do
if [ -x "$candidate" ]; then
CODE="$candidate"
break
fi
done
if [ -z "$CODE" ]; then
echo "Error: VS Code not found. Install the 'code' CLI: open VS Code, Cmd+Shift+P, 'Shell Command: Install code command in PATH'"
exit 1
fi
PATH="$ROOT:$PATH" "$CODE" --extensionDevelopmentPath="$ROOT/editors/vscode-calcmark" --new-window "$ROOT"
publish:vscode:
desc: Publish the VS Code extension to the marketplace (stable)
deps:
- build:vscode
dir: editors/vscode-calcmark
cmds:
- npx vsce publish
publish:vscode:pre:
desc: Publish the VS Code extension as a pre-release
deps:
- build:vscode
dir: editors/vscode-calcmark
cmds:
- npx vsce publish --pre-release
# ── Development ────────────────────────────────────────────────────
dev:
desc: Run in development mode (use -- to pass args, e.g. task dev -- eval file.cm)
cmds:
- go run ./cmd/calcmark {{.CLI_ARGS}}
# ── Quality ────────────────────────────────────────────────────────
lint:
desc: Run basic linters (fmt, vet)
cmds:
- go fmt ./...
- go vet ./...
- echo '✓ Basic linting passed'
modernize:
internal: true
cmds:
- go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest ./...
- echo '✓ Modernize check passed'
staticcheck:
internal: true
cmds:
- go run honnef.co/go/tools/cmd/staticcheck@latest ./...
- echo '✓ Staticcheck passed'
quality:
desc: Run all quality checks (recommended before commit)
cmds:
- task: lint
- task: modernize
- task: staticcheck
- echo '✓ All quality checks passed'
security:
desc: Run security-focused tests
cmds:
- go test -v -run "TestValidateFilePath|TestValidateReadFilePath|TestValidateFileContent|TestValidateStdinContent|TestReadFilePath" ./cmd/calcmark/cmd
- go test -v ./cmd/calcmark/filecheck
- go test -v -run "TestSecurity" ./spec/parser
- go test -v -run "Fuzz" -fuzz=. -fuzztime=5s ./cmd/calcmark/filecheck
- go test -v -run "Fuzz" -fuzz=. -fuzztime=5s ./spec/lexer
- go test -v -run "Fuzz" -fuzz=. -fuzztime=5s ./spec/parser
- go test -v -run "Fuzz" -fuzz=. -fuzztime=5s ./spec/document
- echo '✓ Security tests passed'
# ── Benchmarks ─────────────────────────────────────────────────────
bench:
internal: true
cmds:
- go test ./... -run='^$' -bench=. -benchmem
# ── Maintenance ────────────────────────────────────────────────────
clean:
desc: Clean build artifacts
cmds:
- rm -f {{.BINARY_NAME}}
- rm -rf dist/
- rm -f coverage.out coverage.html
- go clean -cache
deps:update:
desc: Update dependencies
cmds:
- go get -u ./...
- go mod tidy
# ── Website ────────────────────────────────────────────────────────
generate-docs:
internal: true
cmds:
- go run ./cmd/docgen
- go run ./cmd/doceval
sources:
- spec/features/registry.go
- site/content/docs/**/*.md
- testdata/examples/*.cm
generates:
- site/data/features.json
- site/data/cm_results.json
- site/content/docs/examples/*/full.md
og-image:
desc: Regenerate OG image from lockup SVG (requires librsvg)
preconditions:
- sh: command -v rsvg-convert
msg: "rsvg-convert not found — install with: brew install librsvg"
cmds:
- rsvg-convert site/assets/images/og.svg -w 1200 -h 630 -o site/static/images/og.png
sources:
- site/assets/images/og.svg
generates:
- site/static/images/og.png
site:
desc: Start Hugo dev server for the website
deps:
- generate-docs
cmds:
- hugo server --source site --buildDrafts
site:build:
desc: Build the website
deps:
- generate-docs
cmds:
- hugo --source site --minify
- echo 'Site built to site/public/'
record-demos:
desc: Regenerate all demo GIFs for the website
sources:
- scripts/*.tape
cmds:
- for: sources
cmd: vhs {{.ITEM}}
- echo '✓ All demos regenerated to site/static/images/'
# ── Examples ───────────────────────────────────────────────────────
example:dates:
internal: true
cmds:
- echo "today + 7 days" | ./{{.BINARY_NAME}} eval
- echo "Dec 25 2025 + 30 days" | ./{{.BINARY_NAME}} eval
example:units:
internal: true
cmds:
- echo "5 kg + 10 lb" | ./{{.BINARY_NAME}} eval
- echo "10 meters + 5 feet" | ./{{.BINARY_NAME}} eval
example:
desc: Run all examples
deps:
- build
cmds:
- task: example:dates
- task: example:units
# ── Release ────────────────────────────────────────────────────────
release:
desc: Build release binaries (runs all quality checks first)
cmds:
- task: clean
- task: quality # lint + modernize + staticcheck
- task: test # All tests must pass
- task: bench # Benchmark regressions
- task: security # Security tests + fuzzing
- task: build:all
- echo 'Release binaries built in dist/'
release:dogfood:
desc: |
Verify the LOCAL go-calcmark working tree against cmw's full task check
before tagging. Catches downstream regressions while the version is still
cheap (no published tag to live with). Always restores cmw's go.mod / go.sum
on exit. Runs cmw's pre-push gate only — Playwright e2e is excluded by
design, so this is not a flaky-test surface. Set CMW_PATH to override the
default sibling directory location.
cmds:
- bash scripts/release-dogfood.sh