Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
- "crates/minvmd/**"
- "crates/minimald/**" # guest daemon: pid-1 in the e2e/boot VM
- "crates/minimal/**"
- "crates/minzoned/**" # the box-name service: the zoned job
- "crates/sessions/**" # platform-sensitive: canonicalization, symlinks
- "Cargo.toml"
- "Cargo.lock"
Expand Down Expand Up @@ -565,13 +566,55 @@ jobs:
if-no-files-found: error
retention-days: 3

zoned:
# The box-name service (minzoned) as a real LaunchDaemon: the
# privileged command `min` hands an operator, run for real, then the
# service proved through the system resolver, its channel, a restart
# and a clean teardown (scripts/zoned-macos-e2e.sh). It needs root,
# and the self-hosted fleet has no sudo because it runs PR code, so
# this runs on a GitHub-hosted runner: ephemeral, sudo without a
# password, no VM needed (a script stands in for the node). The
# debug `min` skips the codesign requirement check, so that part
# stays unproved here.
needs: [changes]
if: github.event_name != 'merge_group' && (github.event_name != 'pull_request' || needs.changes.outputs.macos == 'true')
runs-on: macos-latest
timeout-minutes: 30
env:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Toolchain
uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
with:
toolchain: stable
- name: Cache cargo registry and build artifacts
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 # zizmor: ignore[cache-poisoning] test-only lane, nothing published; save-if keeps every non-main ref read-only
with:
shared-key: mac-zoned
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build minzoned and min
# Two invocations, as the unit job builds its testbed: one
# cargo call would unify features across both packages.
# `min` finds `minzoned` beside its own executable.
run: |
set -euo pipefail
cargo build -p minzoned --locked
cargo build -p minimal --bin min --locked
- name: Prove the service install
env:
MINIMAL_E2E_PRIVILEGED: "1"
run: scripts/zoned-macos-e2e.sh target/debug/min

Comment thread
norrietaylor marked this conversation as resolved.
Resolved
# Single required status check for this lane (branch-protection context:
# ci-macos-success). Green when every gating job succeeded OR was
# path-skipped (or the RUN_MACOS_CI kill-switch skipped the e2e); red only
# on failure/cancellation.
ci-macos-success:
if: always()
needs: [changes, artifacts, e2e, unit]
needs: [changes, artifacts, e2e, unit, zoned]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand Down
121 changes: 120 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ jobs:
mv min minimal-linux-amd64
mv minimald minimald-linux-amd64
mv minvmd minvmd-linux-amd64
mv minzoned minzoned-linux-amd64
- name: Re-check minzoned links on the renamed artifact
# dist-build.sh gated the binary it built; re-run the same gate
# on the exact file that uploads, so the shipped bytes are the
# checked bytes.
run: scripts/check-zoned-links.sh target/x86_64-unknown-linux-musl/release/minzoned-linux-amd64
- name: Upload binary (minzoned)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: minzoned-linux-amd64
path: target/x86_64-unknown-linux-musl/release/minzoned-linux-amd64
retention-days: 7
- name: Upload binary (mip)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
Expand Down Expand Up @@ -378,6 +390,16 @@ jobs:
mv mip mip-linux-arm64
mv minimald minimald-linux-arm64
mv minvmd minvmd-linux-arm64
mv minzoned minzoned-linux-arm64
- name: Re-check minzoned links on the renamed artifact
# See the amd64 job: the gate runs again on the file that uploads.
run: scripts/check-zoned-links.sh target/aarch64-unknown-linux-musl/release/minzoned-linux-arm64
- name: Upload binary (minzoned)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: minzoned-linux-arm64
path: target/aarch64-unknown-linux-musl/release/minzoned-linux-arm64
retention-days: 7
- name: Upload binary (minimal)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
Expand Down Expand Up @@ -428,11 +450,20 @@ jobs:
# self-hosted runner is offline — a skip here also skips `release`, which
# needs it.
runs-on: [self-hosted, macOS, ARM64]
timeout-minutes: 45
# 60, not 45: the build takes about 15 minutes, and the notarization
# step below waits on Apple's notary service for three submissions.
timeout-minutes: 60
needs: [assert-version]
if: vars.RUN_MACOS_CI != 'false'
env:
MINIMAL_RELEASE_VERSION: ${{ needs.assert-version.outputs.release_version }}
# The signing identity minzoned is signed under below, compiled
# into `min` (option_env! in crates/minimal/src/resolver.rs): the
# session advisory verifies the copy source against the Developer
# ID requirement for this team and identifier, and a `min` built
# without them offers no answerer step on macOS.
MINIMAL_ZONED_TEAMID: 3G47C5HY64
MINIMAL_ZONED_IDENTIFIER: dev.minimal.minzoned
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
Expand Down Expand Up @@ -475,12 +506,21 @@ jobs:
printf '%s\n' "$bad" >&2
exit 1
fi
- name: Build release minzoned binary
Comment thread
norrietaylor marked this conversation as resolved.
Resolved
# Its OWN invocation, like minimal above and for the same reason:
# beside `-p minvmd` the libkrun feature would unify into the
# answerer a root host service must never carry. Link-gated as
# built; the gate runs again on the signed artifact below.
run: |
cargo build --release --locked -p minzoned --bin minzoned
scripts/check-zoned-links.sh target/release/minzoned
- name: Rename binaries with platform suffix
# download-artifact merge-multiple flattens on basename, so the uploaded
# file must already carry the platform-suffixed name the release job expects.
run: |
mv target/release/minvmd target/release/minvmd-macos-arm64
mv target/release/min target/release/minimal-macos-arm64
mv target/release/minzoned target/release/minzoned-macos-arm64
- name: Codesign binaries with Developer ID
# Sign the two shipped Mach-O binaries with the Developer ID
# Application identity held in the runner's signing keychain. This
Expand All @@ -505,9 +545,82 @@ jobs:
codesign --force --timestamp --options runtime \
--sign "$IDENTITY" \
target/release/minimal-macos-arm64
# minzoned: no entitlements at all (no hypervisor, no
# disable-library-validation, no dyld environment, no JIT),
# and an explicit identifier, the one `min` checks it by.
codesign --force --timestamp --options runtime \
--identifier "$MINIMAL_ZONED_IDENTIFIER" \
--sign "$IDENTITY" \
target/release/minzoned-macos-arm64

codesign --verify --strict --verbose=2 target/release/minvmd-macos-arm64
codesign --verify --strict --verbose=2 target/release/minimal-macos-arm64
# The exact designated requirement the session advisory and
# the privileged step verify the answerer against.
codesign --verify --strict --verbose=2 \
-R "=anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = \"$MINIMAL_ZONED_TEAMID\" and identifier \"$MINIMAL_ZONED_IDENTIFIER\"" \
target/release/minzoned-macos-arm64
- name: Re-check minzoned links on the signed artifact
# The last check before upload, on the signed and renamed bytes.
run: scripts/check-zoned-links.sh target/release/minzoned-macos-arm64
- name: Notarize binaries
# Submit each signed binary to Apple's notary service and fail the
# release unless every result is Accepted. Notarization does not
# modify the file, so the uploaded bytes stay the signed, link-gated
# bytes above. notarytool takes a zip, a .pkg or a .dmg, never a
# bare Mach-O, so each binary goes up in a ditto zip that is used
# only for the submission.
#
# No staple: the release ships each binary as a bare Mach-O file,
# and stapler cannot attach a ticket to one (only to an .app, a .pkg
# or a .dmg). Gatekeeper looks the ticket up online instead.
#
# The credentials are a notarytool keychain profile stored in the
# signing keychain; the repository variable MACOS_NOTARY_PROFILE
# names it.
env:
KC_PW: ${{ secrets.KC_PW }}
NOTARY_PROFILE: ${{ vars.MACOS_NOTARY_PROFILE }}
run: |
if [ -z "$NOTARY_PROFILE" ]; then
echo "::error::repository variable MACOS_NOTARY_PROFILE is not set" >&2
exit 1
fi
KC=minimal-signing.keychain-db
security unlock-keychain -p "$KC_PW" "$KC"

work="$RUNNER_TEMP/notarize"
rm -rf "$work"
mkdir -p "$work"
for f in target/release/minvmd-macos-arm64 \
target/release/minimal-macos-arm64 \
target/release/minzoned-macos-arm64; do
name=$(basename "$f")
zip="$work/$name.zip"
result="$work/$name.json"
ditto -c -k --keepParent "$f" "$zip"

echo "Submitting $name for notarization"
xcrun notarytool submit "$zip" \
--keychain-profile "$NOTARY_PROFILE" \
--keychain "$HOME/Library/Keychains/$KC" \
--wait --timeout 15m \
--output-format json >"$result" || true
cat "$result"

status=$(plutil -extract status raw -o - "$result" 2>/dev/null || true)
if [ "$status" != "Accepted" ]; then
echo "::error::notarization of $name ended with status '${status:-none}'" >&2
id=$(plutil -extract id raw -o - "$result" 2>/dev/null || true)
if [ -n "$id" ]; then
xcrun notarytool log "$id" \
--keychain-profile "$NOTARY_PROFILE" \
--keychain "$HOME/Library/Keychains/$KC" || true
fi
exit 1
fi
echo "$name: Accepted"
done
- name: Upload binary (minvmd)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
Expand All @@ -520,6 +633,12 @@ jobs:
name: minimal-macos-arm64
path: target/release/minimal-macos-arm64
retention-days: 7
- name: Upload binary (minzoned)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: minzoned-macos-arm64
path: target/release/minzoned-macos-arm64
retention-days: 7

build-libkrun-macos-arm64:
# Build the TRIMMED libkrun.dylib to SHIP in the release, so macOS users
Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ members = [
"crates/minimald",
"crates/minimald-rpc",
"crates/minvmd",
"crates/min-answerer",
"crates/minzoned",
"crates/mlog",
"crates/remote-client",
"crates/remote-proto",
Expand Down
9 changes: 9 additions & 0 deletions crates/minimal/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ pub enum Command {
/// on Ctrl-C, whichever comes first.
#[command(hide = true)]
Spin(SpinArgs),
/// Print the privileged command that installs this host's resolver,
/// local range and box-name service (development aid).
///
/// The command a session start's advisory prints, rendered without a
/// daemon, so the service install can be tested on a host that cannot
/// boot a VM. Debug builds only.
#[cfg(debug_assertions)]
#[command(name = "debug-answerer-command", hide = true)]
DebugAnswererCommand,
/// Print session-identifier completion candidates (used by the shell).
///
/// The completion path a shell actually takes runs in-process (see
Expand Down
8 changes: 8 additions & 0 deletions crates/minimal/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ pub(crate) async fn run_command(cli: Cli) -> Result<(), anyhow::Error> {
// logging may need stdout too.
Some(Command::Version) => cmd_version(&cli.global_args, &mut std::io::stdout()).await,
Some(Command::Spin(args)) => cmd_spin(&cli.global_args, args).await,
#[cfg(debug_assertions)]
Some(Command::DebugAnswererCommand) => {
println!(
"{}",
crate::resolver::answerer_command_for_this_host().await?
);
Ok(())
}
Some(Command::Init(args)) => cmd_init(&cli.global_args, args)
.await
.map_err(|e| anyhow::anyhow!("{e}")),
Expand Down
Loading
Loading