diff --git a/.buildkite/hooks/asdf-pre-command b/.buildkite/hooks/asdf-pre-command new file mode 100755 index 000000000..cbdcbd37c --- /dev/null +++ b/.buildkite/hooks/asdf-pre-command @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file +# if the pidfile exists we know another process is executing so we don't need to install anything +# +# A more robust approach would be to use a lock file, but that would require some more work +set -eu +pushd "$(dirname "${BASH_SOURCE[0]}")"/../.. + +WORKDIR=$(pwd) +PIDFILE=/var/lock/dobackup.pid + +remove_pidfile() +{ + rm -f "$PIDFILE" +} + +another_instance() +{ + echo "There is another instance running, skipping" + exit 0 +} + +if [ -f "$PIDFILE" ]; then + kill -0 "$(cat $PIDFILE)" && another_instance +fi +trap remove_pidfile EXIT +echo $$ > "$PIDFILE" + +echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':" +asdf install diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command old mode 100755 new mode 100644 index cbdcbd37c..1a52196e7 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -1,30 +1,11 @@ #!/usr/bin/env bash -# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file -# if the pidfile exists we know another process is executing so we don't need to install anything -# -# A more robust approach would be to use a lock file, but that would require some more work -set -eu -pushd "$(dirname "${BASH_SOURCE[0]}")"/../.. - -WORKDIR=$(pwd) -PIDFILE=/var/lock/dobackup.pid - -remove_pidfile() -{ - rm -f "$PIDFILE" -} - -another_instance() -{ - echo "There is another instance running, skipping" +# Skip the rest if this is pipeline upload or empty +if [[ "${BUILDKITE_COMMAND:-}" =~ "buildkite-agent pipeline upload".* ]]; then + exit 0 +elif [[ "${BUILDKITE_COMMAND:-}" = "" ]]; then exit 0 -} - -if [ -f "$PIDFILE" ]; then - kill -0 "$(cat $PIDFILE)" && another_instance fi -trap remove_pidfile EXIT -echo $$ > "$PIDFILE" -echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':" -asdf install +if [ ! -f .use_mise ]; then + source ./asdf-pre-command +fi diff --git a/.use_mise b/.use_mise new file mode 100644 index 000000000..5c2719a04 --- /dev/null +++ b/.use_mise @@ -0,0 +1,6 @@ +Stateless CI agents use the presence of this file to determine whether it should install tools with mise or install them with ASDF. +Thus if you delete this file, CI will use ASDF to install tools and not mise. + +The file is only meant to be here while we transition to using mise completely. + +For more information you can reach out to the dev-infra team on #discuss-dev-infra.