-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathTaskfile.yml
More file actions
137 lines (120 loc) · 4.58 KB
/
Taskfile.yml
File metadata and controls
137 lines (120 loc) · 4.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
version: "3"
vars:
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/docker-agent/pkg/version.Version={{.GIT_TAG}}" -X "github.com/docker/docker-agent/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}}/{{.CLI_PLUGIN_BINARY_NAME}} {{.MAIN_PKG}}
- '{{if ne .CI "true"}}ln -sf {{.USER_WORKING_DIR}}/{{.BUILD_DIR}}/{{.CLI_PLUGIN_BINARY_NAME}} {{.HOME}}/bin/{{.CLI_PLUGIN_BINARY_NAME}}{{end}}'
sources:
- "{{.GO_SOURCES}}"
- "**/*.template"
- "**/*.txt"
- "**/*.y{a,}ml"
- "go.mod"
- "go.sum"
generates:
- "{{.BUILD_DIR}}/{{.CLI_PLUGIN_BINARY_NAME}}"
deploy-local:
desc: Deploy the docker agent cli-plugin
deps: ["build"]
cmds:
- mkdir -p ~/.docker/cli-plugins
- /bin/ln -sf "{{.TASKFILE_DIR}}/bin/{{.CLI_PLUGIN_BINARY_NAME}}" "{{.HOME}}/.docker/cli-plugins/{{.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= 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= 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/docker-agent ./dist/docker-agent.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/docker-agent {{.BUILD_ARGS}} .
push-image:
desc: Build and Push Docker image
cmd: docker buildx build --push --platform linux/amd64,linux/arm64 -t docker/docker-agent {{.BUILD_ARGS}} .
docs-serve:
desc: Preview the Jekyll documentation site locally
dir: docs
cmd: |
docker build -t docker-agent-docs . && \
docker run --rm \
-v "{{.TASKFILE_DIR}}/docs:/srv/jekyll" \
-e JEKYLL_ENV=development \
-p 4000:4000 \
docker-agent-docs \
jekyll serve --host 0.0.0.0 --config _config.yml,_config.dev.yml --livereload
docs-check-links:
desc: Build the documentation site and check for broken links
dir: docs
cmd: |
cleanup() {
docker rm -f docs-linkcheck 2>/dev/null
docker network rm docs-linkcheck-net 2>/dev/null
}
trap cleanup EXIT
docker build -t docker-agent-docs . && \
docker network create docs-linkcheck-net && \
docker run -d --rm \
--name docs-linkcheck \
--network docs-linkcheck-net \
-v "{{.TASKFILE_DIR}}/docs:/srv/jekyll" \
docker-agent-docs \
jekyll serve --host 0.0.0.0 --config _config.yml,_config.dev.yml && \
echo 'Waiting for Jekyll to start...' && \
for i in $(seq 1 30); do \
docker run --rm --network docs-linkcheck-net curlimages/curl -sf http://docs-linkcheck:4000/ > /dev/null 2>&1 && break; \
sleep 2; \
done && \
docker run --rm \
--network docs-linkcheck-net \
raviqqe/muffet \
--buffer-size 16384 \
--exclude 'fonts.googleapis.com' \
--exclude 'fonts.gstatic.com' \
--exclude 'console.mistral.ai' \
--exclude 'console.x.ai' \
--rate-limit 20 \
http://docs-linkcheck:4000/
record-demo:
desc: Record demo gif
cmd: vhs ./docs/recordings/demo.tape