Skip to content

Commit c01316e

Browse files
committed
Support for building gems
1 parent dd0da03 commit c01316e

File tree

16 files changed

+553
-449
lines changed

16 files changed

+553
-449
lines changed

.github/workflows/build-gems.yml

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

.github/workflows/ci.yml

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,25 @@ 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
23-
#
24-
#os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
25-
os: [ubuntu-latest, macos-intel, macos-arm]
22+
os: [ubuntu-latest, macos-latest, windows-latest]
2623
# Earliest and latest supported
2724
rubyVersion: ["3.1", "3.3"]
2825

2926
include:
3027
- os: ubuntu-latest
3128
rubyVersion: "3.3"
3229
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 }}
30+
runs-on: ${{ matrix.os }}
3831
steps:
3932
- name: Checkout repository
4033
uses: actions/checkout@v2
@@ -47,43 +40,34 @@ jobs:
4740
ruby-version: ${{ matrix.rubyVersion }}
4841
bundler-cache: true
4942
cargo-cache: true
50-
51-
- name: Setup Rust cache
52-
uses: Swatinem/rust-cache@v2
53-
with:
54-
workspaces: temporalio/ext -> temporalio/target
43+
working-directory: ./temporalio
5544

5645
# Needed for tests currently
5746
- name: Install Go
5847
uses: actions/setup-go@v5
5948
with:
6049
go-version: stable
6150

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

69-
- name: Lint Rust
70-
if: ${{ matrix.checkTarget }}
71-
working-directory: ./temporalio
72-
run: cargo clippy && cargo fmt --check
73-
7460
- name: Install bundle
7561
working-directory: ./temporalio
7662
run: bundle install
7763

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

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)