-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
118 lines (101 loc) · 3.3 KB
/
Taskfile.yaml
File metadata and controls
118 lines (101 loc) · 3.3 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
version: '3'
vars:
TOOL_DIR: "{{.USER_WORKING_DIR}}/bin"
IMAGE_NAME: "ghcr.io/datum-cloud/search"
IMAGE_TAG: "dev"
tasks:
default:
desc: List all available tasks
cmds:
- task --list
silent: true
# Build tasks
build:
desc: Build the search binary
cmds:
- |
set -e
echo "Building search..."
mkdir -p {{.TOOL_DIR}}
# Get git information for version injection
GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
VERSION="v0.0.0-dev+${GIT_COMMIT:0:7}"
GIT_TREE_STATE="clean"
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
GIT_TREE_STATE="dirty"
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || echo "unknown")
echo "Version: ${VERSION}, Commit: ${GIT_COMMIT:0:7}, Tree: ${GIT_TREE_STATE}"
go build \
-ldflags="-X 'go.datum.net/search/internal/version.Version=${VERSION}' \
-X 'go.datum.net/search/internal/version.GitCommit=${GIT_COMMIT}' \
-X 'go.datum.net/search/internal/version.GitTreeState=${GIT_TREE_STATE}' \
-X 'go.datum.net/search/internal/version.BuildDate=${BUILD_DATE}'" \
-o {{.TOOL_DIR}}/search ./cmd/search
echo "✅ Binary built: {{.TOOL_DIR}}/search"
silent: true
# Development tasks
dev:build:
desc: Build the Search server container image for development
silent: true
cmds:
- |
set -e
echo "Building Search server container image: {{.IMAGE_NAME}}:{{.IMAGE_TAG}}"
# Get git information for version injection
GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
VERSION="v0.0.0-dev+${GIT_COMMIT:0:7}"
GIT_TREE_STATE="clean"
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
GIT_TREE_STATE="dirty"
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || echo "unknown")
docker build \
--build-arg VERSION="${VERSION}" \
--build-arg GIT_COMMIT="${GIT_COMMIT}" \
--build-arg GIT_TREE_STATE="${GIT_TREE_STATE}" \
--build-arg BUILD_DATE="${BUILD_DATE}" \
-t {{.IMAGE_NAME}}:{{.IMAGE_TAG}} \
.
echo "✅ Container image built: {{.IMAGE_NAME}}:{{.IMAGE_TAG}}"
# Code generation tasks
generate:
desc: Generate deepcopy and client code
cmds:
- |
set -e
echo "Generating code..."
# Run code generators
go run k8s.io/code-generator/cmd/deepcopy-gen \
--go-header-file hack/boilerplate.go.txt \
--output-file zz_generated.deepcopy.go \
--bounding-dirs go.datum.net/search/pkg/apis \
go.datum.net/search/pkg/apis/search/v1alpha1
echo "✅ Code generation complete"
silent: true
# Test tasks
test:
desc: Run unit tests
cmds:
- go test -v ./...
# Cleanup tasks
clean:
desc: Clean build artifacts
cmds:
- rm -rf {{.TOOL_DIR}}
- rm -rf .task
- echo "✅ Cleaned build artifacts"
silent: true
# Format and lint
fmt:
desc: Format Go code
cmds:
- go fmt ./...
- echo "✅ Code formatted"
silent: true
vet:
desc: Run go vet
cmds:
- go vet ./...
- echo "✅ Vet complete"
silent: true