Skip to content

Build and export native macOS ARM64 (darwin-arm64) OpenStudio-server tarball in CI - #885

Open
anchapin wants to merge 3 commits into
developfrom
issue-884-darwin-arm64
Open

anchapin wants to merge 3 commits into
developfrom
issue-884-darwin-arm64

Conversation

@anchapin

@anchapin anchapin commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses #884 and unblocks NatLabRockies/OpenStudio-PAT#311 by building, verifying, and exporting a native macOS ARM64 (darwin-arm64) OpenStudio-server-<sha>-darwin-arm64.tar.gz tarball in CI alongside the Intel (darwin) tarball.

Changes

  • .github/workflows/openstudio-server-tests.yml:
    • Adds macos-arm64-test on macos-15 (uploading artifact openstudio-server-gems-darwin-arm64) alongside macos-test on macos-15-intel (openstudio-server-gems-darwin).
  • ci/github-actions/setup.sh:
    • Detects uname -m (arm64 vs x86_64) on macos15 to install matching portable Ruby (ruby-3.2.2-darwin-arm64.tar.gz vs ruby-3.2.2-darwin.tar.gz), MongoDB (mongodb-macos-arm64-8.0.12.tgz extracting to mongodb-macos-aarch64-8.0.12), and OpenStudio (Darwin-arm64 vs Darwin-x86_64) packages, and ensures /usr/local/bin exists.
    • Repairs portable /usr/local/ruby on both arm64 and x86_64 so all native gem extensions (psych, puma, bigdecimal, bson, nio4r, sassc, msgpack, racc, websocket-driver, etc.) compile cleanly and link statically without /opt/homebrew or /usr/local/opt dylib references:
      1. Stages static archives (*.a) and headers for gmp, libyaml, and openssl@3 into /usr/local/ruby/{lib,include}.
      2. Replaces extinit.o and encinit.o in libruby.3.2-static.a (present on arm64) with dummy Init_ext/Init_enc symbols so mkmf try_link0 checks against -lruby.3.2-static succeed.
      3. Sanitizes Conan and Homebrew (/usr/local/opt/{openssl@3,libyaml,gmp}) build-runner paths in rbconfig.rb and adds --without-pkg-config so mkmf does not crash on nil ENV["PKG_CONFIG_PATH"] or pull in Homebrew dylib search paths.
      4. Restores autoload declarations in rubygems.rb when eager require 'rubygems/...' lines are present so the securerandom default gem is not pre-activated before Gem::Specification.load_defaults and Bundler.setup.
  • ci/github-actions/test.sh & ci/github-actions/export_build_osx.sh:
    • Uses uname -m to select Darwin-arm64 vs Darwin-x86_64 and -darwin-arm64.tar.gz vs -darwin.tar.gz.
    • Adds post-export tarball verification in export_build_osx.sh matching NatLabRockies/OpenStudio-PAT#311 (verify_server_deps.yaml), rejecting any /opt/homebrew, /usr/local/, /Users/, or /private/ dylib dependency.
  • bin/openstudio_meta:
    • Emits OpenStudio-server-<sha>-darwin-arm64.tar.gz when RUBY_PLATFORM matches darwin + arm64/aarch64.
    • Sets COPYFILE_DISABLE=1 on macOS before running tar so AppleDouble ._* metadata files are never included.
    • Skips top-level build and *.tar.gz/*.tgz entries when staging OpenStudio-server/.

Fixes #884

- Add `macos-arm64-test` job on `macos-15` alongside `macos-test` on
  `macos-15-intel` in `.github/workflows/openstudio-server-tests.yml`,
  uploading the `openstudio-server-gems-darwin-arm64` artifact.
- Update `ci/github-actions/setup.sh`, `ci/github-actions/test.sh`, and
  `ci/github-actions/export_build_osx.sh` to detect `uname -m` (`arm64`
  vs `x86_64`) and select matching portable Ruby, MongoDB, and
  OpenStudio tarballs.
- Fix up portable `/usr/local/ruby` on `arm64` in `setup.sh` so native
  gem extensions compile cleanly and link statically against `gmp`,
  `libyaml`, and `openssl@3` without embedding `/opt/homebrew` dylibs,
  replace `extinit.o`/`encinit.o` in `libruby.3.2-static.a` with dummy
  `Init_ext`/`Init_enc` symbols, sanitize Conan runner paths in
  `rbconfig.rb`, and restore `autoload` declarations in `rubygems.rb`.
- Update `bin/openstudio_meta` to emit `-darwin-arm64.tar.gz` on ARM64
  macOS, set `COPYFILE_DISABLE=1` to prevent AppleDouble `._*` files,
  and exclude `build` and `*.tar.gz`/`*.tgz` from the staged archive.
- Add post-export tarball verification in `export_build_osx.sh` checking
  required files/directories, absence of `._*` and nested archives,
  native `.bundle` Mach-O architecture, and portable dylib linkage.

Fixes #884

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Native Ruby archive modifications and portability require macOS validation with PAT’s bundled runtime, beyond resolving the retained issues.

2 open findings
What changed in this PR

Adds native macOS ARM64 server packaging alongside Intel builds for PAT’s Apple Silicon support.

Changes:

  • Adds an ARM64 CI job and architecture-specific dependency selection.
  • Repairs portable ARM64 Ruby for native gem compilation.
  • Updates archive naming, cleanup, and portability verification.
File Description
ci/​github-actions/​test.sh Selects architecture-specific OpenStudio paths.
ci/​github-actions/​setup.sh Installs matching dependencies and repairs ARM64 Ruby.
ci/​github-actions/​export_build_osx.sh Exports and verifies architecture-specific archives.
bin/​openstudio_meta Names ARM64 archives and excludes build artifacts and metadata.
.github/​workflows/​openstudio-server-tests.yml Adds ARM64 testing and artifact upload.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ci/github-actions/setup.sh Outdated
fi
sudo cp mongodb-macos-x86_64-8.0.12/bin/* /usr/local/bin/
sudo mkdir -p /usr/local/bin
sudo cp "${MONGO_ARCHIVE}"/bin/* /usr/local/bin/
Comment thread ci/github-actions/export_build_osx.sh Outdated
…libyaml linking

- Use MONGO_EXTRACT_DIR=mongodb-macos-aarch64-8.0.12 when extracting
  mongodb-macos-arm64-8.0.12.tgz on macOS ARM64.
- Stage static gmp, libyaml, and openssl@3 archives/headers into
  /usr/local/ruby and sanitize /usr/local/opt/{openssl@3,libyaml,gmp}
  in rbconfig.rb on both x86_64 and arm64 so Intel puma_http11.bundle
  links statically instead of referencing /usr/local/opt/openssl@3.
- Reject any /usr/local/ dylib path in export_build_osx.sh portability
  check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On x86_64 portable Ruby (ruby-3.2.2-darwin.tar.gz), rubygems.rb already
uses autoload :DependencyList, File.expand_path(...), whereas the arm64
Conan Ruby replaced them with eager require 'rubygems/...' lines. Guard
the replacement with rg_content.include?(old_line) so both tarballs
succeed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Build and export native macOS ARM64 (darwin-arm64) OpenStudio-server tarball in CI for OpenStudio-PAT

2 participants