Closed frankpengau closed 1 year ago
Local Testing with bk local run
➜ docker-buildkite-plugin git:(xmas-2022-updates) bk local run
>>> Starting local agent 🤖
>>> Starting build 👟
>>> Executing initial command: buildkite-agent pipeline upload
>>> Executing command step 🐚 Shellcheck
~~~ Preparing plugins
# Plugin "github.com/buildkite-plugins/shellcheck-buildkite-plugin" will be checked out to "/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-shellcheck-buildkite-plugin-v1-3-0"
# Switching to the temporary plugin directory
$ cd /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-shellcheck-buildkite-plugin-v1-3-0666322005
$ git clone -v --recursive -- https://github.com/buildkite-plugins/shellcheck-buildkite-plugin .
Cloning into '.'...
POST git-upload-pack (193 bytes)
POST git-upload-pack (620 bytes)
remote: Enumerating objects: 373, done.
remote: Counting objects: 100% (102/102), done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 373 (delta 57), reused 81 (delta 52), pack-reused 271
Receiving objects: 100% (373/373), 85.34 KiB | 3.56 MiB/s, done.
Resolving deltas: 100% (152/152), done.
# Checking out `v1.3.0`
$ git checkout -f v1.3.0
Note: switching to 'v1.3.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 03732ed Merge pull request #42 from segmentio/mckern/globstar
# Moving temporary plugin directory to final location
$ cd /private/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-build-126807773
$ cd /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin
~~~ Running plugin shellcheck command hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-shellcheck-buildkite-plugin-v1-3-0/hooks/command
~~~ Checking for glob behavior modifiers
+++ Running shellcheck on 3 files
Files are ok ✅
>>> Command succeeded in 5.809849625s
>>> Executing command step ✨
~~~ Preparing plugins
# Plugin "github.com/buildkite-plugins/plugin-linter-buildkite-plugin" will be checked out to "/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-plugin-linter-buildkite-plugin-v3-0-0"
# Switching to the temporary plugin directory
$ cd /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-plugin-linter-buildkite-plugin-v3-0-01766645163
$ git clone -v --recursive -- https://github.com/buildkite-plugins/plugin-linter-buildkite-plugin .
Cloning into '.'...
POST git-upload-pack (193 bytes)
POST git-upload-pack (420 bytes)
remote: Enumerating objects: 273, done.
remote: Counting objects: 100% (62/62), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 273 (delta 25), reused 61 (delta 25), pack-reused 211
Receiving objects: 100% (273/273), 75.17 KiB | 2.89 MiB/s, done.
Resolving deltas: 100% (110/110), done.
# Checking out `v3.0.0`
$ git checkout -f v3.0.0
Note: switching to 'v3.0.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at bd8359b Merge pull request #38 from buildkite-plugins/renovate/docker-compose-3.x
# Moving temporary plugin directory to final location
$ cd /private/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-build-126807773
$ cd /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin
~~~ Running plugin plugin-linter command hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-plugin-linter-buildkite-plugin-v3-0-0/hooks/command
--- :docker: Fetching the latest buildkite/plugin-linter
Using default tag: latest
Failed to fire hook: while creating logrus local file hook: user: Current requires cgo or $USER set in environment
[2022-12-29T23:35:07.456657000Z][docker-credential-desktop][F] user: Current requires cgo or $USER set in environment
[common/pkg/paths.Home()
[ common/pkg/paths/paths.go:105 +0x58
[common/pkg/paths.Container()
[ common/pkg/paths/user_darwin.go:37 +0x1c
[common/pkg/paths.Data()
[ common/pkg/paths/paths_darwin.go:27 +0x1c
[common/pkg/paths.setCurrentDirectory()
[ common/pkg/paths/paths.go:61 +0x20
[common/pkg/paths.Init(0x0?)
[ common/pkg/paths/paths.go:45 +0x20
[main.main()
[ common/cmd/docker-credential-desktop/main.go:43 +0x3c
latest: Pulling from buildkite/plugin-linter
Digest: sha256:cae8c12d3741c0f32dcb524f5d988ce6f4b34b40c0bfb887b9a2a9c82406163b
Status: Image is up to date for buildkite/plugin-linter:latest
docker.io/buildkite/plugin-linter:latest
+++ Linting
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
TAP version 13
ok 1 - plugin.yml is valid
ok 2 - All the readme config examples for plugin id 'docker' are valid (8 found)
ok 3 - Readme version numbers are up-to-date (undefined)
1..3
# time=306.854ms
>>> Command succeeded in 13.506064042s
>>> Executing command step :docker: 🔨
~~~ Preparing plugins
# Plugin "github.com/buildkite-plugins/docker-compose-buildkite-plugin" will be checked out to "/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-docker-compose-buildkite-plugin-v4-5-0"
# Switching to the temporary plugin directory
$ cd /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-docker-compose-buildkite-plugin-v4-5-03061174592
$ git clone -v --recursive -- https://github.com/buildkite-plugins/docker-compose-buildkite-plugin .
Cloning into '.'...
POST git-upload-pack (193 bytes)
POST git-upload-pack (gzip 3820 to 1927 bytes)
remote: Enumerating objects: 3676, done.
remote: Counting objects: 100% (856/856), done.
remote: Compressing objects: 100% (338/338), done.
remote: Total 3676 (delta 575), reused 742 (delta 516), pack-reused 2820
Receiving objects: 100% (3676/3676), 901.39 KiB | 3.18 MiB/s, done.
Resolving deltas: 100% (2115/2115), done.
# Checking out `v4.5.0`
$ git checkout -f v4.5.0
Note: switching to 'v4.5.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 779e0e1 Merge pull request #354 from buildkite-plugins/toote_mount_checkout_path
# Moving temporary plugin directory to final location
$ cd /private/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-build-126807773
$ cd /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin
~~~ Running plugin docker-compose command hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-docker-compose-buildkite-plugin-v4-5-0/hooks/command
2022-12-30 10:35:15 WARN POST http://127.0.0.1:51123/jobs/2dcddc04-157f-410c-a8f1-ec1a1c6a3c88/data/exists: 404 (Attempt 1/10 Retrying in 5s)
2022-12-30 10:35:15 FATAL Failed to see if meta-data exists: POST http://127.0.0.1:51123/jobs/2dcddc04-157f-410c-a8f1-ec1a1c6a3c88/data/exists: 404
~~~ :docker: Building Docker Compose Service: tests
⚠️ No pre-built image found from a previous 'build' step for this service and config file. Building image...
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 build --pull tests
~~~ :docker: Starting dependencies
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 up -d --scale tests=0 tests
[+] Running 1/0
⠿ Network buildkite2dcddc04157f410ca8f1ec1a1c6a3c88_default Created 0.0s
+++ :docker: Running in service tests
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 run --name buildkite2dcddc04157f410ca8f1ec1a1c6a3c88_tests_build_1 --rm tests
command.bats
✓ Run with BUILDKITE_COMMAND
✓ Run with BUILDKITE_COMMAND and cleanup remaining containers
✓ Pull image first before running BUILDKITE_COMMAND
✓ Runs BUILDKITE_COMMAND with mount-buildkite-agent disabled specifically
✓ Runs BUILDKITE_COMMAND with mount-buildkite-agent enabled but no command
✓ Runs BUILDKITE_COMMAND with mount-buildkite-agent enabled but with command
✓ Runs BUILDKITE_COMMAND with volumes
✓ Runs BUILDKITE_COMMAND with volumes with variables
✓ Runs BUILDKITE_COMMAND with volumes with variables and option turned off
✓ Runs BUILDKITE_COMMAND with volumes with variables and option turned on
✓ Runs BUILDKITE_COMMAND with devices
✓ Runs BUILDKITE_COMMAND with publish
✓ Runs BUILDKITE_COMMAND with sysctls
✓ Runs BUILDKITE_COMMAND with leave-container=false
✓ Runs BUILDKITE_COMMAND with leave-container=true
✓ Runs BUILDKITE_COMMAND with mount-checkout=false
✓ Runs BUILDKITE_COMMAND with mount-checkout=true
✓ Runs BUILDKITE_COMMAND with deprecated mounts
✓ Runs BUILDKITE_COMMAND with environment
✓ Runs BUILDKITE_COMMAND with environment files
✓ Runs BUILDKITE_COMMAND with storage-opt
✓ Runs BUILDKITE_COMMAND with shm size
✓ Runs BUILDKITE_COMMAND with pid namespace
✓ Runs BUILDKITE_COMMAND with cpus
✓ Runs BUILDKITE_COMMAND with gpus
✓ Runs BUILDKITE_COMMAND with propagate environment
✓ Runs BUILDKITE_COMMAND with user
✓ Runs BUILDKITE_COMMAND with userns
✓ Runs BUILDKITE_COMMAND with additional groups
✓ Runs BUILDKITE_COMMAND with propagated uid and guid
✓ Runs BUILDKITE_COMMAND with network that doesn't exist
✓ Runs BUILDKITE_COMMAND with custom runtime
✓ Runs BUILDKITE_COMMAND with custom IPC option
✓ Runs BUILDKITE_COMMAND with entrypoint without explicit shell
✓ Runs BUILDKITE_COMMAND with entrypoint with explicit shell
✓ Runs BUILDKITE_COMMAND with entrypoint disabled by empty string
✓ Runs BUILDKITE_COMMAND with entrypoint set as false
✓ Runs BUILDKITE_COMMAND with shell
✓ Runs BUILDKITE_COMMAND with shell option as string
✓ Runs BUILDKITE_COMMAND with shell disabled
✓ Runs BUILDKITE_COMMAND with add-host
✓ Runs with a command as a string
✓ Runs with a command as an array
✓ Runs with a command as an array with a shell
✓ Runs with a command as an array with a shell and an entrypoint
✓ Doesn't disclose environment
✓ Run with BUILDKITE_REPO_MIRROR
✓ Run with BUILDKITE_REPO_MIRROR but mount-checkout=false
✓ Run with BUILDKITE_REPO_MIRROR in addition to other volumes
✓ Runs BUILDKITE_COMMAND with propagate aws auth tokens
✓ Doesn't disclose aws auth tokens
✓ Runs BUILDKITE_COMMAND with memory options
✓ Runs BUILDKITE_COMMAND with memory-swap options
✓ Runs BUILDKITE_COMMAND with memory-swappiness options
✓ Runs BUILDKITE_COMMAND with implicit no swap
✓ Runs BUILDKITE_COMMAND with one added capability
✓ Runs BUILDKITE_COMMAND with multiple added capabilities
✓ Runs BUILDKITE_COMMAND with one dropped capability
✓ Runs BUILDKITE_COMMAND with multiple dropped capabilities
✓ Runs BUILDKITE_COMMAND with one security opt
✓ Runs BUILDKITE_COMMAND with multiple security opts
✓ Runs BUILDKITE_COMMAND with one ulimit
✓ Runs BUILDKITE_COMMAND with multiple ulimits
✓ Runs BUILDKITE_COMMAND without interactive option
✓ Runs BUILDKITE_COMMAND with interactive option
✓ Runs BUILDKITE_COMMAND without tty option
✓ Runs BUILDKITE_COMMAND with tty option
✓ Run with BUILDKITE_COMMAND that exits with a failure
✓ Run with BUILDKITE_COMMAND propagates exit codes
✓ Run with BUILDKITE_COMMAND propagates subshell exit codes
✓ Run with multi-line BUILDKITE_COMMAND
pre-checkout.bats
✓ Run without specific options
✓ Run with skip-checkout turned off
✓ Run with skip-checkout turned on
74 tests, 0 failures
~~~ Running plugin docker-compose pre-exit hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/github-com-buildkite-plugins-docker-compose-buildkite-plugin-v4-5-0/hooks/pre-exit
~~~ :docker: Cleaning up after docker-compose
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 kill
no container to kill
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 rm --force -v
No stopped containers
$ docker-compose -f docker-compose.yml -p buildkite2dcddc04157f410ca8f1ec1a1c6a3c88 down --volumes
[+] Running 1/0
⠿ Network buildkite2dcddc04157f410ca8f1ec1a1c6a3c88_default Removed 0.0s
>>> Command succeeded in 1m4.561691083s
>>> Executing command step run the plugin
~~~ Preparing plugins
# Plugin "/Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin" will be checked out to "/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc"
# Switching to the temporary plugin directory
$ cd /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc2499623989
$ git clone -v --recursive -- /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin .
Cloning into '.'...
done.
# Checking out `1aed7267cbafbc25e3a3b365005825a360d4a9fc`
$ git checkout -f 1aed7267cbafbc25e3a3b365005825a360d4a9fc
Note: switching to '1aed7267cbafbc25e3a3b365005825a360d4a9fc'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 1aed726 making shellcheck happy
# Moving temporary plugin directory to final location
$ cd /private/var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-build-126807773
$ cd /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin
~~~ Running plugin docker command hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc/hooks/command
--- :docker: Running command in ubuntu:22.04
$ docker run -t -i --rm --init --volume /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin:/workdir --workdir /workdir --label com.buildkite.job-id=56096436-a617-4ab5-8229-33e89ab6fb98 ubuntu:22.04 /bin/sh -e -c echo\ hello\ world
Unable to find image 'ubuntu:22.04' locally
Failed to fire hook: while creating logrus local file hook: user: Current requires cgo or $USER set in environment
[2022-12-29T23:36:05.215344000Z][docker-credential-desktop][F] user: Current requires cgo or $USER set in environment
[common/pkg/paths.Home()
[ common/pkg/paths/paths.go:105 +0x58
[common/pkg/paths.Container()
[ common/pkg/paths/user_darwin.go:37 +0x1c
[common/pkg/paths.Data()
[ common/pkg/paths/paths_darwin.go:27 +0x1c
[common/pkg/paths.setCurrentDirectory()
[ common/pkg/paths/paths.go:61 +0x20
[common/pkg/paths.Init(0x0?)
[ common/pkg/paths/paths.go:45 +0x20
[main.main()
[ common/cmd/docker-credential-desktop/main.go:43 +0x3c
22.04: Pulling from library/ubuntu
Digest: sha256:27cb6e6ccef575a4698b66f5de06c7ecd61589132d5a91d098f7f3f9285415a9
Status: Downloaded newer image for ubuntu:22.04
hello world
~~~ Running plugin docker pre-exit hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc/hooks/pre-exit
>>> Command succeeded in 1m9.570592042s
>>> Executing command step ensure exit codes are propagated
~~~ Preparing plugins
# Plugin "/Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin#1aed7267cbafbc25e3a3b365005825a360d4a9fc" already checked out (1aed726)
$ cd /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin
~~~ Running plugin docker command hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc/hooks/command
--- :docker: Running command in ubuntu:22.04
$ docker run -t -i --rm --init --volume /Users/frank.peng/Repos/experiments/git-forks/docker-buildkite-plugin:/workdir --workdir /workdir --label com.buildkite.job-id=e4267c1b-e213-4e25-803b-7f4518afa554 ubuntu:22.04 /bin/sh -e -c exit\ 3
🚨 Error: The command exited with status 3
^^^ +++
^^^ +++
user command error: The plugin docker command hook exited with status 3
~~~ Running plugin docker pre-exit hook
$ /var/folders/g5/gldb9rfd6xv_6s5fh1x4w3840000gp/T/buildkite-plugins-763029656/Users-frank-peng-Repos-experiments-git-forks-docker-buildkite-plugin-1aed7267cbafbc25e3a3b365005825a360d4a9fc/hooks/pre-exit
>>> 🚨 Command failed in 1m10.576008917s
🚨 Job failed with code 3
^ Still feels a bit weird seeing that the command/job failed with exit code 3, but realised it is intentional to test exit code propagation.
Thanks a lot for the contribution :)
hooks/command
for shellcheckshellcheck disable=SC2317
for false positives. To fix shellcheck prompt:SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).
According to shellcheck wiki:$retry_exit_status
exit code. To fix shellcheck prompt:SC2086 (info): Double quote to prevent globbing and word splitting.