Skip to content

Commit ddec64a

Browse files
authored
Add progress option (#467)
* Add progress option to Docker Compose plugin configuration and update README * Reorder progress option in plugin.yml configuration for consistency
1 parent 7780a77 commit ddec64a

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
A [Buildkite plugin](https://buildkite.com/docs/agent/v3/plugins) that lets you build, run and push build steps using [Docker Compose](https://docs.docker.com/compose/).
44

5-
* Containers are built, run and linked on demand using Docker Compose
6-
* Containers are namespaced to each build job, and cleaned up after use
7-
* Supports pre-building of images, allowing for fast parallel builds across distributed agents
8-
* Supports pushing tagged images to a repository
9-
5+
- Containers are built, run and linked on demand using Docker Compose
6+
- Containers are namespaced to each build job, and cleaned up after use
7+
- Supports pre-building of images, allowing for fast parallel builds across distributed agents
8+
- Supports pushing tagged images to a repository
109

1110
## Examples
1211

@@ -30,7 +29,7 @@ The name of the service the command should be run within. If the docker-compose
3029

3130
#### `push`
3231

33-
A list of services to push. You can specify just the service name to push or the format `service:registry:tag` to override where the service's image is pushed to. Needless to say, the image for the service must have been built in the very same step or built and pushed previously to ensure it is available for pushing.
32+
A list of services to push. You can specify just the service name to push or the format `service:registry:tag` to override where the service's image is pushed to. Needless to say, the image for the service must have been built in the very same step or built and pushed previously to ensure it is available for pushing.
3433

3534
:warning: If a service does not have an `image` configuration and no registry/tag are specified in the `push` option, pushing of the service will be skipped by docker.
3635

@@ -190,7 +189,7 @@ Note that there is a single build command run for all services so the target val
190189

191190
A list of volumes to mount into the container. If a matching volume exists in the Docker Compose config file, this option will override that definition.
192191

193-
Additionally, volumes may be specified via the agent environment variable `BUILDKITE_DOCKER_DEFAULT_VOLUMES`, a `;` (semicolon) delimited list of mounts in the `-v` syntax. (Ex. `buildkite:/buildkite;./app:/app`).
192+
Additionally, volumes may be specified via the agent environment variable `BUILDKITE_DOCKER_DEFAULT_VOLUMES`, a `;` (semicolon) delimited list of mounts in the `-v` syntax. (Ex. `buildkite:/buildkite;./app:/app`).
194193

195194
#### `expand-volume-vars` (run only, boolean, unsafe)
196195

@@ -236,6 +235,10 @@ If set to false, runs with `--no-deps` and doesn't start linked services.
236235

237236
The default is `true`.
238237

238+
### `progress` (string)
239+
240+
If set, runs with `--progress VALUE` (can be any of: auto, tty, plain, json, quiet).
241+
239242
#### `pre-run-dependencies` (run only, boolean)
240243

241244
If `dependencies` are activated (which is the default), you can skip starting them up before the main container by setting this option to `false`. This is useful if you want compose to take care of that on its own at the expense of messier output in the run step.
@@ -293,8 +296,9 @@ If set to true, all docker compose commands will run with compatibility mode. Eq
293296
The default is `false`.
294297

295298
Note that [the effect of this option changes depending on your docker compose CLI version](https://docs.docker.com/compose/cli-command-compatibility/#flags-that-will-not-be-implemented):
296-
* in v1 it translates (composefile) v3 deploy keys to their non-swarm (composefile) v2 equivalents
297-
* in v2 it will revert some behaviour to v1 as well, including (but not limited to):
299+
300+
- in v1 it translates (composefile) v3 deploy keys to their non-swarm (composefile) v2 equivalents
301+
- in v2 it will revert some behaviour to v1 as well, including (but not limited to):
298302
- [Character separator for container names](https://github.com/docker/compose/blob/a0acc20d883ce22b8b0c65786e3bea1328809bbd/cmd/compose/compose.go#L181)
299303
- [Not normalizing compose models (when running `config`)](https://github.com/docker/compose/blob/2e7644ff21f9ca0ea6fb5e8d41d4f6af32cd7e20/cmd/compose/convert.go#L69)
300304

lib/shared.bash

+5-1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ function run_docker_compose() {
266266
command+=(--compatibility)
267267
fi
268268

269+
if [[ -n "$(plugin_read_config PROGRESS)" ]]; then
270+
command+=(--progress "$(plugin_read_config PROGRESS)")
271+
fi
272+
269273
for file in $(docker_compose_config_files) ; do
270274
command+=(-f "$file")
271275
done
@@ -330,4 +334,4 @@ function builder_instance_exists() {
330334
else
331335
return 1 # Builder does not exist
332336
fi
333-
}
337+
}

plugin.yml

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ configuration:
112112
type: boolean
113113
prebuilt-image-namespace:
114114
type: string
115+
progress:
116+
type: string
117+
enum: [ "auto", "tty", "plain", "json", "quiet" ]
115118
propagate-environment:
116119
type: boolean
117120
propagate-uid-gid:
@@ -197,6 +200,7 @@ configuration:
197200
mount-ssh-agent: [ run ]
198201
no-cache: [ build, run ]
199202
pre-run-dependencies: [ run ]
203+
progress: [ build, push, run ]
200204
propagate-environment: [ run ]
201205
propagate-uid-gid: [ run ]
202206
pull: [ run ]

tests/run.bats

+24
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,30 @@ cmd3"
224224
unstub buildkite-agent
225225
}
226226

227+
@test "Run with progress=quiet" {
228+
export BUILDKITE_COMMAND=pwd
229+
230+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
231+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false
232+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_PROGRESS=quiet
233+
234+
stub docker \
235+
"compose --progress quiet -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml pull myservice : echo pulled myservice" \
236+
"compose --progress quiet -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml up -d --scale myservice=0 myservice : echo started dependencies for myservice" \
237+
"compose --progress quiet -f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml run --name buildkite1111_myservice_build_1 -T --rm myservice /bin/sh -e -c 'pwd' : echo ran myservice with use aliases output"
238+
239+
stub buildkite-agent \
240+
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \
241+
"meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage"
242+
243+
run "$PWD"/hooks/command
244+
245+
assert_success
246+
assert_output --partial "ran myservice with use aliases output"
247+
unstub docker
248+
unstub buildkite-agent
249+
}
250+
227251
@test "Run without a prebuilt image without pulling" {
228252
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
229253
export BUILDKITE_COMMAND="echo hello world"

0 commit comments

Comments
 (0)