From 82f3617578582a920a9900cdec04ca05a4c73d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 00:28:00 -0300 Subject: [PATCH 1/8] Sorted dependencies in plugin.yml --- plugin.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugin.yml b/plugin.yml index 4fa99451..c385d1fb 100644 --- a/plugin.yml +++ b/plugin.yml @@ -94,21 +94,21 @@ configuration: - push additionalProperties: false dependencies: - pull: [ run ] - image-repository: [ build ] - image-name: [ build ] + ansi: [ run ] + cache-from: [ build ] + dependencies: [ run ] env: [ run ] environment: [ run ] - push-retries: [ push ] - cache-from: [ build ] - volumes: [ run ] expand-volume-vars: [ volumes ] + image-repository: [ build ] + image-name: [ build ] leave-volumes: [ run ] - use-aliases: [ run ] - dependencies: [ run ] - ansi: [ run ] + mount-buildkite-agent: [ run ] + propagate-uid-gid: [ run ] + pull: [ run ] + push-retries: [ push ] tty: [ run ] - workdir: [ run ] + use-aliases: [ run ] user: [ run ] - propagate-uid-gid: [ run ] - mount-buildkite-agent: [ run ] + volumes: [ run ] + workdir: [ run ] From 6ec2c32b4ebf29497667a3d565eabdf9ecf9180a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 00:37:33 -0300 Subject: [PATCH 2/8] Corrected minor shellcheck warning --- tests/build.bats | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/build.bats b/tests/build.bats index 15628d21..1c29181c 100644 --- a/tests/build.bats +++ b/tests/build.bats @@ -16,7 +16,7 @@ load '../lib/shared' stub docker-compose \ "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull myservice : echo built myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command unstub docker-compose assert_success @@ -33,7 +33,7 @@ load '../lib/shared' stub docker-compose \ "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --no-cache myservice : echo built myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -50,7 +50,7 @@ load '../lib/shared' stub docker-compose \ "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --parallel myservice : echo built myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -68,7 +68,7 @@ load '../lib/shared' stub docker-compose \ "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --build-arg MYARG=0 --build-arg MYARG=1 myservice : echo built myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -85,7 +85,7 @@ load '../lib/shared' stub docker-compose \ "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull myservice : echo built myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -106,7 +106,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -134,7 +134,7 @@ load '../lib/shared' "meta-data set docker-compose-plugin-built-image-tag-myservice-1 my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice-1" \ "meta-data set docker-compose-plugin-built-image-tag-myservice-2 my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice-2" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -163,7 +163,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -188,7 +188,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -214,7 +214,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml-tests/composefiles/docker-compose.v2.1.yml my.repository/llamas:test-myservice-build-1 : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -240,7 +240,7 @@ load '../lib/shared' "meta-data set docker-compose-plugin-built-image-tag-myservice1 my.repository/llamas:test-myservice1-build-1 : echo set image metadata for myservice1" \ "meta-data set docker-compose-plugin-built-image-tag-myservice2 my.repository/llamas:test-myservice2-build-1 : echo set image metadata for myservice2" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built all services" @@ -258,7 +258,7 @@ load '../lib/shared' export BUILDKITE_PIPELINE_SLUG=test export BUILDKITE_BUILD_NUMBER=1 - run $PWD/hooks/command + run "$PWD"/hooks/command assert_failure assert_output --partial "Compose file versions 2.0 and above" @@ -278,7 +278,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image" @@ -300,7 +300,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull --no-cache helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success refute_output --partial "pulled cache image" @@ -324,7 +324,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image" @@ -355,7 +355,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image build-target" @@ -392,7 +392,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image build-target-latest" @@ -431,7 +431,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image build-target-latest" @@ -463,7 +463,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image" @@ -488,7 +488,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "my.repository/myservice_cache:latest will not be used as a cache for helloworld" @@ -512,7 +512,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull hello-world : echo built hello-world" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image" @@ -539,7 +539,7 @@ load '../lib/shared' stub docker-compose \ "-f tests/composefiles/docker-compose.v3.2.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml build --pull helloworld : echo built helloworld" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled cache image" @@ -564,7 +564,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice my.repository/llamas:my-llamas-image : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -590,7 +590,7 @@ load '../lib/shared' stub buildkite-agent \ "meta-data set docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v3.2.yml my.repository/llamas:my-llamas-image : echo set image metadata for myservice" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -618,7 +618,7 @@ load '../lib/shared' "meta-data set docker-compose-plugin-built-image-tag-myservice1 my.repository/llamas:my-llamas-image-1 : echo set image metadata for myservice1" \ "meta-data set docker-compose-plugin-built-image-tag-myservice2 my.repository/llamas:my-llamas-image-2 : echo set image metadata for myservice2" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built all services" From 6bdaf2e8589ba8caf4007a91cd71530cd49ba05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 00:37:57 -0300 Subject: [PATCH 3/8] Added run option skip-pull --- commands/run.sh | 2 +- plugin.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/run.sh b/commands/run.sh index eaa14c00..d63e5ad8 100755 --- a/commands/run.sh +++ b/commands/run.sh @@ -69,7 +69,7 @@ elif [[ ${#pull_services[@]} -eq 1 ]] ; then fi # Pull down specified services -if [[ ${#pull_services[@]} -gt 0 ]] ; then +if [[ ${#pull_services[@]} -gt 0 ]] && [[ "$(plugin_read_config SKIP_PULL "false")" == "false" ]]; then echo "~~~ :docker: Pulling services ${pull_services[0]}" retry "$pull_retries" run_docker_compose "${pull_params[@]}" diff --git a/plugin.yml b/plugin.yml index c385d1fb..e273caa6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -70,6 +70,8 @@ configuration: type: string rm: type: boolean + skip-pull: + type: boolean upload-container-logs: type: string propagate-uid-gid: @@ -107,6 +109,7 @@ configuration: propagate-uid-gid: [ run ] pull: [ run ] push-retries: [ push ] + skip-pull: [ run ] tty: [ run ] use-aliases: [ run ] user: [ run ] From bdbf53ee55f44accb2fe41a93f826d3b75cb7b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 00:58:12 -0300 Subject: [PATCH 4/8] Made condition turn on with specific value --- commands/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/run.sh b/commands/run.sh index d63e5ad8..11ac6427 100755 --- a/commands/run.sh +++ b/commands/run.sh @@ -69,7 +69,7 @@ elif [[ ${#pull_services[@]} -eq 1 ]] ; then fi # Pull down specified services -if [[ ${#pull_services[@]} -gt 0 ]] && [[ "$(plugin_read_config SKIP_PULL "false")" == "false" ]]; then +if [[ ${#pull_services[@]} -gt 0 ]] && [[ "$(plugin_read_config SKIP_PULL "false")" != "true" ]]; then echo "~~~ :docker: Pulling services ${pull_services[0]}" retry "$pull_retries" run_docker_compose "${pull_params[@]}" From 6365558d9263f3e3038c0a626cc96406d9e14277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 01:05:40 -0300 Subject: [PATCH 5/8] Added documentation for option --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c11ca3c2..18e68a65 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,7 @@ Will cause the image to be pushed twice (once by the build step and another by t ### `pull` (optional, run only) -Pull down multiple pre-built images. By default only the service that is being run will be pulled down, but this allows multiple images to be specified to handle prebuilt dependent images. +Pull down multiple pre-built images. By default only the service that is being run will be pulled down, but this allows multiple images to be specified to handle prebuilt dependent images. Note that pulling will be skipped if the `skip-pull` option is activated. ### `config` (optional) @@ -440,6 +440,10 @@ Example: `[ "powershell", "-Command" ]` Whether to skip the repository checkout phase. This is useful for steps that use a pre-built image. This will fail if there is no pre-built image. +### `skip-pull` (optional, run only) + +Completely avoid running any `pull` command. Images being used will need to be present in the machine from before or have been built in the same step. Could be useful to avoid hitting rate limits when you can be sure the operation is unnecessary. Note that it is possible other commands run in the plugin's lifecycle will trigger a pull of necessary images. + ### `workdir` (optional, run only) Specify the container working directory via `docker-compose run --workdir`. From 6241660cd6a9ef6ecc1fa871c4378157ea195b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 01:09:33 -0300 Subject: [PATCH 6/8] Corrected shellcheck warnings in run.bats --- tests/run.bats | 78 ++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/tests/run.bats b/tests/run.bats index 916705f9..9389eb58 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -25,7 +25,7 @@ load '../lib/run' stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -51,7 +51,7 @@ load '../lib/run' stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success refute_output --partial "The Docker Compose Plugin does not correctly support step-level array commands" @@ -79,7 +79,7 @@ load '../lib/run' stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -105,7 +105,7 @@ load '../lib/run' stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -133,7 +133,7 @@ cmd3" stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "The Docker Compose Plugin does not correctly support step-level array commands" @@ -162,7 +162,7 @@ cmd3" stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success refute_output --partial "The Docker Compose Plugin does not correctly support step-level array commands" @@ -194,7 +194,7 @@ cmd3" stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice" @@ -220,7 +220,7 @@ cmd3" stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -248,7 +248,7 @@ cmd3" stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -275,7 +275,7 @@ cmd3" "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice" @@ -302,7 +302,7 @@ cmd3" "meta-data exists docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice" @@ -330,7 +330,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml-tests/composefiles/docker-compose.v2.1.yml : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml-tests/composefiles/docker-compose.v2.1.yml : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice" @@ -357,7 +357,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice-tests/composefiles/docker-compose.v2.0.yml : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice" @@ -381,7 +381,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_failure assert_output --partial "Exited with 2" @@ -409,7 +409,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled myservice" @@ -437,7 +437,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice without tty" @@ -463,7 +463,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice without dependencies" @@ -490,7 +490,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice without ansi output" @@ -517,7 +517,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with use aliases output" @@ -545,7 +545,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -572,7 +572,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -602,7 +602,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -635,7 +635,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -671,7 +671,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -706,7 +706,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -733,7 +733,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice with volumes" @@ -761,7 +761,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice-llamas1.yml-llamas2.yml-llamas3.yml : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -787,7 +787,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_failure assert_output --partial "^^^ +++" @@ -818,7 +818,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice2 : exit 0" \ "meta-data get docker-compose-plugin-built-image-tag-myservice2 : echo myimage2" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "pulled myservice1 and myservice2" @@ -845,7 +845,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -872,7 +872,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -895,7 +895,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_failure assert_output --partial "Error" @@ -923,7 +923,7 @@ export BUILDKITE_JOB_ID=1111 "meta-data exists docker-compose-plugin-built-image-tag-myservice : echo myimage" \ "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "ran myservice without tty" @@ -941,8 +941,6 @@ export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false export BUILDKITE_PLUGIN_DOCKER_COMPOSE_ENTRYPOINT="my custom entrypoint" - ENTRYPOINT='--entrypoint\ \"my\ custom\ entrypoint\"' - stub docker-compose \ "-f docker-compose.yml -p buildkite1111 build --pull myservice : echo built myservice" \ "-f docker-compose.yml -p buildkite1111 up -d --scale myservice=0 : echo ran myservice dependencies" \ @@ -951,7 +949,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -978,7 +976,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -1006,7 +1004,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -1033,7 +1031,7 @@ export BUILDKITE_JOB_ID=1111 stub buildkite-agent \ "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 1" - run $PWD/hooks/command + run "$PWD"/hooks/command assert_success assert_output --partial "built myservice" @@ -1064,7 +1062,7 @@ export BUILDKITE_JOB_ID=1111 apk add netcat-openbsd nc -lkvU $SSH_AUTH_SOCK & - run $PWD/hooks/command + run "$PWD"/hooks/command kill %1 From d9ccb60818571bc67d4bf0030aa39244ef6cb455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 01:19:34 -0300 Subject: [PATCH 7/8] Add test for new option --- tests/run.bats | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/run.bats b/tests/run.bats index 9389eb58..9f7dbe85 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -498,6 +498,33 @@ export BUILDKITE_JOB_ID=1111 unstub buildkite-agent } + +@test "Run without pull" { + export BUILDKITE_JOB_ID=1111 + export BUILDKITE_PIPELINE_SLUG=test + export BUILDKITE_BUILD_NUMBER=1 + export BUILDKITE_COMMAND=pwd + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_SKIP_PULL=true + + stub docker-compose \ + "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml up -d --scale myservice=0 myservice : echo started dependencies for myservice" \ + "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml run --name buildkite1111_myservice_build_1 --rm myservice /bin/sh -e -c 'pwd' : echo ran myservice without pull" + + stub buildkite-agent \ + "meta-data exists docker-compose-plugin-built-image-tag-myservice : exit 0" \ + "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" + + run "$PWD"/hooks/command + + assert_success + assert_output --partial "Running /bin/sh -e -c 'pwd' in service myservice" + assert_output --partial "ran myservice without pull" + + unstub docker-compose + unstub buildkite-agent +} + @test "Run with use aliases" { export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice From 36983425631acc5f7711e6780d6b3c755bbf40ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20A=2E=20Bellone?= Date: Thu, 6 Oct 2022 02:11:27 -0300 Subject: [PATCH 8/8] Clarified skup-checkout option (closes #232) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18e68a65..794ca8c4 100644 --- a/README.md +++ b/README.md @@ -438,7 +438,9 @@ Example: `[ "powershell", "-Command" ]` ### `skip-checkout` (optional, run only) -Whether to skip the repository checkout phase. This is useful for steps that use a pre-built image. This will fail if there is no pre-built image. +Whether to skip the repository checkout phase. This is useful for steps that use a pre-built image and will fail if there is no pre-built image. + +**Important**: as the code repository will not be available in the step, you need to ensure that the docker compose file(s) are present in some way (like using artifacts) ### `skip-pull` (optional, run only)