Skip to content

Commit c32e808

Browse files
authored
MUSL support (#216)
1 parent 880b63c commit c32e808

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

.github/workflows/build-gems.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
1515
# https://github.com/temporalio/sdk-ruby/issues/172
16-
rubyPlatform: ["aarch64-linux", "x86_64-linux", "arm64-darwin", "x86_64-darwin"]
16+
rubyPlatform: ["aarch64-linux", "aarch64-linux-musl", "x86_64-linux", "x86_64-linux-musl", "arm64-darwin", "x86_64-darwin"]
1717
steps:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
@@ -86,6 +86,10 @@ jobs:
8686
# https://github.com/temporalio/sdk-ruby/issues/172
8787
os: [ubuntu-latest, macos-intel, macos-latest]
8888
rubyVersion: ["3.2", "3.3", "3.4"]
89+
# Container defaults to empty/none, but additional container for Alpine
90+
# added later
91+
container: [""]
92+
8993
include:
9094
- os: ubuntu-latest
9195
rubyPlatform: x86_64-linux
@@ -94,7 +98,12 @@ jobs:
9498
rubyPlatform: x86_64-darwin
9599
- os: macos-latest
96100
rubyPlatform: arm64-darwin
101+
- os: ubuntu-latest
102+
rubyVersion: "3.3"
103+
container: alpine/git:latest
104+
rubyPlatform: x86_64-linux-musl
97105
runs-on: ${{ matrix.runsOn || matrix.os }}
106+
container: ${{ matrix.container }}
98107
steps:
99108
- name: Checkout repository
100109
uses: actions/checkout@v4
@@ -107,12 +116,19 @@ jobs:
107116
name: ${{ matrix.rubyPlatform }}-gem
108117
path: local-gem
109118

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

128+
# Works for Alpine
129+
- name: Setup Ruby (Alpine)
130+
if: ${{ matrix.container == 'alpine/git:latest' }}
131+
run: apk add --no-cache ruby ruby-dev ruby-bundler build-base
132+
117133
- name: Run smoke test
118134
run: ruby ./temporalio/smoke_test/smoke_test_gem.rb 'local-gem/*-${{ matrix.rubyPlatform }}.gem'

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
# TODO(cretz): Enable ubuntu-24.04-arm when oxidize-rb/actions/setup-ruby-and-rust
15-
# supports it
14+
# TODO(cretz): Enable ubuntu-24.04-arm when setup-ruby-and-rust supports it, see
15+
# https://github.com/oxidize-rb/actions/issues/53
1616
#
1717
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
1818
# https://github.com/temporalio/sdk-ruby/issues/172

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ gem install temporalio
9898

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

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

10491049
* `aarch64-linux`
1050+
* `aarch64-linux-musl`
10501051
* `x86_64-linux`
1052+
* `x86_64-linux-musl`
10511053
* `arm64-darwin`
10521054
* `x86_64-darwin`
10531055

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

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

1061+
Due to [an issue](https://github.com/protocolbuffers/protobuf/issues/16853) with Google Protobuf, latest Linux versions
1062+
of Google Protobuf gems will not work in musl-based environments. Instead use the pure "ruby" platform which will build
1063+
the Google Protobuf gem on install (e.g.
1064+
`gem 'google-protobuf', force_ruby_platform: RUBY_PLATFORM.include?('linux-musl')` in the `Gemfile`).
1065+
10601066
At this time a pure source gem is published for documentation reasons, but it cannot be built and will fail if tried.
10611067
Building from source requires many files across submodules and requires Rust to be installed. See the [Build](#build)
10621068
section for how to build a the repository.
10631069

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

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

10711077
Prerequisites:
10721078

1073-
* [Ruby](https://www.ruby-lang.org/) >= 3.1 (i.e. `ruby` and `bundle` on the `PATH`)
1079+
* [Ruby](https://www.ruby-lang.org/) >= 3.2 (i.e. `ruby` and `bundle` on the `PATH`)
10741080
* [Rust](https://www.rust-lang.org/) latest stable (i.e. `cargo` on the `PATH`)
10751081
* This repository, cloned recursively
10761082
* Change to the `temporalio/` directory

temporalio/smoke_test/smoke_test_gem.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
gem_files = Dir.glob(ARGV.first)
66
raise "Unable to find single gem file, found #{gem_files.length}" unless gem_files.length == 1
77

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

1016
# Create a local environment and start a workflow

0 commit comments

Comments
 (0)