Skip to content

Commit

Permalink
Merge pull request #93 from sarub0b0/appraisal
Browse files Browse the repository at this point in the history
Enable testing across various ruby (2.6-3.1) and rails (6.0-7.1) versions using appraisal
  • Loading branch information
sarub0b0 authored Jul 30, 2024
2 parents 45b7beb + 293036f commit 6141d69
Show file tree
Hide file tree
Showing 27 changed files with 408 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Dockerfile
README.md
.gitignore
.git
Gemfile.lock
gemfiles/*.lock

50 changes: 47 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
name: test
on:
push:
branches:
- main
pull_request:

jobs:
test:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- ruby: "2.6"
gemfile: ruby_26.rails_60.gemfile
- ruby: "2.6"
gemfile: ruby_26.rails_61.gemfile
- ruby: "2.7"
gemfile: ruby_27.rails_60.gemfile
- ruby: "2.7"
gemfile: ruby_27.rails_61.gemfile
- ruby: "2.7"
gemfile: ruby_27.rails_70.gemfile
- ruby: "2.7"
gemfile: ruby_27.rails_71.gemfile
- ruby: "3.0"
gemfile: ruby_30.rails_61.gemfile
- ruby: "3.0"
gemfile: ruby_30.rails_70.gemfile
- ruby: "3.0"
gemfile: ruby_30.rails_71.gemfile
- ruby: "3.1"
gemfile: ruby_31.rails_61.gemfile
- ruby: "3.1"
gemfile: ruby_31.rails_70.gemfile
- ruby: "3.1"
gemfile: ruby_31.rails_71.gemfile
services:
mysql:
image: mysql:8.4
Expand All @@ -17,13 +47,13 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
PUBSUB_TOPIC_ID: trabox
PUBSUB_SUBSCRIPTION_ID: trabox-sub
PUBSUB_EMULATOR_HOST: localhost:8085
GOOGLE_CLOUD_PROJECT: trabox
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand All @@ -36,7 +66,7 @@ jobs:
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Set up database
Expand All @@ -49,3 +79,17 @@ jobs:
gcloud beta emulators pubsub start --host-port=localhost:8085 --quiet &
curl http://localhost:8085 --silent --retry 30 --retry-delay 1 --retry-connrefused
bin/rspec
conclusion:
needs: tests
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Check tests result
run: |
if [[ ${{ needs.tests.result }} == 'success' ]]; then
echo "All tests passed!"
else
echo "Some tests failed!"
exit 1
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ bin/trabox*
!/**/.keep

*.gem

gemfiles/*.lock
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration

AllCops:
TargetRubyVersion: 2.6
83 changes: 83 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ruby 2.6
appraise 'ruby-26.rails-60' do
ruby '~> 2.6.0'
gem 'rails', '~> 6.0.0'
gem 'rspec-rails', '~> 5.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-protobuf', '< 3.24.0'
end

appraise 'ruby-26.rails-61' do
ruby '~> 2.6.0'
gem 'rails', '~> 6.1.0'
gem 'rspec-rails', '~> 5.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-protobuf', '< 3.24.0'
end

# ruby 2.7
appraise 'ruby-27.rails-60' do
ruby '~> 2.7.0'
gem 'rails', '~> 6.0.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-cloud-pubsub', '~> 2.13.0'
gem 'google-protobuf', '~> 3.24.0'
end

appraise 'ruby-27.rails-61' do
ruby '~> 2.7.0'
gem 'rails', '~> 6.0.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-cloud-pubsub', '~> 2.13.0'
gem 'google-protobuf', '~> 3.24.0'
end

appraise 'ruby-27.rails-70' do
ruby '~> 2.7.0'
gem 'rails', '~> 7.0.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-cloud-pubsub', '~> 2.13.0'
gem 'google-protobuf', '~> 3.24.0'
end

appraise 'ruby-27.rails-71' do
ruby '~> 2.7.0'
gem 'rails', '~> 7.1.0'
gem 'factory_bot', '~> 6.2.0'
gem 'google-cloud-pubsub', '~> 2.13.0'
gem 'google-protobuf', '~> 3.24.0'
end

# ruby 3.0
appraise 'ruby-30.rails-61' do
ruby '~> 3.0.0'
gem 'rails', '~> 6.0.0'
end

appraise 'ruby-30.rails-70' do
ruby '~> 3.0.0'
gem 'rails', '~> 7.0.0'
end

appraise 'ruby-30.rails-71' do
ruby '~> 3.0.0'
gem 'rails', '~> 7.1.0'
end

# ruby 3.1
appraise 'ruby-31.rails-61' do
ruby '~> 3.1.0'
gem 'rails', '~> 6.1.0'
end

appraise 'ruby-31.rails-70' do
ruby '~> 3.1.0'
gem 'rails', '~> 7.0.0'
end

appraise 'ruby-31.rails-71' do
ruby '~> 3.1.0'
gem 'rails', '~> 7.1.0'
end

# vim:ft=ruby:
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM ruby:3
ARG RUBY_VERSION=3.1

FROM ruby:${RUBY_VERSION}

WORKDIR /app

Expand Down
20 changes: 15 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ gemspec
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
gem 'ammeter', '~> 1.1'

gem 'byebug'
gem 'database_cleaner-active_record', '~> 2.0'
gem 'factory_bot', '~> 6.2'
gem 'pry-byebug', '~> 3.10'
gem 'rspec-rails', '~> 6.0'
gem 'factory_bot'
gem 'rspec-rails'

# dev tools
gem 'rubocop', '~> 1.38'
gem 'ruby-lsp', '~> 0.17.0'

gem 'pry-byebug'
gem 'rubocop'
gem 'ruby-lsp'

if RUBY_VERSION >= '3.0.0'
gem 'google-protobuf'
elsif RUBY_VERSION >= '2.7.0'
gem 'google-protobuf', '~> 3.24.0'
else
gem 'google-protobuf', '< 3.24.0'
end
5 changes: 5 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Transactional-Outbox for Rails.

- Google Cloud Pub/Sub

## 必要条件

- Ruby 2.6+
- Rails 6.0+

## インストール

`Gemfile`に下記を追記
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Transactional-Outbox for Rails.

- Google Cloud Pub/Sub

## Requirements

- Ruby 2.6+
- Rails 6.0+

## Installation

Add this line to your application's Gemfile:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ services:
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- '3306:3306'
- "3306:3306"
pubsub:
image: google/cloud-sdk
command: gcloud beta emulators pubsub start --host-port=0.0.0.0:8085
ports:
- '8085:8085'
- "8085:8085"
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
18 changes: 18 additions & 0 deletions gemfiles/ruby_26.rails_60.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.6.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails", "~> 5.0"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "< 3.24.0"
gem "rails", "~> 6.0.0"

gemspec path: "../"
18 changes: 18 additions & 0 deletions gemfiles/ruby_26.rails_61.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.6.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails", "~> 5.0"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "< 3.24.0"
gem "rails", "~> 6.1.0"

gemspec path: "../"
19 changes: 19 additions & 0 deletions gemfiles/ruby_27.rails_60.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.7.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "~> 3.24.0"
gem "rails", "~> 6.0.0"
gem "google-cloud-pubsub", "~> 2.13.0"

gemspec path: "../"
19 changes: 19 additions & 0 deletions gemfiles/ruby_27.rails_61.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.7.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "~> 3.24.0"
gem "rails", "~> 6.0.0"
gem "google-cloud-pubsub", "~> 2.13.0"

gemspec path: "../"
19 changes: 19 additions & 0 deletions gemfiles/ruby_27.rails_70.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.7.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "~> 3.24.0"
gem "rails", "~> 7.0.0"
gem "google-cloud-pubsub", "~> 2.13.0"

gemspec path: "../"
19 changes: 19 additions & 0 deletions gemfiles/ruby_27.rails_71.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

ruby "~> 2.7.0"

gem "ammeter", "~> 1.1"
gem "byebug"
gem "database_cleaner-active_record", "~> 2.0"
gem "factory_bot", "~> 6.2.0"
gem "rspec-rails"
gem "pry-byebug"
gem "rubocop"
gem "ruby-lsp"
gem "google-protobuf", "~> 3.24.0"
gem "rails", "~> 7.1.0"
gem "google-cloud-pubsub", "~> 2.13.0"

gemspec path: "../"
Loading

0 comments on commit 6141d69

Please sign in to comment.