|
| 1 | +#!/usr/bin/env zsh |
| 2 | +set -euxo pipefail -o bsdecho |
| 3 | + |
| 4 | +download() { |
| 5 | + curl -fsSLO "http://192.168.100.1:8000/image-deps/macos13/$1" |
| 6 | +} |
| 7 | + |
| 8 | +install_github_actions_runner() { |
| 9 | + if ! [ -e actions-runner-osx-x64.tar.gz ]; then |
| 10 | + download actions-runner-osx-x64.tar.gz |
| 11 | + rm -Rf actions-runner |
| 12 | + mkdir -p actions-runner |
| 13 | + ( cd actions-runner; tar xf ../actions-runner-osx-x64.tar.gz ) |
| 14 | + fi |
| 15 | +} |
| 16 | + |
| 17 | +bake_servo_repo() ( |
| 18 | + # Note the parentheses around this block, so we only cd for this function |
| 19 | + cd ~/a/servo/servo |
| 20 | + |
| 21 | + # Fix the remote url, since it’s still set to our cache |
| 22 | + git remote set-url origin https://github.com/servo/servo.git |
| 23 | + |
| 24 | + # Install the Rust toolchain, for checkouts without servo#35795 |
| 25 | + rustup show active-toolchain || rustup toolchain install |
| 26 | + |
| 27 | + ./mach bootstrap --force |
| 28 | + # Build the same way as a typical macOS libservo job, to allow for incremental builds. |
| 29 | + # FIXME: `cargo build -p libservo` is busted on most platforms <https://github.com/servo/servo/issues/37939> |
| 30 | + # FIXME: `cargo build -p libservo` is untested in CI <https://github.com/servo/servo/issues/38015> |
| 31 | + # cargo build -p libservo --all-targets --release --target-dir target/libservo |
| 32 | + # Build the same way as a typical macOS build job, to allow for incremental builds. |
| 33 | + ./mach build --use-crown --locked --release |
| 34 | +) |
| 35 | + |
| 36 | +start_github_actions_runner() { |
| 37 | + curl -fsS --max-time 5 --retry 99 --retry-all-errors http://192.168.100.1:8000/github-jitconfig | jq -er . > jitconfig |
| 38 | + actions-runner/run.sh --jitconfig $(cat jitconfig) |
| 39 | +} |
| 40 | + |
| 41 | +mkdir -p /Users/servo/ci |
| 42 | +cd /Users/servo/ci |
| 43 | + |
| 44 | +# Resize the window to occupy more of the 1280x800 display |
| 45 | +# - Method based on <https://apple.stackexchange.com/a/290802> |
| 46 | +# - Another method for exclusive fullscreen <https://apple.stackexchange.com/a/58962> |
| 47 | +# - Another method with unclear automation <https://apple.stackexchange.com/a/228052> |
| 48 | +osascript -e 'tell application "Terminal"' -e 'activate' -e 'set the bounds of the first window to {0,0,1280,600}' -e 'end tell' |
| 49 | + |
| 50 | +# Disable sleep and display sleep |
| 51 | +# <https://apple.stackexchange.com/a/458157> |
| 52 | +sudo pmset sleep 0 |
| 53 | +sudo pmset displaysleep 0 |
| 54 | + |
| 55 | +# ~/.cargo/env requires HOME to be set |
| 56 | +export HOME=/Users/servo |
| 57 | + |
| 58 | +# Ensure uv is on PATH |
| 59 | +export PATH=$HOME/.local/bin:$PATH |
| 60 | + |
| 61 | +if ! [ -e image-built ]; then |
| 62 | + # Install Xcode CLT (Command Line Tools) non-interactively |
| 63 | + # <https://github.com/actions/runner-images/blob/3d5f09a90fd475a3531b0ef57325aa7e27b24595/images/macos/scripts/build/install-xcode-clt.sh> |
| 64 | + download install-xcode-clt.sh |
| 65 | + chmod +x install-xcode-clt.sh |
| 66 | + sudo -i mkdir -p /var/root/utils |
| 67 | + sudo -i touch /var/root/utils/utils.sh |
| 68 | + sudo -i $PWD/install-xcode-clt.sh |
| 69 | + |
| 70 | + # Install Homebrew |
| 71 | + if ! [ -e /usr/local/bin/brew ]; then |
| 72 | + download install-homebrew.sh |
| 73 | + chmod +x install-homebrew.sh |
| 74 | + NONINTERACTIVE=1 ./install-homebrew.sh |
| 75 | + fi |
| 76 | + |
| 77 | + set -- gnu-tar # Install gtar(1) |
| 78 | + set -- "$@" jq # Used by start_github_actions_runner() |
| 79 | + |
| 80 | + brew install "$@" |
| 81 | + |
| 82 | + # Install rustup and the latest Rust |
| 83 | + if ! [ -e ~/.rustup ]; then |
| 84 | + download rustup-init |
| 85 | + chmod +x rustup-init |
| 86 | + ./rustup-init -y --quiet |
| 87 | + mkdir -p ~/.cargo |
| 88 | + curl -fsSLo ~/.cargo/config.toml http://192.168.100.1:8000/image-deps/cargo-config.toml |
| 89 | + fi |
| 90 | + |
| 91 | + # Install uv |
| 92 | + if ! [ -e ~/.local/bin/uv ]; then |
| 93 | + download uv-installer.sh |
| 94 | + chmod +x uv-installer.sh |
| 95 | + ./uv-installer.sh |
| 96 | + fi |
| 97 | +fi |
| 98 | + |
| 99 | +# Set up Cargo |
| 100 | +. ~/.cargo/env |
| 101 | + |
| 102 | +if ! [ -e image-built ]; then |
| 103 | + # Clone and bake the Servo repo |
| 104 | + mkdir -p ~/a/servo |
| 105 | + git clone http://192.168.100.1:8000/cache/servo/.git ~/a/servo/servo |
| 106 | + bake_servo_repo |
| 107 | + |
| 108 | + install_github_actions_runner |
| 109 | + touch image-built |
| 110 | + sudo shutdown -h now |
| 111 | + exit # `shutdown` does not exit |
| 112 | +else |
| 113 | + start_github_actions_runner |
| 114 | +fi |
0 commit comments