forked from datarobot-oss/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
170 lines (151 loc) · 4.68 KB
/
Taskfile.yaml
File metadata and controls
170 lines (151 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
version: "3"
vars:
VERSION_PACKAGE: "github.com/datarobot/cli/internal/version"
VERSION: { sh: "git describe --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.6.0"
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: [lint]
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: "Lint the source code"
deps: [install-tools]
cmds:
- echo "🧹 Cleaning go.mod…"
- go mod tidy
- echo "🧹 Formatting files…"
- go fmt ./...
- "{{.BIN_DIR}}/gofumpt -l -w ."
- echo "🧹 Vetting go.mod…"
- go vet ./...
- echo "🧹 GoCI Lint…"
- "{{.BIN_DIR}}/golangci-lint run ./..."
- echo "🧹 Check GoReleaser…"
- "{{.BIN_DIR}}/goreleaser check"
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-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-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