-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathTaskfile.yml
More file actions
149 lines (131 loc) · 4.75 KB
/
Taskfile.yml
File metadata and controls
149 lines (131 loc) · 4.75 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
version: '3'
vars:
OUTPUT_DIR: '_output'
GO_TAGS: '-tags "no_grpc"'
LDFLAGS: '-s -w'
GO_LDFLAGS: '-ldflags "{{.LDFLAGS}}"'
# Map Go's GOARCH to the kernel arch naming convention (amd64 → x86_64).
KERNEL_ARCH:
sh: 'a=$(go env GOARCH); case "$a" in amd64) echo x86_64;; *) echo "$a";; esac'
tasks:
default:
desc: Build all outputs via Docker Buildx Bake
deps: [build]
#
# Build tasks
#
build:
desc: Build all outputs via Docker Buildx Bake
cmds:
- HOST_OS={{OS}} KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake
build:shim:
desc: Build containerd-shim-nerdbox-v1 for the current platform
cmds:
- mkdir -p {{.OUTPUT_DIR}}
- go build {{.GO_TAGS}} {{.GO_LDFLAGS}} -o {{.OUTPUT_DIR}}/containerd-shim-nerdbox-v1{{if eq OS "windows"}}.exe{{end}} ./cmd/containerd-shim-nerdbox-v1
- cmd: codesign --entitlements cmd/containerd-shim-nerdbox-v1/containerd-shim-nerdbox-v1.entitlements --force -s - {{.OUTPUT_DIR}}/containerd-shim-nerdbox-v1
platforms: [darwin]
build:guest:
desc: Build guest artifacts (kernel and initrd) via Docker Buildx Bake
cmds:
- KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake kernel initrd
build:initrd:
desc: Build the nerdbox initrd via Docker Buildx Bake
cmds:
- KERNEL_ARCH={{.KERNEL_ARCH}} docker buildx bake initrd
build:integration:
desc: Build the integration test binary
cmds:
- mkdir -p {{.OUTPUT_DIR}}
- go test -c -o {{.OUTPUT_DIR}}/integration.test{{if eq OS "windows"}}.exe{{end}} {{.GO_LDFLAGS}} {{.GO_TAGS}} ./integration
- cmd: codesign --entitlements cmd/containerd-shim-nerdbox-v1/containerd-shim-nerdbox-v1.entitlements --force -s - {{.OUTPUT_DIR}}/integration.test
platforms: [darwin]
#
# Test tasks
#
test:unit:
desc: Run unit tests (excludes integration package)
cmds:
- go test -count=1 ./api/... ./cmd/... ./internal/... ./pkg/... ./plugins/...
test:integration:
desc: "Run integration tests (each test in its own process). Extra flags are forwarded to the test binary: task test:integration -- -run TestSystemInfo -v"
deps: [build:integration]
vars:
# When -v is in the extra flags, switch gotestsum to standard-verbose so
# t.Log() output is shown; otherwise testname format suppresses it.
GOTESTSUM_FORMAT:
sh: |
case " {{.CLI_ARGS}} " in *" -v "*|*" -v") echo standard-verbose ;; *) echo testname ;; esac
env:
TESTFLAGS: '{{.CLI_ARGS}}'
cmds:
- cmd: gotestsum -f {{.GOTESTSUM_FORMAT}} --raw-command bash integration/test.sh
platforms: [darwin, linux]
- cmd: gotestsum -f {{.GOTESTSUM_FORMAT}} --raw-command powershell -ExecutionPolicy Bypass -File integration/test.ps1
platforms: [windows]
#
# Code quality tasks
#
validate:
desc: Validate via Docker Buildx Bake
cmds:
- docker buildx bake validate
lint:
desc: Run linters via Docker Buildx Bake
cmds:
- docker buildx bake lint
protos:
desc: Regenerate protobuf bindings
dir: api
cmds:
- buf generate
- buf build --exclude-imports -o next.txtpb
- go-fix-acronym -w -a '^Os' $(find . -name '*.pb.go')
- go-fix-acronym -w -a '(Id|Io|Uuid|Os)$' $(find . -name '*.pb.go')
generate:
desc: Regenerate all derived artifacts (protobuf)
deps: [protos]
check-protos:
desc: Verify protobuf bindings are up to date
deps: [protos]
cmds:
- cmd: |
if [ -n "$(git status --short | grep ".pb.go")" ]; then
git diff | cat
echo "please run 'task protos' when making changes to proto files"
exit 1
fi
check-api-descriptors:
desc: Verify protobuf descriptor files are up to date
deps: [protos]
cmds:
- cmd: |
if [ -n "$(git status --short | grep ".txtpb")" ]; then
git diff $(find ./api/ -name '*.txtpb') | cat
echo "please run 'task protos' when making changes to proto files and check-in the generated descriptor file changes"
exit 1
fi
proto-fmt:
desc: Check proto files use tabs (not spaces) for indentation
cmds:
- cmd: |
if [ -n "$(find ./api/ -name '*.proto' -type f -exec grep -Hn -e "^ " {} \;)" ]; then
echo "please indent proto files with tabs only"
exit 1
fi
verify-vendor:
desc: Verify go.mod/go.sum and vendor directory are up to date
cmds:
- cmd: |
tmpdir=$(mktemp -d)
cp -R . "$tmpdir/nerdbox"
(cd "$tmpdir/nerdbox" && go mod tidy && go mod verify)
diff -r -u . "$tmpdir/nerdbox" || (rm -rf "$tmpdir" && exit 1)
rm -rf "$tmpdir"
#
# Clean
#
clean:
desc: Remove all build outputs
cmds:
- rm -rf {{.OUTPUT_DIR}}