From 6adfdfa8544bbb5ad62c5b7a791f56f8f722f69c Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 16 Nov 2022 11:24:50 +0100 Subject: [PATCH 1/2] Add Buildkite hook to install `xcodes` --- .buildkite/hooks/pre-command | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 .buildkite/hooks/pre-command diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command new file mode 100755 index 00000000000..7e4f5ae233a --- /dev/null +++ b/.buildkite/hooks/pre-command @@ -0,0 +1,16 @@ +#!/bin/bash + +# Job lifecycle hooks are sourced by the Buildkite bootstrap in the different +# job phases, so we need to explicitly call `set -e` etc. instead of passing +# the options to the shebang. +set -e + +# This is a temporary check while we provision the tool as part of our VMs in +# CI. +if [[ $IMAGE_ID =~ ^xcode ]]; then + echo '--- :xcode: Ensure xcodes tool is installed' + brew install xcodes +else + # Leave a note in the logs for why the hook returned without doing anything. + echo 'Running on an agent that does not use Xcode. Skipping xcodes tool installation.' +fi From 7881a046cb3a135fe76f7d953dc334630cc748bf Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 16 Nov 2022 13:43:29 +0100 Subject: [PATCH 2/2] Use `BUILDKITE_AGENT_META_DATA_QUEUE` in Buildkite pre-command hook --- .buildkite/hooks/pre-command | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 7e4f5ae233a..f3fa9228c45 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -7,7 +7,17 @@ set -e # This is a temporary check while we provision the tool as part of our VMs in # CI. -if [[ $IMAGE_ID =~ ^xcode ]]; then +# +# A more precise check would be: +# +# if [[ $IMAGE_ID =~ ^xcode ]]; then +# +# but our tooling doesn't currently forward that environment variable. +# See +# +# - https://github.com/Automattic/hostmgr/pull/47 +# - https://github.com/Automattic/hostmgr/issues/48 +if [[ $BUILDKITE_AGENT_META_DATA_QUEUE = 'mac' ]]; then echo '--- :xcode: Ensure xcodes tool is installed' brew install xcodes else