Skip to content

Commit

Permalink
Merge pull request buildkite-plugins#261 from buildkite-plugins/rever…
Browse files Browse the repository at this point in the history
…t-250-run-build-args

Revert "Accept args and no-cache for run"
  • Loading branch information
jj-bk authored Feb 7, 2020
2 parents 5611e9e + f1790b8 commit 515765a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 70 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ The name to use when tagging pre-built images. If multiple images are built in t

Other docker-compose services that should be aliased to the main service that was built. This is for when different docker-compose services share the same prebuilt image.

### `args` (optional)
### `args` (optional, build only)

A list of KEY=VALUE that are passed through as build arguments when image is being built.

Expand Down Expand Up @@ -387,7 +387,7 @@ Prevent the removal of volumes after the command has been run.

The default is `false`.

### `no-cache` (optional)
### `no-cache` (optional, build only)

Sets the build step to run with `--no-cache`, causing Docker Compose to not use any caches when building the image.

Expand Down
12 changes: 1 addition & 11 deletions commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,10 @@ elif [[ ! -f "$override_file" ]]; then
echo "~~~ :docker: Building Docker Compose Service: $run_service" >&2
echo "⚠️ No pre-built image found from a previous 'build' step for this service and config file. Building image..."

build_params=()

if [[ "$(plugin_read_config NO_CACHE "false")" == "true" ]] ; then
build_params+=(--no-cache)
fi

while read -r arg ; do
[[ -n "${arg:-}" ]] && build_params+=("--build-arg" "${arg}")
done <<< "$(plugin_read_list ARGS)"

# Ideally we'd do a pull with a retry first here, but we need the conditional pull behaviour here
# for when an image and a build is defined in the docker-compose.ymk file, otherwise we try and
# pull an image that doesn't exist
run_docker_compose build --pull "${build_params[@]}" "$run_service"
run_docker_compose build --pull "$run_service"

# Sometimes docker-compose pull leaves unfinished ansi codes
echo
Expand Down
3 changes: 1 addition & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ configuration:
cache-from: [ build ]
volumes: [ run ]
leave-volumes: [ run ]
no-cache: [ build, run ]
no-cache: [ build ]
use-aliases: [ run ]
dependencies: [ run ]
ansi: [ run ]
tty: [ run ]
workdir: [ run ]
user: [ run ]
args: [ build, run ]
propagate-uid-gid: [ run ]
55 changes: 0 additions & 55 deletions tests/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -199,61 +199,6 @@ cmd3"
unstub buildkite-agent
}

@test "Run without a prebuilt image with no-cache" {
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_NO_CACHE=true
export BUILDKITE_PIPELINE_SLUG=test
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_COMMAND="echo hello world"
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CHECK_LINKED_CONTAINERS=false
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false

stub docker-compose \
"-f docker-compose.yml -p buildkite1111 build --pull --no-cache myservice : echo built myservice" \
"-f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 : echo ran myservice dependencies" \
"-f docker-compose.yml -p buildkite1111 run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'echo hello world' : echo ran myservice"

stub buildkite-agent \
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1"

run $PWD/hooks/command

assert_success
assert_output --partial "built myservice"
assert_output --partial "ran myservice"
unstub docker-compose
unstub buildkite-agent
}

@test "Run without a prebuilt image with build args" {
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_0=MYARG=0
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ARGS_1=MYARG=1
export BUILDKITE_PIPELINE_SLUG=test
export BUILDKITE_BUILD_NUMBER=1
export BUILDKITE_COMMAND="echo hello world"
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CHECK_LINKED_CONTAINERS=false
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false

stub docker-compose \
"-f docker-compose.yml -p buildkite1111 build --pull --build-arg MYARG=0 --build-arg MYARG=1 myservice : echo built myservice" \
"-f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 : echo ran myservice dependencies" \
"-f docker-compose.yml -p buildkite1111 run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'echo hello world' : echo ran myservice"

stub buildkite-agent \
"meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1"

run $PWD/hooks/command

assert_success
assert_output --partial "built myservice"
assert_output --partial "ran myservice"
unstub docker-compose
unstub buildkite-agent
}

@test "Run with a prebuilt image" {
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
Expand Down

0 comments on commit 515765a

Please sign in to comment.