-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
274 lines (246 loc) · 8.82 KB
/
Taskfile.yaml
File metadata and controls
274 lines (246 loc) · 8.82 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc.
# SPDX-License-Identifier: Apache-2.0
version: '3'
vars:
BINARY_NAME: waggle
BUILD_DIR: bin
MAIN_PACKAGE: ./cmd/waggle
IMAGE_REGISTRY: ghcr.io/stacklok/waggle
IMAGE_TAG:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
BUILD_DATE:
sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
MICROVM_VERSION:
sh: go list -m github.com/stacklok/go-microvm | awk '{print $2}'
HOST_ARCH:
sh: uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/'
HOST_OS:
sh: uname -s | tr '[:upper:]' '[:lower:]'
CONTAINER_ENGINE:
sh: echo ${CONTAINER_ENGINE:-$(command -v docker >/dev/null 2>&1 && echo docker || echo podman)}
LDFLAGS: >-
-X main.version={{.VERSION}}
-X main.commit={{.COMMIT}}
-X main.buildDate={{.BUILD_DATE}}
LDFLAGS_EMBED: >-
-X main.version={{.VERSION}}
-X main.commit={{.COMMIT}}
-X main.buildDate={{.BUILD_DATE}}
-X github.com/stacklok/waggle/pkg/infra/vm/runtimebin.Version={{.MICROVM_VERSION}}
# Quick reference:
# task build → Build self-contained waggle with embedded go-microvm runtime
# task build-dev-system → Build waggle + go-microvm-runner from system libkrun
# task fetch-runtime → Download pre-built go-microvm runtime from GitHub Release
# task fetch-firmware → Download pre-built go-microvm firmware from GitHub Release
# task test → Run tests with race detector
# task lint → Run linter
# task verify → fmt + lint + test
tasks:
default:
desc: Show available tasks
cmds:
- task --list
build:
desc: Build self-contained waggle with embedded go-microvm runtime
deps: [build-init, fetch-runtime, fetch-firmware]
env:
CGO_ENABLED: "0"
cmds:
- mkdir -p {{.BUILD_DIR}}
- go build -tags embed_runtime -ldflags "{{.LDFLAGS_EMBED}}" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} {{.MAIN_PACKAGE}}
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- '{{.BUILD_DIR}}/{{.BINARY_NAME}}'
build-dev-system:
desc: Build waggle + go-microvm-runner from system libkrun (requires libkrun-devel)
platforms: [linux]
cmds:
- task: build
- mkdir -p {{.BUILD_DIR}}
- CGO_ENABLED=1 go build -o {{.BUILD_DIR}}/go-microvm-runner github.com/stacklok/go-microvm/runner/cmd/go-microvm-runner
build-dev-system-darwin:
desc: Build waggle + go-microvm-runner from system libkrun (macOS, requires Homebrew libkrun)
platforms: [darwin]
cmds:
- task: build
- mkdir -p {{.BUILD_DIR}}
- CGO_ENABLED=1 go build -o {{.BUILD_DIR}}/go-microvm-runner github.com/stacklok/go-microvm/runner/cmd/go-microvm-runner
- codesign --entitlements assets/entitlements.plist --force -s - {{.BUILD_DIR}}/go-microvm-runner
fetch-runtime:
desc: Download pre-built go-microvm runtime from GitHub Release
status:
- test -f pkg/infra/vm/runtimebin/go-microvm-runner
cmds:
- mkdir -p pkg/infra/vm/runtimebin
- >-
gh release download {{.MICROVM_VERSION}}
--repo stacklok/go-microvm
--pattern "go-microvm-runtime-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz"
--dir pkg/infra/vm/runtimebin/ --clobber
- >-
gh release download {{.MICROVM_VERSION}}
--repo stacklok/go-microvm
--pattern "sha256sums.txt"
--dir pkg/infra/vm/runtimebin/ --clobber
- cd pkg/infra/vm/runtimebin/ && sha256sum --check --ignore-missing sha256sums.txt
- >-
tar -xzf pkg/infra/vm/runtimebin/go-microvm-runtime-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz
-C pkg/infra/vm/runtimebin/ --strip-components=1
- rm -f pkg/infra/vm/runtimebin/go-microvm-runtime-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz
fetch-firmware:
desc: Download pre-built go-microvm firmware from GitHub Release
status:
- ls pkg/infra/vm/runtimebin/libkrunfw.* >/dev/null 2>&1
cmds:
- mkdir -p pkg/infra/vm/runtimebin
- >-
gh release download {{.MICROVM_VERSION}}
--repo stacklok/go-microvm
--pattern "go-microvm-firmware-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz"
--dir pkg/infra/vm/runtimebin/ --clobber
- >-
gh release download {{.MICROVM_VERSION}}
--repo stacklok/go-microvm
--pattern "sha256sums.txt"
--dir pkg/infra/vm/runtimebin/ --clobber
- cd pkg/infra/vm/runtimebin/ && sha256sum --check --ignore-missing sha256sums.txt
- >-
tar -xzf pkg/infra/vm/runtimebin/go-microvm-firmware-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz
-C pkg/infra/vm/runtimebin/ --strip-components=1
- rm -f pkg/infra/vm/runtimebin/go-microvm-firmware-{{.HOST_OS}}-{{.HOST_ARCH}}.tar.gz
build-init:
desc: Build the waggle-init binary (guest VM init)
cmds:
- mkdir -p pkg/infra/vm/initbin
- CGO_ENABLED=0 GOOS=linux go build -ldflags "{{.LDFLAGS}}" -o pkg/infra/vm/initbin/waggle-init ./cmd/waggle-init
sources:
- cmd/waggle-init/**/*.go
- pkg/infra/vm/initbin/embed.go
- go.mod
- go.sum
generates:
- pkg/infra/vm/initbin/waggle-init
build-all:
desc: Build all binaries
deps: [build, build-init]
test:
desc: Run unit tests with race detector
deps: [build-init]
cmds:
- go test -v -race ./...
test-coverage:
desc: Run tests with coverage
cmds:
- go test -v -race -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated at coverage.html"
lint:
desc: Run linter
deps: [build-init]
cmds:
- golangci-lint run ./...
lint-fix:
desc: Run linter and fix issues
cmds:
- golangci-lint run --fix ./...
fmt:
desc: Format code
cmds:
- go fmt ./...
- goimports -w .
tidy:
desc: Tidy go modules
cmds:
- go mod tidy
gen:
desc: Generate mocks
cmds:
- go generate ./...
verify:
desc: Verify code (fmt, lint, test)
cmds:
- task: fmt
- task: lint
- task: test
version:
desc: Print version information
cmds:
- 'echo "Version: {{.VERSION}}"'
- 'echo "Commit: {{.COMMIT}}"'
- 'echo "Build Date: {{.BUILD_DATE}}"'
clean:
desc: Clean build artifacts
cmds:
- rm -rf {{.BUILD_DIR}}/
- rm -f coverage.out coverage.html
- rm -f pkg/infra/vm/initbin/waggle-init
- rm -f pkg/infra/vm/runtimebin/go-microvm-runner
- rm -f pkg/infra/vm/runtimebin/libkrun.so.1 pkg/infra/vm/runtimebin/libkrun.1.dylib
- rm -f pkg/infra/vm/runtimebin/libkrunfw.so.5 pkg/infra/vm/runtimebin/libkrunfw.5.dylib
- rm -f pkg/infra/vm/runtimebin/VERSION pkg/infra/vm/runtimebin/LICENSE-GPL
build-image-base:
desc: Build base runtime image (shared Alpine layer)
run: once
cmds:
- "{{.CONTAINER_ENGINE}} build -t {{.IMAGE_REGISTRY}}/base:{{.IMAGE_TAG}} -t {{.IMAGE_REGISTRY}}/base:latest images/base/"
sources:
- images/base/Dockerfile
build-image-python:
desc: Build Python runtime image
deps: [build-image-base]
cmds:
- >-
{{.CONTAINER_ENGINE}} build
--build-arg BASE_IMAGE={{.IMAGE_REGISTRY}}/base:latest
-t {{.IMAGE_REGISTRY}}/python:{{.IMAGE_TAG}}
-t {{.IMAGE_REGISTRY}}/python:latest images/python/
sources:
- images/base/Dockerfile
- images/python/Dockerfile
build-image-node:
desc: Build Node.js runtime image
deps: [build-image-base]
cmds:
- >-
{{.CONTAINER_ENGINE}} build
--build-arg BASE_IMAGE={{.IMAGE_REGISTRY}}/base:latest
-t {{.IMAGE_REGISTRY}}/node:{{.IMAGE_TAG}}
-t {{.IMAGE_REGISTRY}}/node:latest images/node/
sources:
- images/base/Dockerfile
- images/node/Dockerfile
build-image-shell:
desc: Build shell runtime image
deps: [build-image-base]
cmds:
- >-
{{.CONTAINER_ENGINE}} build
--build-arg BASE_IMAGE={{.IMAGE_REGISTRY}}/base:latest
-t {{.IMAGE_REGISTRY}}/shell:{{.IMAGE_TAG}}
-t {{.IMAGE_REGISTRY}}/shell:latest images/shell/
sources:
- images/base/Dockerfile
- images/shell/Dockerfile
build-images:
desc: Build all runtime images
deps: [build-image-python, build-image-node, build-image-shell]
push-images:
desc: Push all runtime images to registry
deps: [build-images]
cmds:
- "{{.CONTAINER_ENGINE}} push {{.IMAGE_REGISTRY}}/base:{{.IMAGE_TAG}}"
- "{{.CONTAINER_ENGINE}} push {{.IMAGE_REGISTRY}}/python:{{.IMAGE_TAG}}"
- "{{.CONTAINER_ENGINE}} push {{.IMAGE_REGISTRY}}/node:{{.IMAGE_TAG}}"
- "{{.CONTAINER_ENGINE}} push {{.IMAGE_REGISTRY}}/shell:{{.IMAGE_TAG}}"
run:
desc: Build and run the server
deps: [build]
cmds:
- ./{{.BUILD_DIR}}/{{.BINARY_NAME}}