Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
209 lines (178 loc) · 5.96 KB
/
Copy pathTaskfile.yml
File metadata and controls
209 lines (178 loc) · 5.96 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
# Taskfile for tygor
# Bootstrap: go run github.com/go-task/task/v3/cmd/task@v3.45.4 setup
# https://taskfile.dev/
version: '3'
vars:
TOOLS_DIR: "{{.ROOT_DIR}}/.tools"
AQUA_ROOT: "{{.ROOT_DIR}}/.tools/aqua-pkgs"
STATICCHECK_VERSION: v0.8.1
env:
GOBIN: "{{.TOOLS_DIR}}"
AQUA_CONFIG: "{{.ROOT_DIR}}/aqua.yaml"
AQUA_ROOT_DIR: "{{.AQUA_ROOT}}"
PATH: "{{.TOOLS_DIR}}:{{.AQUA_ROOT}}/bin:{{.Env.PATH}}"
tasks:
# ============================================================================
# Setup
# ============================================================================
setup:
desc: Bootstrap project (only requires Go)
cmds:
- go install github.com/go-task/task/v3/cmd/task@v3.45.4
- go install github.com/aquaproj/aqua/v2/cmd/aqua@v2.54.1
- go install honnef.co/go/tools/cmd/staticcheck@{{.STATICCHECK_VERSION}}
- "{{.TOOLS_DIR}}/aqua i"
- "{{.TOOLS_DIR}}/aqua exec -- bun install --frozen-lockfile --ignore-scripts"
sources:
- aqua.yaml
- package.json
# ============================================================================
# Development
# ============================================================================
default:
desc: Run tests and lint
deps: [test, lint]
test:
desc: Run Go tests
cmds:
- GOWORK=off go test ./...
test:e2e:
desc: Run cross-language end-to-end tests
cmds:
- GOWORK=off go test -count=1 -tags=e2e ./e2e
lint:
desc: Run go vet and staticcheck
cmds:
- GOWORK=off go vet ./...
- GOWORK=off {{.TOOLS_DIR}}/staticcheck ./...
fmt:
desc: Format Go code
cmds:
- gofmt -w .
fmt:check:
desc: Check Go formatting
cmds:
- cmd: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "Files need formatting:"
echo "$unformatted"
exit 1
fi
gen:
desc: Generate client error types from Go source
cmds:
- go run ./cmd/tygor gen packages/client/generated -t ErrorCode -t Error -p tygor.dev/tygor
typecheck:docs:
desc: Type-check documentation examples
cmds:
- bun x typescript --noEmit --project doc/examples/tsconfig.json
typecheck:client:
desc: Type-check client package (including tests)
cmds:
- bun x typescript --noEmit --project packages/client/tsconfig.test.json
typecheck:vite-plugin:
desc: Type-check vite plugin
dir: packages/vite-plugin
cmds:
- bun run --silent typecheck
# ============================================================================
# Precommit checks (run with: task precommit)
# ============================================================================
precommit:
desc: Run all precommit checks
deps:
- fmt:check
cmds:
- task: precommit:client-package
- task: precommit:parallel
- echo "All precommit checks passed."
precommit:parallel:
internal: true
deps:
- precommit:test
- test:e2e
- precommit:lint
- precommit:typecheck
- precommit:vite-plugin
- precommit:devserver
- precommit:client-gen
- precommit:version-sync
- precommit:client-bundle
precommit:test:
internal: true
cmds:
- cmd: output=$(GOWORK=off go test ./... 2>&1) || (echo "$output"; exit 1)
silent: true
precommit:lint:
internal: true
cmds:
- cmd: output=$(GOWORK=off go vet ./... 2>&1) || (echo "$output"; exit 1)
silent: true
- cmd: output=$(GOWORK=off {{.TOOLS_DIR}}/staticcheck ./... 2>&1) || (echo "$output"; exit 1)
silent: true
precommit:typecheck:
internal: true
cmds:
- bun x typescript --noEmit --project doc/examples/tsconfig.json
- bun x typescript --noEmit --project packages/client/tsconfig.test.json
precommit:client-package:
internal: true
cmds:
- bun run --silent build:client
- bun test packages/client/runtime.test.ts
precommit:vite-plugin:
internal: true
deps: [precommit:client-bundle]
dir: packages/vite-plugin
cmds:
- bun run --silent typecheck
- bun run --silent test
precommit:devserver:
internal: true
cmds:
- go run ./cmd/tygor gen --check -p ./cmd/tygor/internal/dev ./packages/vite-plugin/src/devserver
precommit:client-gen:
internal: true
cmds:
- go run ./cmd/tygor gen --check packages/client/generated -t ErrorCode -t Error -p tygor.dev/tygor
precommit:version-sync:
internal: true
cmds:
- cmd: |
if ! diff -q VERSION cmd/tygor/VERSION > /dev/null 2>&1; then
echo "ERROR: VERSION files are out of sync"
echo " VERSION: $(cat VERSION)"
echo " cmd/tygor/VERSION: $(cat cmd/tygor/VERSION)"
echo "Run: cp VERSION cmd/tygor/VERSION"
exit 1
fi
precommit:client-bundle:
internal: true
dir: packages/vite-plugin
cmds:
- bun run --silent build:client
- cmd: |
if [ -d {{.ROOT_DIR}}/.jj ]; then
changes=$(jj diff --name-only packages/vite-plugin/src/generated/client-bundle.ts 2>/dev/null | grep -v '^$' || true)
else
changes=$(git diff --name-only packages/vite-plugin/src/generated/client-bundle.ts 2>/dev/null || true)
fi
if [ -n "$changes" ]; then
echo ""
echo "ERROR: Client bundle out of sync with packages/vite-plugin/src/client/ sources."
echo "Run 'cd packages/vite-plugin && bun run build' to update."
echo ""
exit 1
fi
# ============================================================================
# CI & Release
# ============================================================================
ci:local:
desc: Run GitHub Actions workflow locally via Docker
cmds:
- act --container-architecture linux/amd64
release:
desc: "Release packages (usage: task release -- patch|minor|major)"
cmds:
- ./release.bash {{.CLI_ARGS}}