blob: 3b2f42a8e79eb1d31710db692aa2f2d4d985c19a [file] [log] [blame]
Louis Dionnecc7d0842020-10-06 14:13:55 -04001#!/usr/bin/env bash
2
3# This simple script can be used to set up a CI node running MacOS.
4# An additional requirement that is *not* handled by this script is the
5# installation of Xcode, which requires manual intervention.
Louis Dionne2c7a3b52021-07-13 13:07:45 -04006#
7# This script should be run from an administrator account. It can be run
8# without having to clone the LLVM repository with:
9#
10# $ /bin/bash -c "$(curl -fsSl https://raw.githubusercontent.com/llvm/llvm-project/main/libcxx/utils/ci/macos-ci-setup)"
11#
12# Once the necessary dependencies have been installed, you can switch
13# to a non-administrator account and run:
14#
15# $ caffeinate -s buildkite-agent start --build-path /tmp/buildkite-builds
Louis Dionnecc7d0842020-10-06 14:13:55 -040016
Louis Dionneaf413c52021-07-12 15:44:28 -040017set -e
18
Louis Dionne137daee2021-06-14 15:55:36 -040019if [[ -z "${BUILDKITE_AGENT_TOKEN}" ]]; then
20 echo "The BUILDKITE_AGENT_TOKEN environment variable must be set to a BuildKite Agent token when calling this script."
21 exit 1
22fi
Louis Dionnecc7d0842020-10-06 14:13:55 -040023
24# Install Homebrew
25/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
26
27# Install the required tools to run CI
Louis Dionne87da9ed2020-12-11 14:06:24 -050028brew install sphinx-doc python3 ninja cmake clang-format buildkite/buildkite/buildkite-agent
Louis Dionnecc7d0842020-10-06 14:13:55 -040029
30CFG_DIR="$(brew --prefix)/etc/buildkite-agent"
31
Louis Dionne6a3ffe22021-02-02 14:59:35 -050032version="$(sw_vers -productVersion | sed -E 's/([0-9]+).([0-9]+).[0-9]+/\1.\2/')"
Louis Dionne60523a12021-07-12 15:34:17 -040033arch="$(uname -m)"
Louis Dionne6a3ffe22021-02-02 14:59:35 -050034
Louis Dionnecc7d0842020-10-06 14:13:55 -040035# Setup the tags of the agent
Louis Dionne695dd642021-07-12 17:22:26 -040036echo "tags=\"queue=libcxx-builders,arch=${arch},os=macos,os=macos${version}\"" >> "${CFG_DIR}/buildkite-agent.cfg"
Louis Dionnecc7d0842020-10-06 14:13:55 -040037
38# Setup the BuildKite Agent token
39sed -i '' "s/xxx/${BUILDKITE_AGENT_TOKEN}/g" "${CFG_DIR}/buildkite-agent.cfg"