-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskfile.yml
More file actions
171 lines (150 loc) · 4.68 KB
/
Taskfile.yml
File metadata and controls
171 lines (150 loc) · 4.68 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
# Taskfile for iteratr
# Install Task: https://taskfile.dev/installation/
version: '3'
vars:
BINARY_NAME: iteratr
VERSION:
sh: echo "${VERSION:-dev}"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
BUILD_TIME:
sh: date -u '+%Y-%m-%d_%H:%M:%S'
CMD_DIR: ./cmd/iteratr
TEST_DIRS: ./...
tasks:
default:
desc: Show available tasks
cmds:
- task --list
silent: true
build:
desc: Build the binary
vars:
LDFLAGS: '-ldflags "-X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.BUILD_TIME}}"'
cmds:
- echo "Building {{.BINARY_NAME}}..."
- go build {{.LDFLAGS}} -o {{.BINARY_NAME}} {{.CMD_DIR}}
- echo "Build complete"
build-all:
desc: Build for all platforms
vars:
LDFLAGS: '-ldflags "-X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.BUILD_TIME}}"'
cmds:
- echo "Building for multiple platforms..."
- GOOS=linux GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-linux-amd64 {{.CMD_DIR}}
- GOOS=linux GOARCH=arm64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-linux-arm64 {{.CMD_DIR}}
- GOOS=darwin GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-darwin-amd64 {{.CMD_DIR}}
- GOOS=darwin GOARCH=arm64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-darwin-arm64 {{.CMD_DIR}}
- GOOS=windows GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-windows-amd64.exe {{.CMD_DIR}}
- echo "Multi-platform build complete"
install:
desc: Install the binary to GOPATH/bin
vars:
LDFLAGS: '-ldflags "-X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.BUILD_TIME}}"'
cmds:
- echo "Installing {{.BINARY_NAME}}..."
- go install {{.LDFLAGS}} {{.CMD_DIR}}
- echo "Install complete"
test:
desc: Run tests
cmds:
- echo "Running tests..."
- go test -v -race -coverprofile=coverage.out {{.TEST_DIRS}}
- echo "Tests complete"
test-short:
desc: Run tests without race detector (faster)
cmds:
- echo "Running tests (short)..."
- go test -v -short {{.TEST_DIRS}}
test-coverage:
desc: Run tests and show coverage report
deps: [test]
cmds:
- echo "Generating coverage report..."
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report created at coverage.html"
lint:
desc: Run linters (requires golangci-lint)
cmds:
- echo "Running linters..."
- golangci-lint run --timeout=5m ./internal/... ./cmd/iteratr/...
- echo "Lint complete"
preconditions:
- sh: which golangci-lint
msg: "golangci-lint not found. Install from https://golangci-lint.run/usage/install/"
fmt:
desc: Format code
cmds:
- echo "Formatting code..."
- go fmt {{.TEST_DIRS}}
- echo "Format complete"
vet:
desc: Run go vet
cmds:
- echo "Running go vet..."
- go vet {{.TEST_DIRS}}
- echo "Vet complete"
check:
desc: Run all checks (fmt, vet, lint, test)
deps: [fmt, vet, lint, test]
cmds:
- echo "All checks passed"
clean:
desc: Remove build artifacts
cmds:
- echo "Cleaning..."
- rm -f {{.BINARY_NAME}}
- rm -f {{.BINARY_NAME}}-*
- rm -f coverage.out coverage.html
- rm -rf .iteratr/
- echo "Clean complete"
deps:
desc: Download dependencies
cmds:
- echo "Downloading dependencies..."
- go mod download
- go mod tidy
- echo "Dependencies updated"
deps-update:
desc: Update dependencies
cmds:
- echo "Updating dependencies..."
- go get -u ./...
- go mod tidy
- echo "Dependencies updated"
run:
desc: Build and run iteratr (pass flags after --)
deps: [build]
cmds:
- ./{{.BINARY_NAME}} {{.CLI_ARGS}}
e2e:
desc: Run e2e test spec (no-commit, temp files only)
deps: [build]
cmds:
- ./{{.BINARY_NAME}} build --reset -s specs/test-spec.md -t .iteratr.test.template
doctor:
desc: Run iteratr doctor to check dependencies
deps: [build]
cmds:
- ./{{.BINARY_NAME}} doctor
dev:
desc: Quick dev cycle (fmt, vet, build)
deps: [fmt, vet, build]
cmds:
- echo "Development build ready"
ci:
desc: CI pipeline (deps, check, build)
deps: [deps, check, build]
cmds:
- echo "CI pipeline complete"
npm-publish:
desc: Publish to npm using latest git tag version
dir: npm
cmds:
- git fetch --tags origin
- |
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
VERSION=${LATEST_TAG#v}
echo "Publishing version $VERSION to npm..."
npm version $VERSION --no-git-tag-version
npm publish --access public