Skip to content

Commit

Permalink
Support for building gems
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Oct 17, 2024
1 parent dd0da03 commit 08b616c
Show file tree
Hide file tree
Showing 16 changed files with 552 additions and 449 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/build-gems.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build Gems
on:
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/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.
os: [ubuntu-latest, macos-intel, macos-latest, windows-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
- os: windows-latest
rubyPlatform: x64-mingw-ucrt
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'
44 changes: 14 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,25 @@ 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]
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,43 +40,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 }}

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

0 comments on commit 08b616c

Please sign in to comment.