Skip to content

Commit 05de633

Browse files
committed
servo-macos15-arm: initial
1 parent be8b5e3 commit 05de633

File tree

4 files changed

+394
-1
lines changed

4 files changed

+394
-1
lines changed

monitor/src/image.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use shell::{log_output_as_info, reflink_or_copy_with_warning};
2828
use tracing::{error, info, warn};
2929

3030
use crate::{
31-
image::{macos13::Macos13, ubuntu2204::Ubuntu2204, windows10::Windows10},
31+
image::{
32+
macos13::{Macos13, MacosUtm},
33+
ubuntu2204::Ubuntu2204,
34+
windows10::Windows10,
35+
},
3236
policy::Policy,
3337
};
3438

@@ -46,6 +50,10 @@ static IMAGES: LazyLock<BTreeMap<String, Box<dyn Image + Send + Sync>>> = LazyLo
4650
"servo-macos15".to_owned(),
4751
Box::new(Macos13::new(ByteSize::gib(90), Duration::from_secs(2000))),
4852
);
53+
result.insert(
54+
"servo-macos15-arm".to_owned(),
55+
Box::new(MacosUtm::new(Duration::from_secs(2000))),
56+
);
4957
result.insert(
5058
"servo-ubuntu2204".to_owned(),
5159
Box::new(Ubuntu2204::new(

monitor/src/image/macos13.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::ffi::OsStr;
22
use std::fs::copy;
3+
use std::fs::create_dir_all;
34
use std::fs::remove_file;
45
use std::path::Path;
56
use std::time::Duration;
@@ -74,6 +75,57 @@ impl Image for Macos13 {
7475
}
7576
}
7677

78+
pub struct MacosUtm {
79+
wait_duration: Duration,
80+
}
81+
82+
impl MacosUtm {
83+
pub const fn new(wait_duration: Duration) -> Self {
84+
Self { wait_duration }
85+
}
86+
}
87+
88+
#[expect(unused_variables)]
89+
impl Image for MacosUtm {
90+
fn rebuild(&self, profile: &Profile, snapshot_name: &str) -> eyre::Result<()> {
91+
let profile_name = &profile.profile_name;
92+
let rebuild_guest_name = &profile.rebuild_guest_name(snapshot_name);
93+
hypervisor::utm::clone_guest(&format!("{profile_name}-clean"), rebuild_guest_name)?;
94+
95+
start_guest(rebuild_guest_name)?;
96+
wait_for_guest(rebuild_guest_name, self.wait_duration)?;
97+
98+
let template_guest_name = &profile.template_guest_name(snapshot_name);
99+
rename_guest(rebuild_guest_name, template_guest_name)?;
100+
create_dir_all(get_profile_data_path(&profile.profile_name, None)?)?;
101+
let snapshot_symlink_path =
102+
get_profile_data_path(&profile.profile_name, Path::new("snapshot"))?;
103+
atomic_symlink(snapshot_name, snapshot_symlink_path)?;
104+
105+
Ok(())
106+
}
107+
fn delete_template(&self, profile: &Profile, snapshot_name: &str) -> eyre::Result<()> {
108+
delete_guest(&profile.template_guest_name(snapshot_name))
109+
}
110+
fn register_runner(&self, profile: &Profile, runner_guest_name: &str) -> eyre::Result<String> {
111+
register_runner(profile, runner_guest_name)
112+
}
113+
fn create_runner(
114+
&self,
115+
profile: &Profile,
116+
snapshot_name: &str,
117+
runner_guest_name: &str,
118+
runner_id: usize,
119+
) -> eyre::Result<String> {
120+
let template_guest_name = &profile.template_guest_name(snapshot_name);
121+
hypervisor::utm::clone_guest(template_guest_name, runner_guest_name)?;
122+
Ok(runner_guest_name.to_owned())
123+
}
124+
fn destroy_runner(&self, runner_guest_name: &str, _runner_id: usize) -> eyre::Result<()> {
125+
delete_guest(runner_guest_name)
126+
}
127+
}
128+
77129
pub(super) fn rebuild(
78130
profile: &Profile,
79131
snapshot_name: &str,
@@ -104,6 +156,7 @@ pub(super) fn rebuild(
104156

105157
let template_guest_name = &profile.template_guest_name(snapshot_name);
106158
rename_guest(rebuild_guest_name, template_guest_name)?;
159+
create_dir_all(get_profile_data_path(&profile.profile_name, None)?)?;
107160
let snapshot_symlink_path =
108161
get_profile_data_path(&profile.profile_name, Path::new("snapshot"))?;
109162
atomic_symlink(snapshot_name, snapshot_symlink_path)?;
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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

Comments
 (0)