Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support post-bundle-update Command #8

Merged
merged 5 commits into from Sep 2, 2019

Conversation

@orien
Copy link
Member

commented Sep 2, 2019

Similar to the pre-bundle-update command, let's support a post-bundle-update command that runs after the bundle update. This allows for builds to perform some custom behaviour before changes are committed to source-control management.

plugins:
  - envato/bundle-update#v0.8.0:
      update: true
      post-bundle-update: my-custom-behaviour.sh

See it in action here: https://buildkite.com/envato-marketplaces/marketplace-bundle-update/builds/12#66132b75-4a71-47b2-97c8-4952474e5d32

@@ -14,7 +14,7 @@ This function runs `bundle update` from within a Docker container.
steps:
- label: ":bundler: Update"
plugins:
- envato/bundle-update#v0.7.0:
- envato/bundle-update#v0.8.0:

This comment has been minimized.

Copy link
@orien

orien Sep 2, 2019

Author Member

Bump the version number in examples, ready for the next release.

unstub buildkite-agent
}

@test "Passes the pre-bundle-update command" {

This comment has been minimized.

Copy link
@orien

orien Sep 2, 2019

Author Member

I added in an extra test for the pre-bundle-update command, as well as the post-bundle-update command below.

This comment has been minimized.

Copy link
@joesustaric

joesustaric Sep 5, 2019

Contributor

Just so I understand this test clearly.. you are stubbing the docker command.. then running the hooks/command and the test is that if the command calls docker with those arguments? (i.e essentially passing in the exported env values)

This comment has been minimized.

Copy link
@orien

orien Sep 5, 2019

Author Member

Yeah, exactly. It's not the best test under the sun.

This comment has been minimized.

Copy link
@joesustaric

joesustaric Sep 5, 2019

Contributor

I'd take this test over nothing any day 👍

#!/usr/bin/env bash
set -euo pipefail
#!/bin/sh
set -eu

This comment has been minimized.

Copy link
@orien

orien Sep 2, 2019

Author Member

Given the Docker image is supplied to the plugin, there's no guarantee that Bash will be installed. Let's drop back to bin/sh and make sure this script is portable.

@orien orien requested a review from joesustaric Sep 2, 2019

@orien orien marked this pull request as ready for review Sep 2, 2019

@@ -17,7 +17,8 @@ args=(
"--volume" "$PLUGIN_DIR/update:/update"
"--workdir" "/bundle_update"
"--env" "BUNDLE_APP_CONFIG=/bundle_app_config"
"--env" "PRE_BUNDLE_UPDATE=${script}"
"--env" "PRE_BUNDLE_UPDATE=${pre_bundle_update}"
"--env" "POST_BUNDLE_UPDATE=${post_bundle_update}"

This comment has been minimized.

Copy link
@orien

orien Sep 2, 2019

Author Member

We run the bundle update in a Docker container, so we'll need to pass the argument through via an environment variable. Just like the PRE_BUNDLE_UPDATE.


if [ -n "$POST_BUNDLE_UPDATE" ]; then
echo "--- :shell: Running post bundle update"
eval "$POST_BUNDLE_UPDATE"

This comment has been minimized.

Copy link
@orien

orien Sep 2, 2019

Author Member

Here we run the post-bundle-update command, if provided in the plugin definition in the project's pipeline.yml.

@orien orien merged commit dc37e4c into master Sep 2, 2019

5 checks passed

buildkite/bundle-update-buildkite-plugin Build #131 passed (39 seconds)
Details
buildkite/bundle-update-buildkite-plugin/hammer-test Passed (18 seconds)
Details
buildkite/bundle-update-buildkite-plugin/pipeline Passed (10 seconds)
Details
buildkite/bundle-update-buildkite-plugin/shell-shellcheck Passed (9 seconds)
Details
buildkite/bundle-update-buildkite-plugin/sparkles-lint Passed (13 seconds)
Details

@orien orien deleted the orien/post-bundle-update branch Sep 2, 2019

@joesustaric
Copy link
Contributor

left a comment

Sorry for the late review. was away.. Looks great! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.