-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
220 lines (196 loc) · 6.38 KB
/
Taskfile.yaml
File metadata and controls
220 lines (196 loc) · 6.38 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
212
213
214
215
216
217
218
219
220
version: "3"
vars:
VERSION_PACKAGE: "github.com/datarobot/cli/internal/version"
VERSION: { sh: 'git describe --dirty --tags --long --always --abbrev=15' }
COMMIT: { sh: "git describe --dirty --long --always --abbrev=15" }
BUILD_DATE: { sh: 'date -u +"%Y-%m-%dT%H:%M:%SZ"' }
LDFLAGS_COMMON: |
-X {{.VERSION_PACKAGE}}.GitCommit={{.COMMIT}} \
-X {{.VERSION_PACKAGE}}.Version={{.VERSION}} \
-X {{.VERSION_PACKAGE}}.BuildDate={{.BUILD_DATE}}
BIN_DIR: "$PWD/tmp/bin"
GOLANGCI_LINT_VERSION: "v2.11.4"
dotenv: [".env"]
tasks:
help:
desc: "🛠️ Dev Commands"
cmds:
- echo "🛠️ Dev Commands"
- task --list
default:
cmds:
- task help
install-tools:
silent: true
desc: "Install static checkers & other binaries"
cmds:
- |
echo "🚚 Downloading tools…"
export GOBIN={{.BIN_DIR}}
go install mvdan.cc/gofumpt@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{.BIN_DIR}} {{.GOLANGCI_LINT_VERSION}}
go install github.com/goreleaser/goreleaser/v2@latest
status:
- "{{.BIN_DIR}}/gofumpt --version"
- "{{.BIN_DIR}}/golangci-lint --version"
- "{{.BIN_DIR}}/goreleaser --version"
uninstall-tools:
silent: true
desc: "Uninstall static checkers & other binaries"
cmds:
- "rm {{.BIN_DIR}}/gofumpt"
- "rm {{.BIN_DIR}}/golangci-lint"
- "rm {{.BIN_DIR}}/goreleaser"
dev-init:
silent: true
desc: "Initialize development environment"
deps: [delint]
cmds:
- |
export GOBIN={{.BIN_DIR}}
echo "🔧 Initializing development environment…"
mkdir -p {{.BIN_DIR}}
echo "🛠️ Installing tools…"
go get github.com/stretchr/testify@latest
echo "✅ Development environment initialized."
lint:
silent: true
desc: "Check for lint issues (does not modify files)"
deps: [install-tools]
cmds:
- echo "🧹 Checking go.mod…"
- go mod tidy -diff
- echo "🧹 Checking formatting…"
- "{{.BIN_DIR}}/gofumpt -l -d ."
- echo "🧹 Vetting…"
- go vet ./...
- echo "🧹 Linting…"
- "{{.BIN_DIR}}/golangci-lint run ./..."
- echo "🧹 Checking GoReleaser config…"
- "{{.BIN_DIR}}/goreleaser check"
delint:
silent: true
desc: "Fix lint and formatting issues"
deps: [install-tools]
cmds:
- echo "🧹 Cleaning go.mod…"
- go mod tidy
- echo "🧹 Formatting files…"
- go fmt ./...
- "{{.BIN_DIR}}/gofumpt -l -w ."
- echo "🧹 Fixing lint issues…"
- "{{.BIN_DIR}}/golangci-lint run --fix ./..."
run:
silent: true
desc: "Run CLI"
cmds:
- |
if [ -z "{{.CLI_ARGS}}" ]; then
go run -ldflags "{{.LDFLAGS_COMMON}}" main.go
else
go run -ldflags "{{.LDFLAGS_COMMON}}" main.go -- {{.CLI_ARGS}}
fi
build:
silent: true
desc: "Build CLI"
cmds:
- 'echo "🔨 Building binary…"'
- 'echo "• Version: {{.VERSION}}"'
- 'echo "• Commit: {{.COMMIT}}"'
- 'echo "• Build Date: {{.BUILD_DATE}}"'
- 'go build -ldflags "{{.LDFLAGS_COMMON}}" -o ./dist/dr'
- 'echo "✨ Binary built at ./dist/dr"'
gen:
silent: true
desc: "Generate Go code"
cmds:
- go generate ./...
gen-check:
silent: true
desc: "Check if Go code needs to be generated"
deps: [gen]
cmds:
- git diff --exit-code
test:
silent: true
desc: "Run tests"
cmds:
- go test -count=1 -race -shuffle=on -coverprofile=coverage.txt ./...
test-no-coverage:
silent: true
desc: "Run tests without coverage"
cmds:
- go test -count=1 -race -shuffle=on ./...
test-coverage:
silent: true
desc: "Run tests with coverage rendered in HTML"
cmds:
- task test
- go tool cover -html=coverage.txt -o coverage.html
- |
{{if eq OS "darwin"}}
open ./coverage.html
{{else if eq OS "linux"}}
xdg-open ./coverage.html
{{else}}
echo "Running on OS other than Mac/Linux - assuming Windows."
start ./coverage.html
{{end}}
smoke-test:
desc: "Run smoke tests"
cmds:
- ./smoke_test_scripts/run_smoke_test.sh {{if .DR_API_TOKEN}}{{.DR_API_TOKEN}}{{else}}$DR_API_TOKEN{{end}}
smoke-test-self-update:
desc: "Run self-update smoke tests"
cmds:
- ./smoke_test_scripts/run_self_update_smoke_test.sh
smoke-test-plugin-update:
desc: "Run plugin auto-update-check smoke tests (requires internet, no API token needed)"
deps: [build]
cmds:
- ./smoke_test_scripts/run_plugin_update_smoke_test.sh
smoke-test-windows:
desc: "Run smoke tests (Windows)"
cmds:
- powershell.exe -ExecutionPolicy Bypass -File ./smoke_test_scripts/windows/run_smoke_test.ps1 {{if .DR_API_TOKEN}}{{.DR_API_TOKEN}}{{else}}$env:DR_API_TOKEN{{end}}
docs-serve:
silent: true
desc: "Serve documentation site locally"
dir: docs
cmds:
- echo "📚 Starting documentation server…"
- uv sync
- echo "🌐 Open http://localhost:8000 in your browser"
- uv run mkdocs serve
copyright:
silent: true
desc: "Apply copyrights to all files"
aliases:
- license
cmds:
- echo "🧹 Applying license headers"
- |
docker run --rm \
-v $PWD:/github/workspace \
ghcr.io/apache/skywalking-eyes/license-eye:4021a396bf07b2136f97c12708476418a8157d72 \
-v info -c .licenserc.yaml header fix
copyright-year:
silent: true
platforms: [linux, darwin]
desc: "Update copyright year in all source files to the current year"
vars:
TO_YEAR:
sh: date +%Y
FROM_YEAR:
sh: echo $(($(date +%Y) - 1))
FIND_GO_FILES: "find cmd internal tui main.go -type f -name '*.go'"
SED_EXPR: "s/Copyright {{.FROM_YEAR}} DataRobot/Copyright {{.TO_YEAR}} DataRobot/g"
COUNT:
sh: "{{.FIND_GO_FILES}} -exec grep -l 'Copyright {{.FROM_YEAR}} DataRobot' {} + 2>/dev/null | wc -l | tr -d ' '"
cmds:
- echo "Updating copyright year from {{.FROM_YEAR}} to {{.TO_YEAR}}"
- platforms: [darwin]
cmd: "{{.FIND_GO_FILES}} -exec sed -i '' '{{.SED_EXPR}}' {} +"
- platforms: [linux]
cmd: "{{.FIND_GO_FILES}} -exec sed -i '{{.SED_EXPR}}' {} +"
- echo "{{.COUNT}} files were updated!"