Skip to content

Add fully functional Ruby client compatible with Go client #157

Add fully functional Ruby client compatible with Go client

Add fully functional Ruby client compatible with Go client #157

Workflow file for this run

name: CI
env:
# Database to connect to that can create other databases with `CREATE DATABASE`.
ADMIN_DATABASE_URL: postgres://postgres:postgres@localhost:5432
# Just a common place for steps to put binaries they need and which is added
# to GITHUB_PATH/PATH.
BIN_PATH: /home/runner/bin
# The version of Ruby that non-spec tasks like the build check or lint run
# against. The setup-ruby step must have a version specified, which is why
# this is necessary.
#
# If updating this value, you probably also want to add a new version to the
# spec version matrix below.
RUBY_VERSION: "4.0"
# A suitable URL for a test database.
TEST_DATABASE_NAME: river_test
TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_test?sslmode=disable
on:
- push
jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 3
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- name: Read upstream River revision
id: river_revision
run: |
ruby -rjson -e '
revision = JSON.parse(File.read("migration/manifest.json")).fetch("revision")
abort "Invalid River revision" unless /\A[0-9a-f]{40}\z/.match?(revision)
File.open(ENV.fetch("GITHUB_OUTPUT"), "a") { |file| file.puts("revision=#{revision}") }
'
- name: Checkout upstream River
uses: actions/checkout@v4
with:
path: upstream/river
persist-credentials: false
ref: ${{ steps.river_revision.outputs.revision }}
repository: riverqueue/river
- name: Verify migrations
run: make verify RIVER_PATH="$GITHUB_WORKSPACE/upstream/river"
gem_build:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ruby + `bundle install`
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build gem (riverqueue-ruby)
run: gem build riverqueue.gemspec
working-directory: .
- name: Build gem (riverqueue-activerecord)
run: gem build riverqueue-activerecord.gemspec
working-directory: ./driver/riverqueue-activerecord
- name: Build gem (riverqueue-sequel)
run: gem build riverqueue-sequel.gemspec
working-directory: ./driver/riverqueue-sequel
- name: Build gem (riverqueue-redis)
run: gem build riverqueue-redis.gemspec
working-directory: ./driver/riverqueue-redis
- name: Build gem (riverqueue-rails)
run: gem build riverqueue-rails.gemspec
working-directory: ./rails/riverqueue-rails
- name: Build gem (riverqueue-pro)
if: ${{ hashFiles('pro/riverqueue-pro/riverqueue-pro.gemspec') != '' }}
run: gem build riverqueue-pro.gemspec
working-directory: ./pro/riverqueue-pro
lint:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ruby + `bundle install`
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Standard Ruby (riverqueue-ruby)
run: bundle exec standardrb
working-directory: .
- name: Frozen string literal comments
run: bundle exec rubocop --config .rubocop-frozen-string-literal.yaml --only Style/FrozenStringLiteralComment
working-directory: .
- name: bundle install (riverqueue-activerecord)
run: bundle install
working-directory: ./driver/riverqueue-activerecord
- name: Standard Ruby (riverqueue-activerecord)
run: bundle exec standardrb
working-directory: ./driver/riverqueue-activerecord
- name: bundle install (riverqueue-sequel)
run: bundle install
working-directory: ./driver/riverqueue-sequel
- name: Standard Ruby (riverqueue-sequel)
run: bundle exec standardrb
working-directory: ./driver/riverqueue-sequel
- name: bundle install (riverqueue-pro)
if: ${{ hashFiles('pro/riverqueue-pro/Gemfile') != '' }}
run: bundle install
working-directory: ./pro/riverqueue-pro
- name: Standard Ruby (riverqueue-pro)
if: ${{ hashFiles('pro/riverqueue-pro/Gemfile') != '' }}
run: bundle exec standardrb
working-directory: ./pro/riverqueue-pro
tool_versions_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check RUBY_VERSION matches .tool-versions Ruby version
run: |
cat <<- "EOF" | ruby
ruby_env = ENV["RUBY_VERSION"] || abort("need RUBY_VERSION")
ruby_tool_versions = File.read('.tool-versions').split('\n')[0].split[1]
if ruby_env != ruby_tool_versions
abort("CI version $RUBY_VERSION ${ruby_env } should match .tool-versions Ruby ${ruby_tool_versions }")
end
EOF
# run: |
# [[ "$RUBY_VERSION" == "$(cat .tool-versions | grep ruby | cut -w -f 2)" ]] || echo "CI version \$RUBY_VERSION should match .tool-versions Ruby `cat .tool-versions | grep ruby | cut -w -f 2`" && (exit 1)
type_check:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ruby + `bundle install`
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Steep (riverqueue-ruby)
run: bundle exec steep check
working-directory: .
spec:
runs-on: ubuntu-latest
timeout-minutes: 3
strategy:
matrix:
# If adding a value, you probably also want to update the default
# RUBY_VERSION for non-spec jobs above.
ruby_version:
- "3.2"
- "3.3"
- "3.4"
- "4.0"
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ruby + `bundle install`
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# Needed for River's CLI. There is a version of Go on Actions' base image,
# but it's old and can't read modern `go.mod` annotations correctly.
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "stable"
check-latest: true
- name: Create database
run: psql --echo-errors --quiet -c '\timing off' -c "CREATE DATABASE ${TEST_DATABASE_NAME};" ${ADMIN_DATABASE_URL}
- name: Install River CLI
run: go install github.com/riverqueue/river/cmd/river@latest
- name: river migrate-up
run: river migrate-up --database-url "$TEST_DATABASE_URL"
- name: Rspec (riverqueue-ruby)
run: bundle exec rspec
working-directory: .
- name: bundle install (riverqueue-activerecord)
run: bundle install
working-directory: ./driver/riverqueue-activerecord
- name: Rspec (riverqueue-activerecord)
run: bundle exec rspec
working-directory: ./driver/riverqueue-activerecord
- name: bundle install (riverqueue-sequel)
run: bundle install
working-directory: ./driver/riverqueue-sequel
- name: Rspec (riverqueue-sequel)
run: bundle exec rspec
working-directory: ./driver/riverqueue-sequel
- name: bundle install (riverqueue-pro)
if: ${{ hashFiles('pro/riverqueue-pro/Gemfile') != '' }}
run: bundle install
working-directory: ./pro/riverqueue-pro
- name: Rspec (riverqueue-pro, SQLite)
if: ${{ hashFiles('pro/riverqueue-pro/Gemfile') != '' }}
run: bundle exec rspec
working-directory: ./pro/riverqueue-pro
redis:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
ruby: ["3.2", "3.3", "3.4", "4.0"]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install Redis
run: sudo apt-get update && sudo apt-get install -y redis-server
- run: bundle install
working-directory: ./driver/riverqueue-redis
- run: bundle exec rspec
working-directory: ./driver/riverqueue-redis
- run: bundle exec standardrb
working-directory: ./driver/riverqueue-redis
rails:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
include:
- rails: "~> 7.2.0"
ruby: "3.2"
- rails: "~> 8.0.0"
ruby: "3.3"
- rails: "~> 8.1.0"
ruby: "4.0"
env:
BUNDLE_FROZEN: "false"
RAILS_VERSION: ${{ matrix.rails }}
RIVER_REQUIRE_DATABASES: "1"
services:
postgres:
image: postgres:17
env:
POSTGRES_DB: river_test
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: bundle install
working-directory: ./rails/riverqueue-rails
- run: bundle exec rspec
working-directory: ./rails/riverqueue-rails
- run: bundle exec standardrb
working-directory: ./rails/riverqueue-rails