-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
175 lines (150 loc) · 4.59 KB
/
Copy pathTaskfile.yaml
File metadata and controls
175 lines (150 loc) · 4.59 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
version: "3"
vars:
BINARY_NAME: clicky
GO_VERSION: 1.23
MAIN_PACKAGE: ./cmd/clicky
tasks:
default:
desc: List available tasks
cmds:
- task --list
_ginkgo:
internal: true
desc: Base ginkgo command that passes through all CLI args
vars:
FLAGS: '{{.FLAGS | default ""}}'
PATHS: '{{.PATHS | default "./..."}}'
cmds:
- ginkgo run {{.FLAGS}} {{.CLI_ARGS}} {{.PATHS}}
env:
CGO_ENABLED: '{{.CGO_ENABLED | default "1"}}'
build:
desc: Build the binary
vars:
VERSION:
sh: git describe --tags --always 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'
DIRTY:
sh: if [ -n "$(git status --porcelain 2>/dev/null)" ]; then echo "true"; else echo "false"; fi
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.date={{.DATE}} -X main.dirty={{.DIRTY}}
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o {{.BINARY_NAME}} {{.MAIN_PACKAGE}}
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- ./{{.BINARY_NAME}}
install:
desc: Install the binary to $GOPATH/bin
deps:
- build
cmds:
- mv "./{{.BINARY_NAME}}" "$GOPATH/bin/"
sources:
- ./**/*.go
- go.mod
- go.sum
test:
desc: Run tests
cmds:
# Use centralized exclusion patterns aligned with linter exclusions
- go test -v -race -coverprofile=coverage.out $(go list ./... | grep -v '/examples/' | grep -v '/hack/' | grep -v '/vendor/' | grep -v '/build/' | grep -v '/dist/' | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v '/node_modules/')
env:
CGO_ENABLED: 1
test:unit:
desc: Run unit tests only
cmds:
# Use centralized exclusion patterns aligned with linter exclusions
- go test -v -short $(go list ./... | grep -v '/examples/' | grep -v '/hack/' | grep -v '/vendor/' | grep -v '/build/' | grep -v '/dist/' | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v '/node_modules/')
test:integration:
desc: Run integration tests
cmds:
# Use centralized exclusion patterns aligned with linter exclusions
- go test -v -run Integration $(go list ./... | grep -v '/examples/' | grep -v '/hack/' | grep -v '/vendor/' | grep -v '/build/' | grep -v '/dist/' | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v '/node_modules/')
test:coverage:
desc: Run tests with coverage report
cmds:
# Use centralized exclusion patterns aligned with linter exclusions
- go test -v -race -coverprofile=coverage.out $(go list ./... | grep -v '/examples/' | grep -v '/hack/' | grep -v '/vendor/' | grep -v '/build/' | grep -v '/dist/' | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v '/node_modules/')
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated at coverage.html"
lint:
desc: Run linters
cmds:
- cmd: golangci-lint run
ignore_error: true
- go vet ./...
- go mod tidy
fmt:
desc: Format code
cmds:
- go fmt ./...
- gofmt -s -w .
clean:
desc: Clean build artifacts
cmds:
- rm -f {{.BINARY_NAME}}
- rm -f coverage.out coverage.html
- rm -rf dist/
- go clean -cache
mod:
desc: Download and tidy modules
cmds:
- go mod download
- go mod tidy
run:
desc: Run the application
deps: [build]
cmds:
- ./{{.BINARY_NAME}} {{.CLI_ARGS}}
run:check:
desc: Run check on current directory
deps: [build]
cmds:
- ./{{.BINARY_NAME}} check {{.CLI_ARGS}}
run:init:
desc: Initialize .ARCHUNIT file
deps: [build]
cmds:
- ./{{.BINARY_NAME}} init {{.CLI_ARGS}}
dev:
desc: Run in development mode with live reload
cmds:
- air
docker:build:
desc: Build Docker image
cmds:
- docker build -t {{.BINARY_NAME}}:latest .
docker:run:
desc: Run Docker container
deps: [docker:build]
cmds:
- docker run --rm -v $(pwd):/workspace {{.BINARY_NAME}}:latest check /workspace
release:
desc: Create a new release
cmds:
- goreleaser release --clean
release:snapshot:
desc: Create a snapshot release
cmds:
- goreleaser release --snapshot --clean
deps:check:
desc: Check for dependency updates
cmds:
- go list -u -m all
deps:update:
desc: Update dependencies
cmds:
- go get -u ./...
- go mod tidy
ci:
desc: Run CI pipeline locally
cmds:
- task: fmt
- task: lint
- task: test
- task: build