Skip to content

Commit f49e5a3

Browse files
authored
Support for building gems and prepare release (#171)
1 parent dd0da03 commit f49e5a3

File tree

17 files changed

+607
-453
lines changed

17 files changed

+607
-453
lines changed

.github/workflows/build-gems.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build Gems
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- "releases/*"
7+
8+
jobs:
9+
build-gems:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
15+
# https://github.com/temporalio/sdk-ruby/issues/172
16+
rubyPlatform: ["aarch64-linux", "x86_64-linux", "arm64-darwin", "x86_64-darwin"]
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Setup Ruby and Rust
24+
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
25+
with:
26+
ruby-version: "3.3"
27+
bundler-cache: true
28+
cargo-cache: true
29+
cargo-vendor: true
30+
working-directory: ./temporalio
31+
cache-version: v1-${{ matrix.rubyPlatform }}
32+
33+
- name: Cross compile gems
34+
uses: oxidize-rb/actions/cross-gem@v1
35+
id: cross-gem
36+
with:
37+
platform: ${{ matrix.rubyPlatform }}
38+
ruby-versions: "3.1,3.2,3.3"
39+
working-directory: ./temporalio
40+
41+
- name: Upload gems
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: ${{ matrix.rubyPlatform }}-gem
45+
path: ${{ steps.cross-gem.outputs.gem-path }}
46+
47+
smoke-test-gems:
48+
needs:
49+
- build-gems
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
# TODO(cretz): Enable Linux ARM. See ci.yaml comment for why we can't right now.
54+
#
55+
# TODO(cretz): Enable windows-latest if we can figure out Windows issue, see
56+
# https://github.com/temporalio/sdk-ruby/issues/172
57+
os: [ubuntu-latest, macos-intel, macos-latest]
58+
rubyVersion: ["3.1", "3.2", "3.3"]
59+
include:
60+
- os: ubuntu-latest
61+
rubyPlatform: x86_64-linux
62+
- os: macos-intel
63+
runsOn: macos-12
64+
rubyPlatform: x86_64-darwin
65+
- os: macos-latest
66+
rubyPlatform: arm64-darwin
67+
runs-on: ${{ matrix.runsOn || matrix.os }}
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
with:
72+
submodules: recursive
73+
74+
- name: Download gem
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: ${{ matrix.rubyPlatform }}-gem
78+
path: local-gem
79+
80+
- name: Setup Ruby
81+
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
82+
with:
83+
ruby-version: "${{ matrix.rubyVersion }}"
84+
bundler-cache: true
85+
cargo-cache: false
86+
87+
- name: Run smoke test
88+
run: ruby ./temporalio/smoke_test/smoke_test_gem.rb 'local-gem/*-${{ matrix.rubyPlatform }}.gem'

.github/workflows/ci.yml

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,31 @@ on:
99
jobs:
1010
build-lint-test:
1111
strategy:
12-
fail-fast: false
12+
fail-fast: true
1313
matrix:
14-
# TODO(cretz): Enable Windows (it's slow)
15-
#
1614
# TODO(cretz): Enable Linux ARM. It's not natively supported with setup-ruby (see
17-
# https://github.com/ruby/setup-ruby#supported-platforms). So we need to set ruby-version to 'none' per
15+
# https://github.com/ruby/setup-ruby#supported-platforms and https://github.com/ruby/setup-ruby/issues/577).
16+
# So we need to set ruby-version to 'none' per
1817
# https://github.com/oxidize-rb/actions/tree/main/setup-ruby-and-rust and install Ruby ourselves maybe. See
1918
# https://github.com/ruby/setup-ruby?tab=readme-ov-file#using-self-hosted-runners. The error states:
2019
# Error: The current runner (ubuntu-24.04-arm64) was detected as self-hosted because the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported).
2120
# In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build
2221
# You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml
2322
#
24-
#os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
25-
os: [ubuntu-latest, macos-intel, macos-arm]
23+
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
24+
# https://github.com/temporalio/sdk-ruby/issues/172
25+
os: [ubuntu-latest, macos-latest]
2626
# Earliest and latest supported
2727
rubyVersion: ["3.1", "3.3"]
2828

2929
include:
3030
- os: ubuntu-latest
3131
rubyVersion: "3.3"
3232
checkTarget: true
33-
- os: macos-intel
34-
runsOn: macos-12
35-
- os: macos-arm
36-
runsOn: macos-14
37-
runs-on: ${{ matrix.runsOn || matrix.os }}
33+
runs-on: ${{ matrix.os }}
3834
steps:
3935
- name: Checkout repository
40-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
4137
with:
4238
submodules: recursive
4339

@@ -47,43 +43,34 @@ jobs:
4743
ruby-version: ${{ matrix.rubyVersion }}
4844
bundler-cache: true
4945
cargo-cache: true
50-
51-
- name: Setup Rust cache
52-
uses: Swatinem/rust-cache@v2
53-
with:
54-
workspaces: temporalio/ext -> temporalio/target
46+
working-directory: ./temporalio
5547

5648
# Needed for tests currently
5749
- name: Install Go
5850
uses: actions/setup-go@v5
5951
with:
6052
go-version: stable
6153

62-
- name: Install protoc
54+
# Needed because gRPC tools does not have a macOS protoc binary
55+
# currently, see https://github.com/grpc/grpc/issues/25755
56+
- name: Install protoc for mac
57+
if: ${{ matrix.os == 'macos-latest' }}
6358
uses: arduino/setup-protoc@v3
6459
with:
65-
# TODO(cretz): Can upgrade proto when https://github.com/arduino/setup-protoc/issues/99 fixed
6660
version: "23.x"
6761
repo-token: ${{ secrets.GITHUB_TOKEN }}
6862

69-
- name: Lint Rust
70-
if: ${{ matrix.checkTarget }}
71-
working-directory: ./temporalio
72-
run: cargo clippy && cargo fmt --check
73-
7463
- name: Install bundle
7564
working-directory: ./temporalio
7665
run: bundle install
7766

78-
- name: Check generated code unchanged
67+
- name: Check generated protos
7968
if: ${{ matrix.checkTarget }}
69+
working-directory: ./temporalio
8070
run: |
81-
npx doctoc README.md
82-
cd temporalio && bundle exec rake proto:generate
83-
git diff --exit-code
71+
bundle exec rake proto:generate
72+
[[ -z $(git status --porcelain lib/temporalio/api) ]] || (git diff lib/temporalio/api; echo "Protos changed" 1>&2; exit 1)
8473
8574
- name: Lint, compile, test Ruby
8675
working-directory: ./temporalio
8776
run: bundle exec rake TESTOPTS="--verbose"
88-
89-
# TODO(cretz): Build gem and smoke test against separate dir

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available orchestration engine used to
88
execute asynchronous, long-running business logic in a scalable and resilient way.
99

10-
"Temporal Ruby SDK" is the framework for authoring workflows and activities using the Ruby programming language.
10+
**Temporal Ruby SDK** is the framework for authoring workflows and activities using the Ruby programming language.
1111

1212
⚠️ UNDER ACTIVE DEVELOPMENT
1313

@@ -46,6 +46,7 @@ Notably missing from this SDK:
4646
- [Activity Worker Shutdown](#activity-worker-shutdown)
4747
- [Activity Concurrency and Executors](#activity-concurrency-and-executors)
4848
- [Activity Testing](#activity-testing)
49+
- [Platform Support](#platform-support)
4950
- [Development](#development)
5051
- [Build](#build)
5152
- [Testing](#testing)
@@ -58,11 +59,26 @@ Notably missing from this SDK:
5859

5960
### Installation
6061

61-
⚠️ PENDING GEM PUBLISH
62+
Install the gem to the desired version as mentioned at https://rubygems.org/gems/temporalio. Since the SDK is still in
63+
pre-release, the version should be specified explicitly. So either in a Gemfile like:
6264

63-
**NOTE: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
65+
```
66+
gem 'temporalio', '<version>'
67+
```
68+
69+
Or via `gem install` like:
70+
71+
```
72+
gem install temporalio -v '<version>'
73+
```
74+
75+
**NOTE**: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
6476
supported on Ruby versions 3.3 and newer.
6577

78+
**NOTE**: MinGW-based Windows is not currently supported natively, but is via WSL. Prebuilt gems for Linux MUSL are also
79+
not currently present. We also do not publish a gem for building from source at this time. See the
80+
[Platform Support](#platform-support) section later for more information.
81+
6682
### Implementing an Activity
6783

6884
Implementing workflows is not yet supported in the Ruby SDK, but implementing activities is.
@@ -430,6 +446,29 @@ it will raise the error raised in the activity.
430446
The constructor of the environment has multiple keyword arguments that can be set to affect the activity context for the
431447
activity.
432448

449+
### Platform Support
450+
451+
This SDK is backed by a Ruby C extension written in Rust leveraging the
452+
[Temporal Rust Core](https://github.com/temporalio/sdk-core). Gems are currently published for the following platforms:
453+
454+
* `aarch64-linux`
455+
* `x86_64-linux`
456+
* `arm64-darwin`
457+
* `x86_64-darwin`
458+
459+
This means Linux and macOS for ARM and x64 have published gems. Currently, a gem is not published for
460+
`aarch64-linux-musl` so Alpine Linux users may need to build from scratch or use a libc-based distro.
461+
462+
Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/172) with Windows and multi-threaded Rust, MinGW-based
463+
Windows (i.e. `x64-mingw-ucrt`) is not supported. But WSL is supported using the normal Linux gem.
464+
465+
At this time a pure source gem is not published, which means that when trying to install the gem on an unsupported
466+
platform, you may get an error that it is not available. Building from source requires many files across submodules and
467+
requires Rust to be installed. See the [Build](#build) section for how to build a gem from the repository.
468+
469+
The SDK works on Ruby 3.1+, but due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and
470+
`async` gem) are only supported on Ruby versions 3.3 and newer.
471+
433472
## Development
434473

435474
### Build
@@ -438,7 +477,6 @@ Prerequisites:
438477

439478
* [Ruby](https://www.ruby-lang.org/) >= 3.1 (i.e. `ruby` and `bundle` on the `PATH`)
440479
* [Rust](https://www.rust-lang.org/) latest stable (i.e. `cargo` on the `PATH`)
441-
* [Protobuf Compiler](https://protobuf.dev/) (i.e. `protoc` on the `PATH`)
442480
* This repository, cloned recursively
443481
* Change to the `temporalio/` directory
444482

temporalio/.rubocop.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ AllCops:
1717
# Keep cop rule settings in alphabetical order. For each rule setting, provide
1818
# justification for the change from default.
1919

20-
# We want development dependencies in the gemspec
21-
Gemspec/DevelopmentDependencies:
22-
EnforcedStyle: gemspec
23-
2420
# We want our classes in a certain order
2521
Layout/ClassStructure:
2622
Enabled: true

0 commit comments

Comments
 (0)