Skip to content

MUSL support #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025
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
18 changes: 17 additions & 1 deletion .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
# https://github.com/temporalio/sdk-ruby/issues/172
rubyPlatform: ["aarch64-linux", "x86_64-linux", "arm64-darwin", "x86_64-darwin"]
rubyPlatform: ["aarch64-linux", "aarch64-linux-musl", "x86_64-linux", "x86_64-linux-musl", "arm64-darwin", "x86_64-darwin"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -86,6 +86,10 @@ jobs:
# https://github.com/temporalio/sdk-ruby/issues/172
os: [ubuntu-latest, macos-intel, macos-latest]
rubyVersion: ["3.2", "3.3", "3.4"]
# Container defaults to empty/none, but additional container for Alpine
# added later
container: [""]

include:
- os: ubuntu-latest
rubyPlatform: x86_64-linux
Expand All @@ -94,7 +98,12 @@ jobs:
rubyPlatform: x86_64-darwin
- os: macos-latest
rubyPlatform: arm64-darwin
- os: ubuntu-latest
rubyVersion: "3.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

That's saying you will no longer run this for Ruby 3.3 on non-musl. Is this really what you meant?

Copy link
Member Author

@cretz cretz Feb 6, 2025

Choose a reason for hiding this comment

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

This actually adds a new single entry to the matrix due to the field below this one for setting a container different than an existing metric. It does not affect existing ones. See https://github.com/temporalio/sdk-ruby/actions/runs/13185031590. In fact, since we install Ruby a different way for Alpine, technically I could set this to any value because it is not used for this specific matrix entry.

Copy link
Contributor

Choose a reason for hiding this comment

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

due to the field below this one for setting a container different than an existing metric

Oh, right… very subtle. I'd suggest a comment.

container: alpine/git:latest
rubyPlatform: x86_64-linux-musl
runs-on: ${{ matrix.runsOn || matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -107,12 +116,19 @@ jobs:
name: ${{ matrix.rubyPlatform }}-gem
path: local-gem

# This only works on official runners
- name: Setup Ruby
if: ${{ matrix.container == '' }}
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "${{ matrix.rubyVersion }}"
bundler-cache: true
cargo-cache: false

# Works for Alpine
- name: Setup Ruby (Alpine)
if: ${{ matrix.container == 'alpine/git:latest' }}
run: apk add --no-cache ruby ruby-dev ruby-bundler build-base

- name: Run smoke test
run: ruby ./temporalio/smoke_test/smoke_test_gem.rb 'local-gem/*-${{ matrix.rubyPlatform }}.gem'
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
strategy:
fail-fast: false
matrix:
# TODO(cretz): Enable ubuntu-24.04-arm when oxidize-rb/actions/setup-ruby-and-rust
# supports it
# TODO(cretz): Enable ubuntu-24.04-arm when setup-ruby-and-rust supports it, see
# https://github.com/oxidize-rb/actions/issues/53
#
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
# https://github.com/temporalio/sdk-ruby/issues/172
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ gem install temporalio

**NOTE**: Only macOS ARM/x64 and Linux ARM/x64 are supported, and the platform-specific gem chosen is based on when the
gem/bundle install is performed. A source gem is published but cannot be used directly and will fail to build if tried.
MinGW-based Windows and Linux MUSL do not have gems. See the [Platform Support](#platform-support) section for more
information.
MinGW-based Windows is not currently supported. There are caveats with the Google Protobuf dependency on musl-based
Linux. See the [Platform Support](#platform-support) section for more information.

**NOTE**: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
supported on Ruby versions 3.3 and newer.
Expand Down Expand Up @@ -1047,21 +1047,27 @@ This SDK is backed by a Ruby C extension written in Rust leveraging the
[Temporal Rust Core](https://github.com/temporalio/sdk-core). Gems are currently published for the following platforms:

* `aarch64-linux`
* `aarch64-linux-musl`
* `x86_64-linux`
* `x86_64-linux-musl`
* `arm64-darwin`
* `x86_64-darwin`

This means Linux and macOS for ARM and x64 have published gems. Currently, a gem is not published for
`aarch64-linux-musl` so Alpine Linux users may need to build from scratch or use a libc-based distro.
This means Linux and macOS for ARM and x64 have published gems.

Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/172) with Windows and multi-threaded Rust, MinGW-based
Windows (i.e. `x64-mingw-ucrt`) is not supported. But WSL is supported using the normal Linux gem.

Due to [an issue](https://github.com/protocolbuffers/protobuf/issues/16853) with Google Protobuf, latest Linux versions
of Google Protobuf gems will not work in musl-based environments. Instead use the pure "ruby" platform which will build
the Google Protobuf gem on install (e.g.
`gem 'google-protobuf', force_ruby_platform: RUBY_PLATFORM.include?('linux-musl')` in the `Gemfile`).

At this time a pure source gem is published for documentation reasons, but it cannot be built and will fail if tried.
Building from source requires many files across submodules and requires Rust to be installed. See the [Build](#build)
section for how to build a the repository.

The SDK works on Ruby 3.1+, but due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and
The SDK works on Ruby 3.2+, but due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and
`async` gem) are only supported on Ruby versions 3.3 and newer.

## Development
Expand All @@ -1070,7 +1076,7 @@ The SDK works on Ruby 3.1+, but due to [an issue](https://github.com/temporalio/

Prerequisites:

* [Ruby](https://www.ruby-lang.org/) >= 3.1 (i.e. `ruby` and `bundle` on the `PATH`)
* [Ruby](https://www.ruby-lang.org/) >= 3.2 (i.e. `ruby` and `bundle` on the `PATH`)
* [Rust](https://www.rust-lang.org/) latest stable (i.e. `cargo` on the `PATH`)
* This repository, cloned recursively
* Change to the `temporalio/` directory
Expand Down
6 changes: 6 additions & 0 deletions temporalio/smoke_test/smoke_test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
gem_files = Dir.glob(ARGV.first)
raise "Unable to find single gem file, found #{gem_files.length}" unless gem_files.length == 1

# TODO(cretz): For Linux musl, we have to install google-protobuf manually because latest versions do not work with
# musl. Remove this when https://github.com/protocolbuffers/protobuf/issues/16853 is resolved.
if RUBY_PLATFORM.include?('linux-musl')
system('gem', 'install', '--verbose', 'google-protobuf', '--platform', 'ruby', exception: true)
end

system('gem', 'install', '--verbose', gem_files.first, exception: true)

# Create a local environment and start a workflow
Expand Down
Loading