-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
138 lines (119 loc) · 3.55 KB
/
Taskfile.yml
File metadata and controls
138 lines (119 loc) · 3.55 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
version: '3'
vars:
PROJECT_ROOT:
sh: pwd
GOBIN: '{{.PROJECT_ROOT}}/bin'
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 "Template - Liquid/Django-style template engine"
- 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
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 ./...
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 (deps, format, vet, lint, test)
cmds:
- task: deps
- task: fmt
- task: vet
- task: lint
- task: test
- echo "All verification steps completed successfully ✅"