Skip to content
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
88 changes: 88 additions & 0 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build Gems
on:
push:
branches:
- main
- "releases/*"

jobs:
build-gems:
runs-on: ubuntu-latest
strategy:
fail-fast: false
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"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Ruby and Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "3.3"
bundler-cache: true
cargo-cache: true
cargo-vendor: true
working-directory: ./temporalio
cache-version: v1-${{ matrix.rubyPlatform }}

- name: Cross compile gems
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose that it will output files to temporalio/internal/bridge/3.[123]/temporalio_bridge.(extension). Is that exact?

Some comments on what this action will do would be useful to future readers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Not really wanting to re-document what a separate action does here where we use it, but the internal/bridge.rb does have version specific loading

uses: oxidize-rb/actions/cross-gem@v1
id: cross-gem
with:
platform: ${{ matrix.rubyPlatform }}
ruby-versions: "3.1,3.2,3.3"
working-directory: ./temporalio

- name: Upload gems
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.rubyPlatform }}-gem
path: ${{ steps.cross-gem.outputs.gem-path }}

smoke-test-gems:
needs:
- build-gems
strategy:
fail-fast: false
matrix:
# TODO(cretz): Enable Linux ARM. See ci.yaml comment for why we can't right now.
#
# TODO(cretz): Enable windows-latest if we can figure out Windows issue, see
# https://github.com/temporalio/sdk-ruby/issues/172
os: [ubuntu-latest, macos-intel, macos-latest]
rubyVersion: ["3.1", "3.2", "3.3"]
include:
- os: ubuntu-latest
rubyPlatform: x86_64-linux
- os: macos-intel
runsOn: macos-12
rubyPlatform: x86_64-darwin
- os: macos-latest
rubyPlatform: arm64-darwin
runs-on: ${{ matrix.runsOn || matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Download gem
uses: actions/download-artifact@v4
with:
name: ${{ matrix.rubyPlatform }}-gem
path: local-gem

- name: Setup Ruby
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: "${{ matrix.rubyVersion }}"
bundler-cache: true
cargo-cache: false

- name: Run smoke test
run: ruby ./temporalio/smoke_test/smoke_test_gem.rb 'local-gem/*-${{ matrix.rubyPlatform }}.gem'
47 changes: 17 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,31 @@ on:
jobs:
build-lint-test:
strategy:
fail-fast: false
fail-fast: true
matrix:
# TODO(cretz): Enable Windows (it's slow)
#
# TODO(cretz): Enable Linux ARM. It's not natively supported with setup-ruby (see
# https://github.com/ruby/setup-ruby#supported-platforms). So we need to set ruby-version to 'none' per
# https://github.com/ruby/setup-ruby#supported-platforms and https://github.com/ruby/setup-ruby/issues/577).
# So we need to set ruby-version to 'none' per
# https://github.com/oxidize-rb/actions/tree/main/setup-ruby-and-rust and install Ruby ourselves maybe. See
# https://github.com/ruby/setup-ruby?tab=readme-ov-file#using-self-hosted-runners. The error states:
# 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).
# In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build
# You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml
#
#os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
os: [ubuntu-latest, macos-intel, macos-arm]
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
# https://github.com/temporalio/sdk-ruby/issues/172
os: [ubuntu-latest, macos-latest]
# Earliest and latest supported
rubyVersion: ["3.1", "3.3"]

include:
- os: ubuntu-latest
rubyVersion: "3.3"
checkTarget: true
- os: macos-intel
runsOn: macos-12
- os: macos-arm
runsOn: macos-14
runs-on: ${{ matrix.runsOn || matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -47,43 +43,34 @@ jobs:
ruby-version: ${{ matrix.rubyVersion }}
bundler-cache: true
cargo-cache: true

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: temporalio/ext -> temporalio/target
working-directory: ./temporalio

# Needed for tests currently
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: stable

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

Copy link
Contributor

Choose a reason for hiding this comment

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

To other reviewers: this has been moved to temporalio/Rakefile

- name: Lint Rust
if: ${{ matrix.checkTarget }}
working-directory: ./temporalio
run: cargo clippy && cargo fmt --check

- name: Install bundle
working-directory: ./temporalio
run: bundle install

- name: Check generated code unchanged
- name: Check generated protos
if: ${{ matrix.checkTarget }}
working-directory: ./temporalio
run: |
npx doctoc README.md
cd temporalio && bundle exec rake proto:generate
git diff --exit-code
bundle exec rake proto:generate
[[ -z $(git status --porcelain lib/temporalio/api) ]] || (git diff lib/temporalio/api; echo "Protos changed" 1>&2; exit 1)

- name: Lint, compile, test Ruby
working-directory: ./temporalio
run: bundle exec rake TESTOPTS="--verbose"

# TODO(cretz): Build gem and smoke test against separate dir
46 changes: 42 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[Temporal](https://temporal.io/) is a distributed, scalable, durable, and highly available orchestration engine used to
execute asynchronous, long-running business logic in a scalable and resilient way.

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

⚠️ UNDER ACTIVE DEVELOPMENT

Expand Down Expand Up @@ -46,6 +46,7 @@ Notably missing from this SDK:
- [Activity Worker Shutdown](#activity-worker-shutdown)
- [Activity Concurrency and Executors](#activity-concurrency-and-executors)
- [Activity Testing](#activity-testing)
- [Platform Support](#platform-support)
- [Development](#development)
- [Build](#build)
- [Testing](#testing)
Expand All @@ -58,11 +59,26 @@ Notably missing from this SDK:

### Installation

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

**NOTE: Due to [an issue](https://github.com/temporalio/sdk-ruby/issues/162), fibers (and `async` gem) are only
```
gem 'temporalio', '<version>'
```

Or via `gem install` like:

```
gem install temporalio -v '<version>'
```

**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.

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

### Implementing an Activity

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

### Platform Support

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`
* `x86_64-linux`
* `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.

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.

At this time a pure source gem is not published, which means that when trying to install the gem on an unsupported
platform, you may get an error that it is not available. Building from source requires many files across submodules and
requires Rust to be installed. See the [Build](#build) section for how to build a gem from the repository.

The SDK works on Ruby 3.1+, 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

### Build
Expand All @@ -438,7 +477,6 @@ Prerequisites:

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

Expand Down
4 changes: 0 additions & 4 deletions temporalio/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ AllCops:
# Keep cop rule settings in alphabetical order. For each rule setting, provide
# justification for the change from default.

# We want development dependencies in the gemspec
Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec

# We want our classes in a certain order
Layout/ClassStructure:
Enabled: true
Expand Down
Loading
Loading