Skip to content

Commit

Permalink
Scaffolding and bare-bones client (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz authored Aug 9, 2024
1 parent fd0bfe0 commit 5d17d1d
Show file tree
Hide file tree
Showing 97 changed files with 9,401 additions and 30 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
- "releases/*"

jobs:
build-lint-test:
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]
# 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 }}
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: ${{ matrix.rubyVersion }}
bundler-cache: true
cargo-cache: true

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

# 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
run: cargo clippy && cargo fmt --check

# TODO(cretz): For checkTarget, regen protos and ensure no diff

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

# TODO(cretz): Build gem and smoke test against separate dir
37 changes: 9 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
.bundle/
.yardoc
_yardoc/

/coverage/
/doc/
/examples/vendor/
/pkg/
/spec/reports/
/tmp/

*.gem

# Thermite artefacts
mkmf.log
lib/temporal_sdk_ruby_bridge.*

# rspec failure tracking
.rspec_status

.idea/*

# Rust builds
bridge/target

# Go binaries
spec/support/go_server/main
spec/support/go_worker/main
tmp/
target/
Gemfile.lock
.gem_rbs_collection
*.so
temporalio/test/golangworker/golangworker
temporalio/.yardoc
temporalio/doc
temporalio/pkg
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "temporalio/ext/sdk-core"]
path = temporalio/ext/sdk-core
url = https://github.com/temporalio/sdk-core.git
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
# Temporal Ruby SDK

The Ruby SDK is under active development/refresh.
⚠️ UNDER ACTIVE DEVELOPMENT

The last tag before this refresh is [v0.1.1](https://github.com/temporalio/sdk-ruby/tree/v0.1.1). Please reference that
tag for the previous code.
tag for the previous code.

**TODO: Usage documentation**

## Development

### Build

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

To build shared library for development use:

bundle exec rake compile:dev

To build and test release:

bundle exec rake

### Testing

This project uses `minitest`. To test:

bundle exec rake test

Can add options via `TESTOPTS`. E.g. single test:

bundle exec rake test TESTOPTS="--name=test_start_workflows_async"

### Code Formatting and Type Checking

This project uses `rubocop`:

bundle exec rake rubocop:autocorrect

This project uses `steep`. First may need the RBS collection:

bundle exec rake rbs:install_collection

Now can run `steep`:

bundle exec rake steep

### Proto Generation

Run:

bundle exec rake proto:generate
66 changes: 66 additions & 0 deletions temporalio/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
inherit_mode:
merge:
- Exclude

AllCops:
NewCops: enable
TargetRubyVersion: 3.1
SuggestExtensions: false
Exclude:
- ext/**/*
- lib/temporalio/api/**/*
- target/**/*
- tmp/**/*
- vendor/**/*

# 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

# The default is too small and triggers simply setting lots of values on a proto
Metrics/AbcSize:
Max: 75

# The default is too small
Metrics/BlockLength:
Max: 100

# The default is too small
Metrics/ClassLength:
Max: 400

# The default is too small
Metrics/CyclomaticComplexity:
Max: 25

# The default is too small
Metrics/MethodLength:
Max: 100

# The default is too small
Metrics/PerceivedComplexity:
Max: 25

# We want methods to be documented
Style/DocumentationMethod:
Enabled: true

# Ok to have global vars in tests
Style/GlobalVars:
Exclude:
- test/**/*

# We want our require lists to be in order
Style/RequireOrder:
Enabled: true

# We are ok with large amount of keyword args
Metrics/ParameterLists:
CountKeywordArgs: false
Loading

0 comments on commit 5d17d1d

Please sign in to comment.