Skip to content

Commit

Permalink
GitHub workflow for building gems
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Oct 9, 2024
1 parent 83bea60 commit 2e3b1bd
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 51 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build Gems
on:
pull_request:
push:
branches:
- main
- "releases/*"

jobs:
build-gems:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rubyPlatform: ["aarch64-linux", "x86_64-linux", "arm64-darwin", "x86_64-darwin", "x64-mingw-ucrt"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
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
uses: oxidize-rb/cross-gem-action@v1
with:
platform: ${{ matrix.rubyPlatform }}
ruby-versions: "3.1,3.2,3.3"
working-directory: ./temporalio
27 changes: 3 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,22 @@ jobs:
strategy:
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/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]
os: [ubuntu-latest, macos-latest, windows-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
Expand All @@ -47,25 +39,14 @@ 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
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 }}

- name: Lint Rust
if: ${{ matrix.checkTarget }}
working-directory: ./temporalio
Expand All @@ -85,5 +66,3 @@ jobs:
- name: Lint, compile, test Ruby
working-directory: ./temporalio
run: bundle exec rake TESTOPTS="--verbose"

# TODO(cretz): Build gem and smoke test against separate dir
4 changes: 0 additions & 4 deletions temporalio/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,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
18 changes: 18 additions & 0 deletions temporalio/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,21 @@
source 'https://rubygems.org'

gemspec

group :development do
gem 'activemodel'
gem 'activerecord'
gem 'async'
gem 'base64'
gem 'grpc', '>= 1.65.0.pre2'
gem 'grpc-tools'
gem 'minitest'
gem 'rake'
gem 'rake-compiler'
gem 'rbs', '~> 3.5.3'
gem 'rb_sys', '~> 0.9.63'
gem 'rubocop'
gem 'sqlite3', '~> 1.4'
gem 'steep', '~> 1.7.1'
gem 'yard'
end
11 changes: 10 additions & 1 deletion temporalio/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ task build: :compile
GEMSPEC = Gem::Specification.load('temporalio.gemspec')

RbSys::ExtensionTask.new('temporalio_bridge', GEMSPEC) do |ext|
ext.lib_dir = 'lib/temporalio'
ext.lib_dir = 'lib/temporalio/internal/bridge'
end

require 'rake/testtask'
Expand All @@ -23,6 +23,15 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/**/*_test.rb']
end

def add_protoc_to_path
tools_spec = Gem::Specification.find_by_name('grpc-tools')
cpu = RbConfig::CONFIG['host_cpu']
os = RbConfig::CONFIG['host_os']
ENV['PATH'] = "#{ENV.fetch('PATH', nil)}:#{tools_spec.gem_dir}/bin/#{cpu}-#{os}"
end

add_protoc_to_path

require 'rubocop/rake_task'

RuboCop::RakeTask.new
Expand Down
8 changes: 8 additions & 0 deletions temporalio/lib/temporalio/internal/bridge.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# frozen_string_literal: true

# Use Ruby-version-specific Rust library if present
begin
RUBY_VERSION =~ /(\d+\.\d+)/
require "temporalio/internal/bridge/#{Regexp.last_match(1)}/temporalio_bridge"
rescue LoadError
require 'temporalio/internal/bridge/temporalio_bridge'
end

module Temporalio
module Internal
# @!visibility private
Expand Down
1 change: 0 additions & 1 deletion temporalio/lib/temporalio/internal/bridge/client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'temporalio/internal/bridge'
require 'temporalio/temporalio_bridge'

module Temporalio
module Internal
Expand Down
2 changes: 2 additions & 0 deletions temporalio/lib/temporalio/internal/bridge/runtime.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'temporalio/internal/bridge'

module Temporalio
module Internal
module Bridge
Expand Down
1 change: 0 additions & 1 deletion temporalio/lib/temporalio/internal/bridge/testing.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'temporalio/internal/bridge'
require 'temporalio/temporalio_bridge'

module Temporalio
module Internal
Expand Down
2 changes: 1 addition & 1 deletion temporalio/lib/temporalio/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Temporalio
VERSION = '0.2.0'
VERSION = '0.2.0-alpha1'
end
20 changes: 1 addition & 19 deletions temporalio/temporalio.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/temporalio/sdk-ruby'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.1.0'
spec.required_rubygems_version = '>= 3.3.11'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/temporalio/sdk-ruby'

spec.files = Dir['lib/**/*.rb', 'ext/**/*.*', 'Cargo.lock', 'Cargo.toml', 'Gemfile', 'Rakefile',
'temporalio.gemspec', 'LICENSE', 'README.md']
spec.files = Dir['lib/**/*.rb', 'LICENSE', 'README.md', 'Cargo.*']

spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
Expand All @@ -27,20 +25,4 @@ Gem::Specification.new do |spec|
spec.metadata['rubygems_mfa_required'] = 'true'

spec.add_dependency 'google-protobuf', '>= 3.27.0'

spec.add_development_dependency 'activemodel'
spec.add_development_dependency 'activerecord'
spec.add_development_dependency 'async'
spec.add_development_dependency 'base64'
spec.add_development_dependency 'grpc', '>= 1.65.0.pre2'
spec.add_development_dependency 'grpc-tools'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rake-compiler'
spec.add_development_dependency 'rbs', '~> 3.5.3'
spec.add_development_dependency 'rb_sys', '~> 0.9.63'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'sqlite3', '~> 1.4'
spec.add_development_dependency 'steep', '~> 1.7.1'
spec.add_development_dependency 'yard'
end

0 comments on commit 2e3b1bd

Please sign in to comment.