-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
172 lines (146 loc) · 3.58 KB
/
Copy pathTaskfile.yml
File metadata and controls
172 lines (146 loc) · 3.58 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
version: '3'
includes:
helm:
taskfile: ./helm/Taskfile.yml
dir: ./helm
vars:
IMAGE_REPO: ghcr.io/udl-tf/restart-controller
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
tasks:
default:
desc: List all available tasks
cmds:
- task --list
# Development tasks
dev:fmt:
desc: Format Go code
cmds:
- go fmt ./...
dev:vet:
desc: Run go vet
cmds:
- go vet ./...
dev:tidy:
desc: Tidy go modules
cmds:
- go mod tidy
dev:lint:
desc: Run golangci-lint (requires golangci-lint installed)
cmds:
- golangci-lint run ./...
dev:test:
desc: Run Go tests
cmds:
- go test -v -race -coverprofile=coverage.out ./...
dev:test-coverage:
desc: Run tests and show coverage
deps: [dev:test]
cmds:
- go tool cover -html=coverage.out
dev:all:
desc: Run all development checks
cmds:
- task: dev:tidy
- task: dev:fmt
- task: dev:vet
- task: dev:test
# Docker tasks
docker:build:
desc: Build Docker image
cmds:
- docker build -t {{.IMAGE_REPO}}:{{.VERSION}} .
- docker tag {{.IMAGE_REPO}}:{{.VERSION}} {{.IMAGE_REPO}}:latest
docker:push:
desc: Push Docker image to registry
deps: [docker:build]
cmds:
- docker push {{.IMAGE_REPO}}:{{.VERSION}}
- docker push {{.IMAGE_REPO}}:latest
docker:run:
desc: Run Docker container locally (dry-run mode)
cmds:
- docker run --rm {{.IMAGE_REPO}}:latest
# Kubernetes tasks
k8s:apply-test:
desc: Apply test pod with restart label
cmds:
- |
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: test-restart-pod
labels:
restart: tf2
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
EOF
k8s:delete-test:
desc: Delete test pod
cmds:
- kubectl delete pod test-restart-pod --ignore-not-found=true
k8s:logs:
desc: Show controller logs
cmds:
- kubectl logs -n restart-controller -l app.kubernetes.io/name=restart-controller -f
k8s:status:
desc: Show controller status
cmds:
- kubectl get pods -n restart-controller -l app.kubernetes.io/name=restart-controller
- kubectl get all -n restart-controller
# Build and publish tasks
build:
desc: Build both Docker image and Helm chart
cmds:
- task: docker:build
- task: helm:package
publish:
desc: Publish Docker image and Helm chart (requires authentication)
cmds:
- task: docker:push
- task: helm:push
# CI/CD tasks
ci:
desc: Run CI checks (lint, test, build)
cmds:
- task: dev:all
- task: docker:build
- task: helm:all
release:
desc: Create a new release (build, test, and publish)
cmds:
- echo "Creating release version {{.VERSION}}"
- task: ci
- task: publish
- echo "Release {{.VERSION}} completed!"
# Clean tasks
clean:dist:
desc: Clean dist directory
cmds:
- rm -rf dist
clean:coverage:
desc: Clean coverage files
cmds:
- rm -f coverage.out
clean:all:
desc: Clean all generated files
cmds:
- task: clean:dist
- task: clean:coverage
# Quick tasks
quick:test:
desc: Quick test - format, vet, and test
cmds:
- task: dev:fmt
- task: dev:vet
- task: dev:test
quick:deploy:
desc: Quick deploy to local cluster
cmds:
- task: docker:build
- task: helm:install-dev