File: macos-ci-setup

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,418,812 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (100 lines) | stat: -rwxr-xr-x 3,533 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash

# This simple script can be used to set up a CI node running MacOS.
# An additional requirement that is *not* handled by this script is the
# installation of Xcode, which requires manual intervention.
#
# This script should first be run from an administrator account to install
# the dependencies necessary for running CI. It can be run without having
# to clone the LLVM repository with:
#
#   $ /bin/bash -c "$(curl -fsSl https://raw.githubusercontent.com/llvm/llvm-project/main/libcxx/utils/ci/macos-ci-setup)"
#
# Once the necessary dependencies have been installed, you can switch
# to a non-administrator account and run the script again, passing the
# --setup-launchd argument. That will install a Launchd agent to run the
# BuildKite agent whenever the current user is logged in. You should enable
# automatic login for that user, so that if the CI node goes down, the user
# is logged back in automatically when the node goes up again, and the
# BuildKite agent starts automatically.
#
# Alternatively, you can simply run the BuildKite agent by hand using:
#
#   $ caffeinate -s buildkite-agent start --build-path /tmp/buildkite-builds

set -e

# Install a Launchd agent that will automatically start the BuildKite agent at login
if [[ ${1} == "--setup-launchd" ]]; then
  HOMEBREW_PREFIX="$(brew --prefix)"
  mkdir -p ~/Library/LaunchAgents
  cat <<EOF > ~/Library/LaunchAgents/libcxx.buildkite-agent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>libcxx.buildkite-agent</string>

  <key>ProgramArguments</key>
  <array>
    <string>${HOMEBREW_PREFIX}/bin/buildkite-agent</string>
    <string>start</string>
    <string>--build-path</string>
    <string>${HOME}/libcxx.buildkite-agent/builds</string>
  </array>

  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>${HOMEBREW_PREFIX}/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
  </dict>

  <key>RunAtLoad</key>
  <true/>

  <key>KeepAlive</key>
  <dict>
    <key>SuccessfulExit</key>
    <false/>
  </dict>

  <key>ProcessType</key>
  <string>Interactive</string>

  <key>ThrottleInterval</key>
  <integer>30</integer>

  <key>StandardOutPath</key>
  <string>${HOME}/libcxx.buildkite-agent/stdout.log</string>

  <key>StandardErrorPath</key>
  <string>${HOME}/libcxx.buildkite-agent/stderr.log</string>
</dict>
</plist>
EOF

  echo "Starting BuildKite agent"
  launchctl load ~/Library/LaunchAgents/libcxx.buildkite-agent.plist

else
  echo "Installing CI dependencies for macOS"

  if [[ -z "${BUILDKITE_AGENT_TOKEN}" ]]; then
    echo "The BUILDKITE_AGENT_TOKEN environment variable must be set to a BuildKite Agent token when calling this script."
    exit 1
  fi

  # Install Homebrew
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  HOMEBREW_PREFIX="$(brew --prefix)"

  # Install the required tools to run CI
  brew install sphinx-doc python3 ninja cmake clang-format buildkite/buildkite/buildkite-agent

  # Setup BuildKite Agent config
  version="$(sw_vers -productVersion | sed -E 's/([0-9]+).([0-9]+).[0-9]+/\1.\2/')"
  arch="$(uname -m)"
  sed -i '' "s/token=xxx/token=${BUILDKITE_AGENT_TOKEN}/g" "${HOMEBREW_PREFIX}/etc/buildkite-agent/buildkite-agent.cfg"
  echo "tags=\"queue=libcxx-builders,arch=${arch},os=macos,os=macos${version}\"" >> "${HOMEBREW_PREFIX}/etc/buildkite-agent/buildkite-agent.cfg"
fi