-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
211 lines (181 loc) · 5.56 KB
/
Taskfile.yml
File metadata and controls
211 lines (181 loc) · 5.56 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
version: '3'
vars:
PROJECT_ROOT:
sh: pwd
GOBIN: '{{.PROJECT_ROOT}}/bin'
BINARY_NAME: defuddle
CLI_FOLDER: cmd/defuddle
GOLANGCI_LINT_BINARY: '{{.GOBIN}}/golangci-lint'
REQUIRED_GOLANGCI_LINT_VERSION:
sh: cat .golangci.version 2>/dev/null || echo "2.9.0"
GOLANGCI_LINT_VERSION:
sh: '{{.GOLANGCI_LINT_BINARY}} version --format short 2>/dev/null || {{.GOLANGCI_LINT_BINARY}} version --short 2>/dev/null || echo "not-installed"'
env:
GOBIN: '{{.GOBIN}}'
tasks:
default:
desc: Run lint and test
cmds:
- task: lint
- task: test
help:
desc: Show this help message
cmds:
- echo "defuddle-go - Web content extraction library"
- echo "Available targets:"
- task --list
silent: true
clean:
desc: Clean build artifacts and caches
cmds:
- echo "Cleaning build artifacts..."
- rm -rf {{.GOBIN}}
- go clean -cache -testcache || true
submodules:
desc: Initialize and update git submodules (required for reference library)
cmds:
- echo "Initializing git submodules..."
- git submodule update --init --recursive
deps:
desc: Download Go module dependencies
cmds:
- echo "Downloading dependencies..."
- go mod download
- go mod tidy
deps:update:
desc: Update all dependencies
cmds:
- echo "Updating dependencies..."
- go get -u ./... && go mod tidy
test:
desc: Run all tests with race detection
cmds:
- echo "Running all tests..."
- go test -race ./...
test-unit:
desc: Run unit tests only
cmds:
- echo "Running unit tests..."
- go test -race ./pkg/... ./internal/... .
test-coverage:
desc: Run tests with coverage report
cmds:
- echo "Running tests with coverage..."
- go test -race -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated at coverage.html"
test-verbose:
desc: Run tests with verbose output
cmds:
- echo "Running tests with verbose output..."
- go test -race -v ./...
bench:
desc: Run benchmarks
cmds:
- echo "Running benchmarks..."
- go test -bench=. -benchmem ./...
lint:
desc: Run all linters
deps:
- golangci-lint
- tidy-lint
install-golangci-lint:
desc: Install golangci-lint with the required version
cmds:
- mkdir -p {{.GOBIN}}
- |
if [ "{{.GOLANGCI_LINT_VERSION}}" != "{{.REQUIRED_GOLANGCI_LINT_VERSION}}" ]; then
echo "Installing golangci-lint v{{.REQUIRED_GOLANGCI_LINT_VERSION}} (current: {{.GOLANGCI_LINT_VERSION}})..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{.GOBIN}} v{{.REQUIRED_GOLANGCI_LINT_VERSION}}
echo "golangci-lint v{{.REQUIRED_GOLANGCI_LINT_VERSION}} installed successfully"
fi
status:
- test "{{.GOLANGCI_LINT_VERSION}}" = "{{.REQUIRED_GOLANGCI_LINT_VERSION}}"
golangci-lint:
desc: Run golangci-lint
deps:
- install-golangci-lint
cmds:
- '{{.GOLANGCI_LINT_BINARY}} version'
- echo "Running golangci-lint..."
- '{{.GOLANGCI_LINT_BINARY}} run --timeout=10m --path-prefix .'
tidy-lint:
desc: Check if go.mod and go.sum are tidy
cmds:
- echo "Checking go.mod and go.sum are tidy..."
- go mod tidy
- git diff --exit-code -- go.mod go.sum
fmt:
desc: Format Go code
cmds:
- echo "Formatting Go code..."
- go fmt ./...
vet:
desc: Run go vet
cmds:
- echo "Running go vet..."
- go vet ./...
verify:
desc: Run all verification steps (submodules, deps, format, vet, lint, test)
cmds:
- task: submodules
- task: deps
- task: fmt
- task: vet
- task: lint
- task: test
- echo "All verification steps completed successfully ✅"
dev:
desc: Quick development verification (deps, format, vet)
cmds:
- task: deps
- task: fmt
- task: vet
- echo "Development verification completed successfully"
build:
desc: Build the CLI binary
cmds:
- echo "Building {{.BINARY_NAME}}..."
- go build -o {{.GOBIN}}/{{.BINARY_NAME}} ./{{.CLI_FOLDER}}
- echo "Binary built at {{.GOBIN}}/{{.BINARY_NAME}}"
build-cli:
desc: Build the CLI binary (alias for build)
cmds:
- task: build
install-cli:
desc: Build and symlink CLI to $GOPATH/bin
deps:
- build
cmds:
- ln -sf {{.GOBIN}}/{{.BINARY_NAME}} $(go env GOPATH)/bin/{{.BINARY_NAME}}
- echo "{{.BINARY_NAME}} symlinked to $(go env GOPATH)/bin/{{.BINARY_NAME}}"
snapshot:
desc: Test release build locally
cmds:
- echo "Testing release build..."
- goreleaser release --snapshot --skip=publish --clean
release-test:
desc: Test release build without publishing (alias for snapshot)
cmds:
- task: snapshot
release-snapshot:
desc: Create a snapshot release (alias for snapshot)
cmds:
- task: snapshot
install-goreleaser:
desc: Install GoReleaser
cmds:
- echo "Installing GoReleaser..."
- go install github.com/goreleaser/goreleaser@latest
tag:
desc: Create and push a new tag (usage - task tag VERSION=v0.1.0)
cmds:
- |
if [ -z "{{.VERSION}}" ]; then
echo "VERSION is required. Usage: task tag VERSION=v1.0.0"
exit 1
fi
- echo "Creating tag {{.VERSION}}..."
- git tag -a {{.VERSION}} -m "Release {{.VERSION}}"
- git push origin {{.VERSION}}
- echo "Tag {{.VERSION}} created and pushed"