diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a877c1e..2795c4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,9 @@ jobs: fail-fast: false matrix: ruby: - - 2.6 - - 2.7 - # TODO: Add 3.0 after upgrading Rails + - '2.6' + - '2.7' + - '3.0' name: Run test with Ruby ${{ matrix.ruby }} services: mysql: diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c85a1..8d8652f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v2.x.x (xxxx-xx-xx) +### Changes +- Update Rails to 6.1 +- Support Ruby 3.0 + ## v2.8.0 (2021-12-23) ### New features - Pass `BARBEQUE_SENT_TIMESTAMP` variable to invoked jobs diff --git a/app/services/barbeque/sns_subscription_service.rb b/app/services/barbeque/sns_subscription_service.rb index 9f06dd0..577fa99 100644 --- a/app/services/barbeque/sns_subscription_service.rb +++ b/app/services/barbeque/sns_subscription_service.rb @@ -20,10 +20,10 @@ def subscribe(sns_subscription) update_sqs_policy!(sns_subscription) true rescue Aws::SNS::Errors::AuthorizationError - sns_subscription.errors[:topic_arn] << 'is not authorized' + sns_subscription.errors.add(:topic_arn, 'is not authorized') false rescue Aws::SNS::Errors::NotFound - sns_subscription.errors[:topic_arn] << 'is not found' + sns_subscription.errors.add(:topic_arn, 'is not found') false end else diff --git a/barbeque.gemspec b/barbeque.gemspec index 40f8d93..d721ffc 100644 --- a/barbeque.gemspec +++ b/barbeque.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |s| s.add_dependency "hamlit" s.add_dependency "jquery-rails" s.add_dependency "kaminari", ">= 1.2.1" - s.add_dependency "rails", "~> 5.2.0" + s.add_dependency "rails", "~> 6.1.4" s.add_dependency "rinku" s.add_dependency "sass-rails" s.add_dependency "serverengine" diff --git a/lib/barbeque/executor.rb b/lib/barbeque/executor.rb index 5af3d1a..4b0a11b 100644 --- a/lib/barbeque/executor.rb +++ b/lib/barbeque/executor.rb @@ -23,7 +23,7 @@ module Barbeque module Executor def self.create klass = const_get(Barbeque.config.executor, false) - klass.new(Barbeque.config.executor_options) + klass.new(**Barbeque.config.executor_options) end end end diff --git a/lib/barbeque/executor/docker.rb b/lib/barbeque/executor/docker.rb index 561ea4e..b9b00dc 100644 --- a/lib/barbeque/executor/docker.rb +++ b/lib/barbeque/executor/docker.rb @@ -9,7 +9,7 @@ class Docker class DockerCommandError < StandardError end - def initialize(_options) + def initialize(**) end # @param [Barbeque::JobExecution] job_execution diff --git a/lib/barbeque/executor/hako.rb b/lib/barbeque/executor/hako.rb index fe576f3..d535f85 100644 --- a/lib/barbeque/executor/hako.rb +++ b/lib/barbeque/executor/hako.rb @@ -18,7 +18,7 @@ class HakoCommandError < StandardError # @param [String] yaml_dir (deprecated: renamed to definition_dir) def initialize(hako_dir:, hako_env: {}, yaml_dir: nil, definition_dir: nil, oneshot_notification_prefix:) @hako_dir = hako_dir - @hako_env = hako_env + @hako_env = hako_env.stringify_keys @definition_dir = if definition_dir definition_dir diff --git a/spec/barbeque/execution_poller_spec.rb b/spec/barbeque/execution_poller_spec.rb index f24fe17..9a67e30 100644 --- a/spec/barbeque/execution_poller_spec.rb +++ b/spec/barbeque/execution_poller_spec.rb @@ -7,7 +7,7 @@ let(:executor) { double('Barbeque::Executor::Docker') } before do - allow(Barbeque::Executor::Docker).to receive(:new).with({}).and_return(executor) + allow(Barbeque::Executor::Docker).to receive(:new).and_return(executor) end describe '#run' do diff --git a/spec/barbeque/executor/docker_spec.rb b/spec/barbeque/executor/docker_spec.rb index cd138e5..f64d68e 100644 --- a/spec/barbeque/executor/docker_spec.rb +++ b/spec/barbeque/executor/docker_spec.rb @@ -2,7 +2,7 @@ require 'barbeque/executor/docker' RSpec.describe Barbeque::Executor::Docker do - let(:executor) { described_class.new({}) } + let(:executor) { described_class.new } let(:command) { ['rake', 'test'] } let(:job_definition) { FactoryBot.create(:job_definition, command: ['rake', 'test']) } let(:job_execution) { FactoryBot.create(:job_execution, job_definition: job_definition, status: :pending) } diff --git a/spec/barbeque/executor_spec.rb b/spec/barbeque/executor_spec.rb index d7189f3..3c0271b 100644 --- a/spec/barbeque/executor_spec.rb +++ b/spec/barbeque/executor_spec.rb @@ -12,7 +12,12 @@ let(:barbeque_yml) { 'barbeque' } it 'initializes a configured executor' do - expect(Barbeque::Executor::Docker).to receive(:new).with({}) + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') + # Ruby < 2.7 isn't ready for keyword arguments + expect(Barbeque::Executor::Docker).to receive(:new).with({}) + else + expect(Barbeque::Executor::Docker).to receive(:new).with(no_args) + end Barbeque::Executor.create end end @@ -23,11 +28,12 @@ it 'initializes a configured executor with configured options' do expect(Barbeque::Executor::Hako).to receive(:new).with( hako_dir: '/home/k0kubun/hako_repo', - hako_env: { 'ACCESS_TOKEN' => 'token' }, + hako_env: { ACCESS_TOKEN: 'token' }, yaml_dir: '/yamls', oneshot_notification_prefix: 's3://barbeque/task_statuses?region=ap-northeast-1', - ) - Barbeque::Executor.create + ).and_call_original + hako = Barbeque::Executor.create + expect(hako.instance_variable_get(:@hako_env)).to eq({ 'ACCESS_TOKEN' => 'token' }) end end end diff --git a/spec/barbeque/message_handler/job_execution_spec.rb b/spec/barbeque/message_handler/job_execution_spec.rb index 4b4ed7e..3965e86 100644 --- a/spec/barbeque/message_handler/job_execution_spec.rb +++ b/spec/barbeque/message_handler/job_execution_spec.rb @@ -22,7 +22,7 @@ let(:executor) { double('Barbeque::Executor::Docker') } before do - allow(Barbeque::Executor::Docker).to receive(:new).with({}).and_return(executor) + allow(Barbeque::Executor::Docker).to receive(:new).and_return(executor) allow(Barbeque::ExecutionLog).to receive(:save_message) allow(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr) end diff --git a/spec/barbeque/message_handler/job_retry_spec.rb b/spec/barbeque/message_handler/job_retry_spec.rb index 765628a..7bd91c5 100644 --- a/spec/barbeque/message_handler/job_retry_spec.rb +++ b/spec/barbeque/message_handler/job_retry_spec.rb @@ -22,7 +22,7 @@ before do allow(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr) allow(Barbeque::ExecutionLog).to receive(:load).with(execution: job_execution).and_return({ 'message' => message_body }) - allow(Barbeque::Executor::Docker).to receive(:new).with({}).and_return(executor) + allow(Barbeque::Executor::Docker).to receive(:new).and_return(executor) end around do |example| diff --git a/spec/barbeque/retry_poller_spec.rb b/spec/barbeque/retry_poller_spec.rb index 3b5f2dc..d700573 100644 --- a/spec/barbeque/retry_poller_spec.rb +++ b/spec/barbeque/retry_poller_spec.rb @@ -7,7 +7,7 @@ let(:executor) { double('Barbeque::Executor::Docker') } before do - allow(Barbeque::Executor::Docker).to receive(:new).with({}).and_return(executor) + allow(Barbeque::Executor::Docker).to receive(:new).and_return(executor) end describe '#run' do