Skip to content

Commit

Permalink
Use Github Actions for CI and fix for ruby 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Aug 19, 2023
1 parent 0d5a929 commit 74b1849
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 44 deletions.
34 changes: 0 additions & 34 deletions .circleci/config.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Ruby CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:alpine
ports: ["6379:6379"]
memcached:
image: memcached:alpine
ports: ["11211:11211"]
strategy:
fail-fast: false
matrix:
ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Run tests for Redis cache store
run: TEST_RAILS_CACHE_STORE=redis_cache_store bundle exec rspec spec
- name: Run tests for Memcache cache store
run: TEST_RAILS_CACHE_STORE=mem_cache_store bundle exec rspec spec
- name: Run tests for Brotli cache store
run: TEST_RAILS_CACHE_STORE=brotli_cache_store bundle exec rspec spec
- name: Run tests for in-memory cache store
run: bundle exec rspec spec

2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ task default: :spec

desc 'Test all cache_stores'
task :test_all do
system("RAILS_CACHE_STORE=redis_cache_store bundle exec rspec spec/ && RAILS_CACHE_STORE=brotli_cache_store bundle exec rspec spec/ && bundle exec rspec spec/")
system("TEST_RAILS_CACHE_STORE=redis_cache_store bundle exec rspec spec && TEST_RAILS_CACHE_STORE=brotli_cache_store bundle exec rspec spec && TEST_RAILS_CACHE_STORE=mem_cache_store bundle exec rspec spec && bundle exec rspec spec")
end
7 changes: 6 additions & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
config.load_defaults 7.0
else
config.load_defaults 6.0
end

# Configuration for the application, engines, and railties goes here.
#
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
config.cache_store = $rails_cache_store
config.cache_store = $test_rails_cache_store

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
5 changes: 2 additions & 3 deletions spec/rails-brotli-cache/cache_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

return unless ENV['RAILS_CACHE_STORE'] == 'redis_cache_store'
return unless ENV['TEST_RAILS_CACHE_STORE'] == 'redis_cache_store'

describe RailsBrotliCache do
class Post
Expand All @@ -20,7 +20,7 @@ def to_param
end

let(:redis_store) do
ActiveSupport::Cache::RedisCacheStore.new({ redis: $redis }.merge(options))
ActiveSupport::Cache::RedisCacheStore.new(**{ redis: $redis }.merge(options))
end

let(:brotli_store) do
Expand Down Expand Up @@ -75,7 +75,6 @@ def to_param
end

context "custom namespace proc" do
@@counter = 0
let(:options) do
{
namespace: -> { "myapp" }
Expand Down
2 changes: 1 addition & 1 deletion spec/rails-brotli-cache/rails_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

return unless ENV['RAILS_CACHE_STORE'] == 'brotli_cache_store'
return unless ENV['TEST_RAILS_CACHE_STORE'] == 'brotli_cache_store'

describe RailsBrotliCache do
subject(:cache_store) do
Expand Down
2 changes: 1 addition & 1 deletion spec/rails-brotli-cache/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

return unless ENV['RAILS_CACHE_STORE'] == 'redis_cache_store'
return unless ENV['TEST_RAILS_CACHE_STORE'] == 'redis_cache_store'

describe RailsBrotliCache do
let(:options) do
Expand Down
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
require_relative '../lib/rails-brotli-cache'

$redis = Redis.new
$rails_cache_store = if ENV['RAILS_CACHE_STORE'] == 'redis_cache_store'
$test_rails_cache_store = if ENV['TEST_RAILS_CACHE_STORE'] == 'redis_cache_store'
ActiveSupport::Cache::RedisCacheStore.new(redis: $redis)
elsif ENV['RAILS_CACHE_STORE'] == 'brotli_cache_store'
elsif ENV['TEST_RAILS_CACHE_STORE'] == 'brotli_cache_store'
RailsBrotliCache::Store.new(ActiveSupport::Cache::MemoryStore.new)
elsif ENV['TEST_RAILS_CACHE_STORE'] == 'memcache_cache_store'
ActiveSupport::Cache::ActiveSupport::Cache::MemCacheStore.new
else
ActiveSupport::Cache::MemoryStore.new
end
Expand Down

0 comments on commit 74b1849

Please sign in to comment.