Skip to content

Commit 573bcb9

Browse files
committed
Add .use_mise to use mise in CI
1 parent 782c470 commit 573bcb9

File tree

3 files changed

+43
-26
lines changed

3 files changed

+43
-26
lines changed

.buildkite/hooks/asdf-pre-command

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file
3+
# if the pidfile exists we know another process is executing so we don't need to install anything
4+
#
5+
# A more robust approach would be to use a lock file, but that would require some more work
6+
set -eu
7+
pushd "$(dirname "${BASH_SOURCE[0]}")"/../..
8+
9+
WORKDIR=$(pwd)
10+
PIDFILE=/var/lock/dobackup.pid
11+
12+
remove_pidfile()
13+
{
14+
rm -f "$PIDFILE"
15+
}
16+
17+
another_instance()
18+
{
19+
echo "There is another instance running, skipping"
20+
exit 0
21+
}
22+
23+
if [ -f "$PIDFILE" ]; then
24+
kill -0 "$(cat $PIDFILE)" && another_instance
25+
fi
26+
trap remove_pidfile EXIT
27+
echo $$ > "$PIDFILE"
28+
29+
echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':"
30+
asdf install

.buildkite/hooks/pre-command

100755100644
Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
#!/usr/bin/env bash
2-
# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file
3-
# if the pidfile exists we know another process is executing so we don't need to install anything
4-
#
5-
# A more robust approach would be to use a lock file, but that would require some more work
6-
set -eu
7-
pushd "$(dirname "${BASH_SOURCE[0]}")"/../..
8-
9-
WORKDIR=$(pwd)
10-
PIDFILE=/var/lock/dobackup.pid
11-
12-
remove_pidfile()
13-
{
14-
rm -f "$PIDFILE"
15-
}
16-
17-
another_instance()
18-
{
19-
echo "There is another instance running, skipping"
2+
# Skip the rest if this is pipeline upload or empty
3+
if [[ "${BUILDKITE_COMMAND:-}" =~ "buildkite-agent pipeline upload".* ]]; then
4+
exit 0
5+
elif [[ "${BUILDKITE_COMMAND:-}" = "" ]]; then
206
exit 0
21-
}
22-
23-
if [ -f "$PIDFILE" ]; then
24-
kill -0 "$(cat $PIDFILE)" && another_instance
257
fi
26-
trap remove_pidfile EXIT
27-
echo $$ > "$PIDFILE"
288

29-
echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':"
30-
asdf install
9+
if [ ! -f .use_mise ]; then
10+
source ./asdf-pre-command
11+
fi

.use_mise

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Stateless CI agents use the presence of this file to determine whether it should install tools with mise or install them with ASDF.
2+
Thus if you delete this file, CI will use ASDF to install tools and not mise.
3+
4+
The file is only meant to be here while we transition to using mise completely.
5+
6+
For more information you can reach out to the dev-infra team on #discuss-dev-infra.

0 commit comments

Comments
 (0)