Skip to content

ci: install pkg to user home on runners without passwordless sudo#6142

Merged
Fedr merged 1 commit into
masterfrom
test-distribution-self-hosted-userdir
May 21, 2026
Merged

ci: install pkg to user home on runners without passwordless sudo#6142
Fedr merged 1 commit into
masterfrom
test-distribution-self-hosted-userdir

Conversation

@Fedr
Copy link
Copy Markdown
Contributor

@Fedr Fedr commented May 21, 2026

Summary

Lets test-distribution / macos-test run on runners without passwordless sudo (e.g. our self-hosted macOS fleet) by installing the .pkg into ~/Library via installer -target CurrentUserHomeDirectory instead of sudo installer -target /.

Two coordinated changes:

  • macos/Distribution.xml — adds <domains enable_currentUserHome="true" enable_localSystem="true"/>. macOS rejects -target CurrentUserHomeDirectory by default unless the pkg explicitly opts into the currentUserHome domain. enable_localSystem="true" keeps the existing default system-wide install path, so end users are unaffected and the GUI installer still defaults to /Library.

  • .github/workflows/test-distribution.ymlmacos-test Install Pkg step branches on runner.environment:

    • github-hosted → keeps sudo installer -pkg ... -target / into /Library/Frameworks/... (production install path stays exercised end-to-end).
    • self-hostedinstaller -pkg ... -target CurrentUserHomeDirectory into ~/Library/Frameworks/... (no sudo).
    • The downstream steps (Run MeshViewer, Show meshconv help, brew install -< macos.txt, C/C++ example builds) are made install-location-agnostic by capturing MESHLIB_FW once and putting $MESHLIB_FW/bin on $GITHUB_PATH. CMake's find_package(MeshLib CONFIG REQUIRED) in the examples auto-discovers the framework via CMAKE_SYSTEM_FRAMEWORK_PATH (~/Library/Frameworks is in the macOS default), so no -DCMAKE_PREFIX_PATH= is needed.

Why this came up

PR #6138 expanded the macos-test matrix to include the self-hosted runners macos-arm-build-12 and macos-x64-build, and both failed at "Install Pkg" with sudo: a password is required — the runner service on those hosts runs as a non-admin user, so sudo installer never succeeds. This PR is one of the two follow-ups discussed in #6138's thread (the other is #6141, which pinned CMAKE_OSX_DEPLOYMENT_TARGET=12.7 and is now in master). With both in master, #6138 can be rebased and the full 7-runner matrix should go green.

CI scope

Only macOS distribution testing is affected. Non-mac jobs are disabled via labels. full-ci is set so upload_artifacts is true and test-distribution actually runs from build-test-distribute.yml.

Limitations of this PR's own CI run

Master's current macos-test matrix has only the two GitHub-hosted runners (macos-15-intel, macos-latest). Both take the github-hosted branch of the new if [ "${{ runner.environment }}" = "github-hosted" ], so the new self-hosted branch is not exercised by this PR's own CI. What this PR's run did verify:

  • the new branching, env-var capture, and $GITHUB_PATH plumbing don't break the existing github-hosted path,
  • the <domains> addition to Distribution.xml doesn't break .pkg generation or system-wide installs.

The self-hosted branch is verified once #6138 rebases on top and its matrix expansion lands.

Test plan

Verified in run 26240775524:

  • test-distribution / macos-test (x64, macos-15-intel, *x64.pkg) still passes — .pkg installs to /Library via sudo (the github-hosted code path).
  • test-distribution / macos-test (arm64, macos-latest, *arm.pkg) still passes — same code path.
  • No downstream step regresses on the env-var captured paths (Run MeshViewer, Show meshconv help, examples builds).
  • upload-distributions succeeds — the <domains> addition to Distribution.xml doesn't break productbuild.
  • All 3 macos-build-test variants compile cleanly (x64-Release, arm64-Debug, arm64-Release).
  • Follow-up after merge: rebase ci: widen test-distribution macos-test, rebuild cpr on arm64 only #6138, confirm the self-hosted rows (macos-arm-build-12, macos-x64-build) reach "Install Pkg" without sudo and proceed through MeshViewer / meshconv / examples.

`sudo installer -pkg ... -target /` requires passwordless sudo, which is
the default on GitHub-hosted macOS runners but not on the self-hosted
ones in the MeshInspector fleet, where the runner service runs as a
non-admin user. That made every `test-distribution / macos-test` job
running on a self-hosted runner fail at "Install Pkg" with:

    sudo: a terminal is required to read the password
    sudo: a password is required

Branch on `runner.environment` so:

- GitHub-hosted runners keep the production code path: `sudo installer
  ... -target /` into /Library, matching what end users do.
- Self-hosted runners install via `installer ... -target
  CurrentUserHomeDirectory` (no sudo) into ~/Library.

The capture-once / use-many `MESHLIB_FW` env var keeps the downstream
Run MeshViewer / meshconv / brew install / example-build steps
unaware of which install target was used.

The currentUserHome domain is rejected by default by macOS pkg metadata,
so macos/Distribution.xml opts in via `<domains
enable_currentUserHome="true" enable_localSystem="true"/>`. Production
end users are unaffected -- `enable_localSystem="true"` keeps the
default system-wide /Library install available and the GUI installer
still defaults to it.
@Fedr Fedr merged commit 08f06ae into master May 21, 2026
29 checks passed
@Fedr Fedr deleted the test-distribution-self-hosted-userdir branch May 21, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants