Skip to content

Commit

Permalink
Relocate ActiveRecord generators and final test cleanup (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Nov 16, 2024
1 parent 0717980 commit 553e4f5
Show file tree
Hide file tree
Showing 144 changed files with 166 additions and 2,751 deletions.
39 changes: 1 addition & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
BUNDLE_GEMFILE: gemfiles/rails-${{ matrix.rails }}.gemfile

- name: Test
run: bundle exec rake test
run: bundle exec rake spec
env:
BUNDLE_GEMFILE: gemfiles/rails-${{ matrix.rails }}.gemfile

Expand All @@ -86,40 +86,3 @@ jobs:
- name: Rubocop
run: bundle exec rake rubocop

# test-sample-app:
# runs-on: ubuntu-latest
# services:
# dynamodb:
# image: amazon/dynamodb-local:latest
# ports:
# - 8000:8000
# env:
# AWS_REGION: us-east-1
# AWS_ACCESS_KEY_ID: dummy
# AWS_SECRET_ACCESS_KEY: dummy
# AWS_ENDPOINT_URL: http://localhost:8000
# steps:
# - uses: actions/checkout@v4
#
# - name: Setup Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: ${{ env.ruby_version }}
# bundler-cache: true
# working-directory: ${{ github.workspace }}/sample_app
#
# - name: Create table
# run: cd ${{ github.workspace }}/sample_app && bin/rails runner Aws::SessionStore::DynamoDB::Table.create_table
#
# - name: Insert dummy manifest.json
# run: |
# mkdir -p ${{ github.workspace }}/sample_app/public/packs-test
# echo "{\"application.js\":\"/packs-test/js/application-dummy.js\"}" >> ${{ github.workspace }}/sample_app/public/packs-test/manifest.json
#
# - name: DB Migrate
# run: cd ${{ github.workspace }}/sample_app && bin/rails db:migrate
#
# - name: Test
# run: bundle exec rake test
# working-directory: ${{ github.workspace }}/sample_app
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--require spec_helper
--format documentation
38 changes: 6 additions & 32 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,24 @@ AllCops:
TargetRubyVersion: 2.7
SuggestExtensions: false
Exclude:
- 'tasks/release/**/*'
- 'sample-app/**/*'
- 'sample_app_old/**/*'
- 'spec/dummy/**/*'
- 'test/dummy/**/*'
- 'spec/fixtures/**/*'
- 'spec/fixtures/**/*'

Gemspec/DevelopmentDependencies:
EnforcedStyle: Gemfile

Gemspec/RequireMFA:
Enabled: false

Naming/FileName:
Exclude:
- 'gemfiles/*.gemfile'
- 'lib/aws-sdk-rails.rb'

Style/GlobalVars:
AllowedVariables:
- $VERSION
- $REPO_ROOT

Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
- 'test/**/*.rb'

Metrics/ClassLength:
Metrics/MethodLength:
Exclude:
- 'spec/**/*.rb'
- 'test/**/*.rb'

Metrics/ModuleLength:
Naming/FileName:
Exclude:
- 'spec/**/*.rb'
- 'test/**/*.rb'

Style/HashSyntax:
EnforcedShorthandSyntax: never
- 'gemfiles/*.gemfile'
- 'lib/aws-sdk-rails.rb'

Style/Documentation:
Style/BlockComments:
Exclude:
- 'lib/aws/rails/notifications.rb'
- 'spec/**/*.rb'
- 'test/**/*.rb'
- 'spec/spec_helper.rb'
80 changes: 8 additions & 72 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,29 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-06-24 17:56:34 UTC using RuboCop version 1.64.1.
# on 2024-11-16 00:49:51 UTC using RuboCop version 1.68.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/DuplicateMethods:
Exclude:
- 'lib/aws/rails/sqs_active_job/configuration.rb'

# Offense count: 2
Lint/ShadowedException:
Exclude:
- 'lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb'

# Offense count: 1
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'lib/aws/rails/sqs_active_job/executor.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/aws/rails/sqs_active_job/lambda_handler.rb'

# Offense count: 12
# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 29

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 214

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 11
Max: 21

# Offense count: 18
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 25

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'lib/aws/rails/sqs_active_job/configuration.rb'
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 215

# Offense count: 1
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'

# Offense count: 9
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'lib/active_job/queue_adapters/sqs_adapter.rb'
- 'lib/aws/rails/notifications.rb'
- 'lib/aws/rails/sqs_active_job/configuration.rb'
- 'lib/aws/rails/sqs_active_job/job_runner.rb'
- 'lib/aws/rails/sqs_active_job/lambda_handler.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb'

# Offense count: 23
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 422
Max: 130
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Unreleased Changes

* Feature - New namespace and class names for SQS ActiveJob. Existing namespace has temporarily been kept for backward compatibility and will be removed in aws-sdk-rails ~> 5.

* Issue - Correctly determine if SQSD is running in a Docker container.

* Feature - Aws::Record scaffold generators now lives in the `aws-record-rails` gem.

4.1.0 (2024-09-27)
------------------

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gem 'aws-actiondispatch-dynamodb', git: 'https://github.com/aws/aws-actiondispat
gem 'aws-actionmailbox-ses', git: 'https://github.com/aws/aws-actionmailbox-ses-ruby'
gem 'aws-actionmailer-ses', git: 'https://github.com/aws/aws-actionmailer-ses-ruby'
gem 'aws-activejob-sqs', git: 'https://github.com/aws/aws-activejob-sqs-ruby'
gem 'aws-record-rails', git: 'https://github.com/aws/aws-record-rails'

group :development, :test do
gem 'pry'
Expand Down
16 changes: 2 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'
require 'rake/testtask'
require 'rubocop/rake_task'

Dir.glob('**/*.rake').each do |task_file|
Expand All @@ -10,17 +9,6 @@ end

RuboCop::RakeTask.new

RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new

# Eventually, migrate all tests back into the minitest
# runner. But use minitest-spec-rails to enable syntax.
# Currently, rails generator specs are not running.
Rake::TestTask.new('test:rails') do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.warning = false
end

task test: [:spec, 'test:rails']
task default: :test
task 'release:test' => :test
task 'release:test' => :spec
3 changes: 1 addition & 2 deletions aws-sdk-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Gem::Specification.new do |spec|
spec.add_dependency('aws-actionmailbox-ses', '~> 0')
spec.add_dependency('aws-actionmailer-ses', '~> 0')
spec.add_dependency('aws-activejob-sqs', '~> 0')

spec.add_dependency('aws-record', '~> 2') # for Aws::Record integration
spec.add_dependency('aws-record-rails', '~> 0')

spec.add_dependency('railties', '>= 7.1.0') # Minimum supported Rails version

Expand Down
3 changes: 2 additions & 1 deletion lib/aws/rails/action_mailbox/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
require 'aws/action_mailbox/ses/rspec'
Aws::Rails::ActionMailbox::Rspec = Aws::ActionMailbox::SES::Rspec

Kernel.warn('Aws::Rails::ActionMailbox::Rspec is deprecated in aws-sdk-rails ~> 5. Use Aws::ActionMailbox::SES::Rspec instead.')
Kernel.warn('Aws::Rails::ActionMailbox::Rspec is deprecated in aws-sdk-rails ~> 5. ' \
'Use Aws::ActionMailbox::SES::Rspec instead.')
Kernel.warn('Please require "aws/action_mailbox/ses/rspec" instead of "aws/rails/action_mailbox/rspec"')
3 changes: 2 additions & 1 deletion lib/aws/rails/middleware/elastic_beanstalk_sqsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def from_sqs_daemon?(request)
!current_user_agent.nil? && current_user_agent.start_with?('aws-sqsd')
end

# The beanstalk worker SQS Daemon will add the custom 'X-Aws-Sqsd-Taskname' header for periodic tasks set in cron.yaml.
# The beanstalk worker SQS Daemon will add the custom 'X-Aws-Sqsd-Taskname' header
# for periodic tasks set in cron.yaml.
def periodic_task?(request)
!request.headers['X-Aws-Sqsd-Taskname'].nil? && request.headers['X-Aws-Sqsd-Taskname'].present?
end
Expand Down
1 change: 1 addition & 0 deletions lib/aws/rails/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def add_handlers(handlers, _config)
handlers.add(Handler, step: :initialize, priority: 99)
end

# @api private
class Handler < Seahorse::Client::Handler
def call(context)
event_name = "#{context.operation_name}.#{context.config.api.metadata['serviceId']}.aws"
Expand Down
5 changes: 0 additions & 5 deletions lib/aws/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class Railtie < ::Rails::Railtie
config.eager_load_namespaces << Aws
end
end

rake_tasks do
load 'tasks/dynamo_db/session_store.rake' if defined?(Aws::ActionDispatch::DynamoDb)
load 'tasks/aws_record/migrate.rake' if defined?(Aws::Record)
end
end

# Configures the AWS SDK for Ruby's logger to use the Rails logger.
Expand Down
24 changes: 0 additions & 24 deletions lib/generators/aws_record/model/USAGE

This file was deleted.

Loading

0 comments on commit 553e4f5

Please sign in to comment.