Skip to content

Commit

Permalink
Merge pull request #408 from eugeneotto/add-v2-support-for-skip-pull-…
Browse files Browse the repository at this point in the history
…option

Add --skip-pull support to v2 run command
  • Loading branch information
pzeballos authored Oct 12, 2023
2 parents 22f7b9f + 962d5c7 commit 1e096e4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ fi

run_params+=("$run_service")

build_params=(--pull)
build_params=()

# Only pull if SKIP_PULL is not true
if [[ ! "$(plugin_read_config SKIP_PULL "false")" == "true" ]] ; then
build_params+=(--pull)
fi

if [[ "$(plugin_read_config NO_CACHE "false")" == "true" ]] ; then
build_params+=(--no-cache)
Expand Down
27 changes: 27 additions & 0 deletions tests/v2/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,33 @@ cmd3"
unstub buildkite-agent
}

@test "Run without a prebuilt image without pulling" {
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice
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
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SKIP_PULL=true

stub docker \
"compose -f docker-compose.yml -p buildkite1111 build myservice : echo built myservice" \
"compose -f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 myservice : echo ran myservice dependencies" \
"compose -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
unstub buildkite-agent
}

@test "Run with a prebuilt image and propagate environment but no BUILDKITE_ENV_FILE" {
export BUILDKITE_JOB_ID=1111
export BUILDKITE_PIPELINE_SLUG=test
Expand Down

0 comments on commit 1e096e4

Please sign in to comment.