-
Notifications
You must be signed in to change notification settings - Fork 4
/
Taskfile.yml
183 lines (163 loc) · 5.16 KB
/
Taskfile.yml
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
# See: https://taskfile.dev/#/usage
version: "3"
dotenv: ['.env']
output: prefixed
silent: true
vars:
DEFAULT_GO_PACKAGES:
sh: |
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go package(s)"')
LDFLAGS:
CLUSTER_NAME: jupyter-apis
CONTEXT_NAME: "k3d-{{.CLUSTER_NAME}}"
CONTAINER_IMAGE_NAME: jupyter-apis
CONTAINER_IMAGE_TAG: {sh: git rev-parse HEAD}
CONTAINER_IMAGE: "{{.CONTAINER_IMAGE_NAME}}:{{.CONTAINER_IMAGE_TAG}}"
KUBECTL: "kubectl --context={{.CONTEXT_NAME}}"
KUBEAPPLY: "{{.KUBECTL}} apply"
KUSTOMIZE: "{{.KUBEAPPLY}} --kustomize"
KUBEWAIT: "{{.KUBECTL}} wait"
KUBEWAIT_AVAIL: "{{.KUBEWAIT}} --for=condition=available"
KUBEWAIT_READY: "{{.KUBEWAIT}} --for=condition=ready"
KUBECREATE: "{{.KUBECTL}} create -o yaml --dry-run=client"
TODAY: '{{ now | date "2006-01-02T15:04:05-07:00" }}'
BLACK: \033[:0;30m
RED: \033[:0;31m
GREEN: \033[:0;32m
ORANGE: \033[:0;33m
BLUE: \033[:0;34m
PURPLE: \033[:0;35m
CYAN: \033[:0;36m
LIGHT_GRAY: \033[:0;37m
DARK_GRAY: \033[:1;30m
LIGHT_RED: \033[:1;31m
LIGHT_GREEN: \033[:1;32m
YELLOW: \033[:1;33m
LIGHT_BLUE: \033[:1;34m
LIGHT_PURPLE: \033[:1;35m
LIGHT_CYAN: \033[:1;36m
WHITE: \033[:1;37m
NOCOLOR: \u001b[0m
REVERSED: \u001b[7m
tasks:
default:
prefix: ⚙️
cmds:
- task -l
silent: true
check:
desc: Check for problems associated with the project
deps:
- task: go:vet
- task: go:test
format:
desc: Format all files
deps:
- task: go:format
docker:build:
desc: Build the container image
cmds:
- docker build -t {{.CONTAINER_IMAGE}} -f Dockerfile .
- "k3d image import {{.CONTAINER_IMAGE}} -c nginx-test"
docker:enter:
desc: Enter into the built container
cmds:
- docker run -it --rm --entrypoint=sh {{.CONTAINER_IMAGE}}
docker:push:
desc: Push the built container image
cmds:
- docker push {{.CONTAINER_IMAGE}}
go:dev:
desc: run go code locally for development
cmds:
- go run . {{.CLI_ARGS}}
- sleep 1
sources:
- "*.go"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
cmds:
- go build -v {{.LDFLAGS}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:fix:
desc: Modernize usages of outdated APIs
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:format:
desc: Format Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:lint:
desc: Lint Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- |
if ! which golint &>/dev/null; then
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
exit 1
fi
- |
golint \
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
go:test:
desc: Run unit tests
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- |
go test \
-v \
-short \
-run '{{default ".*" .GO_TEST_REGEX}}' \
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
-coverprofile=coverage_unit.txt \
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:vet:
desc: Check for errors in Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
cmds:
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
k3d:create:
prefix: ⚙️ > create
desc: create k3d cluster
cmds:
- k3d cluster create --config=cluster/config.yaml
k3d:create:dev:
prefix: ⚙️ > create
desc: create k3d cluster (devcontainers)
deps:
- k3d:create
cmds:
- sed -i -e "s/0.0.0.0/host.docker.internal/g" ${HOME}/.kube/config
k3d:destroy:
prefix: ⚙️ > destroy
desc: destroy k3d cluster
cmds:
- "k3d cluster delete {{.CLUSTER_NAME}}"
k3d:start:
prefix: ⚙️ > start
desc: starts knative environment
cmds:
- "k3d cluster start {{.CLUSTER_NAME}}"
k3d:stop:
prefix: ⚙️ > stop
desc: stop knative environment
cmds:
- "k3d cluster stop {{.CLUSTER_NAME}}"
env:
prefix: ⚙ > env
desc: setup dev environment
cmds:
- echo "KF_NAMESPACE=">>.env
- echo "KF_USER_ID=">>.env
- echo "KF_NOTEBOOK_NAME=swag">>.env
- echo "KF_PVC_NAME=swag">>.env
sources:
- .env