-
Notifications
You must be signed in to change notification settings - Fork 262
Expand file tree
/
Copy pathTaskfile.yml
More file actions
93 lines (79 loc) · 3.12 KB
/
Taskfile.yml
File metadata and controls
93 lines (79 loc) · 3.12 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
version: "3"
vars:
BINARY_NAME: cagent{{if eq OS "windows"}}.exe{{end}}
CLI_PLUGIN_BINARY_NAME: docker-agent{{if eq OS "windows"}}.exe{{end}}
MAIN_PKG: ./main.go
BUILD_DIR: ./bin
GIT_TAG:
sh: git describe --tags --exact-match 2>/dev/null || echo dev
GIT_COMMIT:
sh: git rev-parse HEAD
GO_SOURCES: "**/*.go"
BUILD_ARGS: '--build-arg GIT_TAG="{{.GIT_TAG}}" --build-arg GIT_COMMIT="{{.GIT_COMMIT}}"'
LDFLAGS: '-X "github.com/docker/cagent/pkg/version.Version={{.GIT_TAG}}" -X "github.com/docker/cagent/pkg/version.Commit={{.GIT_COMMIT}}"'
tasks:
default:
cmd: task --list
dev:
deps: ["lint", "test", "build"]
build:
aliases: [b]
desc: Build the application binary
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} {{.MAIN_PKG}}
- '{{if ne .CI "true"}}ln -sf {{.USER_WORKING_DIR}}/{{.BUILD_DIR}}/{{.BINARY_NAME}} {{.HOME}}/bin/{{.BINARY_NAME}}{{end}}'
sources:
- "{{.GO_SOURCES}}"
- "**/*.template"
- "**/*.txt"
- "**/*.y{a,}ml"
- "go.mod"
- "go.sum"
generates:
- "{{.BUILD_DIR}}/{{.BINARY_NAME}}"
deploy-local:
desc: Deploy the docker agent cli-plugin
deps: ["build"]
cmds:
- mkdir -p ~/.docker/cli-plugins
- cp "{{.BUILD_DIR}}/{{.BINARY_NAME}}" ~/.docker/cli-plugins/{{.CLI_PLUGIN_BINARY_NAME}}
- cp "{{.BUILD_DIR}}/{{.BINARY_NAME}}" {{.BUILD_DIR}}/{{.CLI_PLUGIN_BINARY_NAME}}
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run
- go mod tidy --diff >/dev/null || (echo "go.mod/go.sum files are not tidy" && exit 1)
sources:
- "{{.GO_SOURCES}}"
- ".golangci.yml"
- "go.mod"
- "go.sum"
format:
desc: Format code
cmd: golangci-lint fmt
sources:
- "{{.GO_SOURCES}}"
- ".golangci.yml"
test:
aliases: [t]
desc: Run tests
cmd: DOCKER_AGENT_MODELS_GATEWAY= OPENAI_API_KEY= ANTHROPIC_API_KEY= GOOGLE_API_KEY= GOOGLE_GENAI_USE_VERTEXAI= MISTRAL_API_KEY= GITHUB_TOKEN= go test {{.CLI_ARGS}} ./...
test-binary:
deps: ["deploy-local"]
desc: Run tests on build binary
cmd: DOCKER_AGENT_MODELS_GATEWAY= OPENAI_API_KEY= ANTHROPIC_API_KEY= GOOGLE_API_KEY= GOOGLE_GENAI_USE_VERTEXAI= MISTRAL_API_KEY= GITHUB_TOKEN= go test -tags=binary_required {{.CLI_ARGS}} ./e2e/binary/...
build-local:
desc: Build binaries for local host platform
cmd: docker buildx build --target=local {{.BUILD_ARGS}} --platform local --output=./dist . {{if eq OS "windows"}}&& mv ./dist/cagent ./dist/cagent.exe{{end}}
cross:
desc: Build binaries for multiple platforms
cmd: docker buildx build --target=cross {{.BUILD_ARGS}} --platform linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64,windows/arm64 --output=./dist .
build-image:
desc: Build Docker image
cmd: docker buildx build -t docker/cagent -t docker/docker-agent {{.BUILD_ARGS}} .
push-image:
desc: Build and Push Docker image
cmd: docker buildx build --push --platform linux/amd64,linux/arm64 -t docker/cagent -t docker/docker-agent {{.BUILD_ARGS}} .
record-demo:
desc: Record demo gif
cmd: vhs ./docs/recordings/demo.tape