Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/conformance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ jobs:

- name: Java fixture tests
run: make test/java/conformance

- uses: ruby/setup-ruby@v1
with:
working-directory: ruby
bundler-cache: true

- name: Ruby fixture tests
run: make test/ruby/conformance
209 changes: 209 additions & 0 deletions .github/workflows/ruby.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
name: Ruby

# Filter the workflow so unrelated changes create no skipped matrix jobs.
# Keep both events' paths in sync.
on:
push:
branches: [master]
paths:
- ".github/workflows/ruby.yaml"
- "Makefile"
- "conformance/**"
- "riverdriver/**/*.sql"
- "ruby/**"
tags: ["riverqueue-ruby-v*"]
pull_request:
paths:
- ".github/workflows/ruby.yaml"
- "Makefile"
- "conformance/**"
- "riverdriver/**/*.sql"
- "ruby/**"

concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
group: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read

defaults:
run:
working-directory: ruby

jobs:
checks:
# Check coverage from the two backends without adding another CI job.
needs: [test, test_sqlite]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
working-directory: ruby
bundler-cache: true
- run: bundle exec standardrb
- run: make frozen-string-literals type-check verify build
- uses: actions/download-artifact@v8
with:
pattern: ruby-coverage-*
path: ruby/coverage/ci
- run: bundle exec ruby scripts/check_coverage.rb

test:
name: test (${{ matrix.ruby }}, ${{ matrix.postgres }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
# Latest Ruby against all supported PostgreSQL versions.
- ruby: "4.0"
postgres: 18
primary: true
- ruby: "4.0"
postgres: 17
- ruby: "4.0"
postgres: 16
- ruby: "4.0"
postgres: 15
- ruby: "4.0"
postgres: 14

# Older Ruby versions against the latest PostgreSQL only.
- ruby: "3.4"
postgres: 18
- ruby: "3.3"
postgres: 18
- ruby: "3.2"
postgres: 18
env:
RIVER_REQUIRE_DATABASES: "1"
TEST_DATABASE: postgres
TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_test?sslmode=disable
services:
postgres:
image: postgres:${{ matrix.postgres }}
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@v7
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
working-directory: ruby
bundler-cache: true
- uses: actions/setup-go@v7
with:
go-version-file: go.work
- run: make generate/fixtures
- run: make spec/core
- run: bundle install
working-directory: ruby/driver/riverqueue-activerecord
- run: make spec/activerecord
- run: bundle install
working-directory: ruby/driver/riverqueue-sequel
- run: make spec/sequel
- uses: actions/upload-artifact@v7
if: matrix.primary
with:
name: ruby-coverage-postgres
path: ruby/**/coverage/.resultset.json
include-hidden-files: true
if-no-files-found: error
retention-days: 1

test_sqlite:
name: test_sqlite (4.0)
runs-on: ubuntu-latest
timeout-minutes: 10
env:
RIVER_REQUIRE_DATABASES: "1"
TEST_DATABASE: sqlite
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0"
working-directory: ruby
bundler-cache: true
- uses: actions/setup-go@v7
with:
go-version-file: go.work
- run: make generate/fixtures
- run: make spec/core
- run: bundle install
working-directory: ruby/driver/riverqueue-activerecord
- run: make spec/activerecord
- run: bundle install
working-directory: ruby/driver/riverqueue-sequel
- run: make spec/sequel
- uses: actions/upload-artifact@v7
with:
name: ruby-coverage-sqlite
path: ruby/**/coverage/.resultset.json
include-hidden-files: true
if-no-files-found: error
retention-days: 1

rails:
name: rails (4.0)
runs-on: ubuntu-latest
timeout-minutes: 10
env:
BUNDLE_FROZEN: "false"
RIVER_REQUIRE_DATABASES: "1"
TEST_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/river_test?sslmode=disable
services:
postgres:
image: postgres:18
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"]
defaults:
run:
working-directory: ruby/rails/riverqueue-rails
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0"
working-directory: ruby/rails/riverqueue-rails
# Reuse the runner, PostgreSQL service, and installed gems across versions.
- name: Test Rails 7.2
env:
RAILS_VERSION: "~> 7.2.0"
run: bundle install && bundle exec rspec
- name: Test Rails 8.0
if: success() || failure()
env:
RAILS_VERSION: "~> 8.0.0"
run: bundle install && bundle exec rspec
- name: Test Rails 8.1
if: success() || failure()
env:
RAILS_VERSION: "~> 8.1.0"
run: bundle install && bundle exec rspec
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ generate: generate/fixtures
generate: generate/java-migrations
generate: generate/js-migrations
generate: generate/migrations
generate: generate/ruby-migrations
generate: generate/rust-migrations
generate: generate/sqlc

Expand Down Expand Up @@ -363,6 +364,7 @@ verify: ## Verify generated artifacts
verify: verify/java-migrations
verify: verify/js-migrations
verify: verify/migrations
verify: verify/ruby-migrations
verify: verify/rust-migrations
verify: verify/sqlc

Expand All @@ -387,3 +389,28 @@ verify/sqlc: ## Verify generated sqlc
cd riverdriver/riverdatabasesql/internal/dbsqlc && $(SQLC) diff
cd riverdriver/riverpgxv5/internal/dbsqlc && $(SQLC) diff
cd riverdriver/riversqlite/internal/dbsqlc && $(SQLC) diff

# Ruby targets are separate from Go's default targets. Install gems with
# `make -C ruby install` first.
.PHONY: build/ruby lint/ruby test/ruby test/ruby/conformance typecheck/ruby
build/ruby: ## Build the Ruby gems without publishing
$(MAKE) -C ruby build

lint/ruby: ## Run Ruby style checks
$(MAKE) -C ruby lint

test/ruby: ## Run Ruby core, Active Record, Sequel, and Rails tests
$(MAKE) -C ruby test

test/ruby/conformance: ## Run Ruby tests that check Go-generated conformance fixtures
$(MAKE) -C ruby test/conformance

typecheck/ruby: ## Check Ruby types with Steep
$(MAKE) -C ruby type-check

.PHONY: generate/ruby-migrations verify/ruby-migrations
generate/ruby-migrations: ## Sync database migrations to Ruby
ruby ruby/scripts/sync_migrations.rb

verify/ruby-migrations: ## Verify Ruby migrations match the canonical migrations
ruby ruby/scripts/sync_migrations.rb --check
4 changes: 2 additions & 2 deletions conformance/cmd/checkmodzip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const conformanceModulePath = "github.com/riverqueue/river/conformance"

// disallowedPathPattern matches paths, relative to a module's root, that must
// never be published: fixture and testdata directories, JSON files, and the
// conformance, Java, JavaScript, and Rust trees.
var disallowedPathPattern = regexp.MustCompile(`(^|/)(fixtures?|testdata)/|\.json$|^(conformance|java|js|rust)/`)
// conformance, Java, JavaScript, Ruby, and Rust trees.
var disallowedPathPattern = regexp.MustCompile(`(^|/)(fixtures?|testdata)/|\.json$|^(conformance|java|js|ruby|rust)/`)

func main() {
if len(os.Args) != 2 {
Expand Down
3 changes: 3 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# River development

The [Ruby](../ruby/), [Rust](../rust/), and [JavaScript](../js/) ports have
separate development instructions and `make test/<language>` targets.

## Run tests

Raise the test database:
Expand Down
5 changes: 5 additions & 0 deletions ruby/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
*.gem
coverage/
.bundle/
vendor/bundle/
10 changes: 10 additions & 0 deletions ruby/.rubocop-frozen-string-literal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AllCops:
NewCops: disable
Exclude:
- ".ruby-lsp/**/*"
- "**/coverage/**/*"
- "**/vendor/**/*"

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
1 change: 1 addition & 0 deletions ruby/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 4.0
Loading
Loading