Skip to content

Commit

Permalink
Merge branch 'decaf' into stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Feb 27, 2025
2 parents a5a292b + 6b12226 commit ceca278
Show file tree
Hide file tree
Showing 86 changed files with 313 additions and 189 deletions.
1 change: 0 additions & 1 deletion .rspec

This file was deleted.

3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ AllCops:
TargetRubyVersion: 3.3
SuggestExtensions: false
Exclude:
- 'projections/**/*'
- 'build/**/*'
- 'tasks/release/**/*'
- 'vendor/**/*'
Expand All @@ -18,6 +19,7 @@ Metrics/AbcSize:
Metrics/BlockLength:
Exclude:
- 'Rakefile'
- 'tasks/**/*.rake'
- '**/spec/**/*.rb'

Metrics/ClassLength:
Expand All @@ -38,6 +40,7 @@ Metrics/ModuleLength:

Naming/FileName:
Exclude:
- 'tasks/**/*.rake'
- '**/spec/**/*.rb'
- 'gems/smithy-client/lib/smithy-client.rb'
- 'gems/smithy-server/lib/smithy-server.rb'
Expand Down
184 changes: 2 additions & 182 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,189 +1,9 @@
# frozen_string_literal: true

require 'rubocop/rake_task'
require 'rspec/core/rake_task'

RuboCop::RakeTask.new

namespace :smithy do
RSpec::Core::RakeTask.new('spec:unit') do |t|
t.pattern = 'gems/smithy/spec/**/*_spec.rb'
t.ruby_opts = '-I gems/smithy/spec'
t.rspec_opts = '--format documentation'
t.rspec_opts += ' --tag rbs_test' if ENV['SMITHY_RUBY_RBS_TEST']
end

task 'spec:generated', [:suite, :rbs_test] do |_t, args|
require_relative 'gems/smithy/spec/spec_helper'

spec_paths = []
include_paths = ['gems/smithy/spec/support/matchers']
plans = []
rbs_targets = %w[Smithy Smithy::* Smithy::Client]
sig_paths = %w[gems/smithy-client/sig gems/smithy-schema/sig]
Dir.glob("gems/smithy/spec/fixtures/#{args[:suite]}/*/model.json") do |model_path|
test_name = model_path.split('/')[-2]
test_module = test_name.gsub('-', '').camelize
plan = SpecHelper.generate_gem(test_module, :client, fixture: "#{args[:suite]}/#{test_name}")
plans << plan
tmpdir = plan.destination_root
spec_paths << "#{tmpdir}/spec"
include_paths << "#{tmpdir}/lib"
include_paths << "#{tmpdir}/spec"
sig_paths << "#{tmpdir}/sig"
rbs_targets += [test_module, "#{test_module}::*"]
end
specs = spec_paths.join(' ')
includes = include_paths.map { |p| "-I #{p}" }.join(' ')

env =
if args[:rbs_test]
{
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup',
'RBS_TEST_RAISE' => 'true',
'RBS_TEST_LOGLEVEL' => 'error',
'RBS_TEST_OPT' => sig_paths.map { |p| "-I #{p}" }.join(' '),
'RBS_TEST_TARGET' => "\"#{rbs_targets.join(',')}\"",
'RBS_TEST_DOUBLE_SUITE' => 'rspec'
}
else
{}
end

sh(env, "bundle exec rspec #{specs} #{includes}")
ensure
plans.each { |plan| SpecHelper.cleanup_gem(plan) }
end

task 'spec:endpoints', [:rbs_test] do |_t, args|
task('smithy:spec:generated').invoke('endpoints', args[:rbs_test])
end

task 'spec:protocols', [:rbs_test] do |_t, args|
task('smithy:spec:generated').invoke('protocol_tests', args[:rbs_test])
end

task 'spec' => %w[spec:unit spec:endpoints spec:protocols]

desc 'Convert all fixture smithy models to JSON AST representation.'
task 'sync-fixtures' do
smithy_build_files = Dir.glob('gems/smithy/spec/fixtures/**/smithy-build.json')
Dir.glob('gems/smithy/spec/fixtures/**/model.smithy') do |model_path|
out_path = model_path.sub('.smithy', '.json')
config_files = smithy_build_files.map do |file|
if model_path.include?(File.dirname(file))
FileUtils.touch(file) # https://github.com/smithy-lang/smithy/issues/2537
" --config #{file}"
end
end
sh("smithy ast#{config_files.join} #{model_path} > #{out_path}")
end
end

desc 'Validate that all fixtures JSON models are up to date.'
task 'validate-fixtures' do
require 'json'
failures = []
smithy_build_files = Dir.glob('gems/smithy/spec/fixtures/**/smithy-build.json')
Dir.glob('gems/smithy/spec/fixtures/**/model.smithy') do |model_path|
old = JSON.load_file(model_path.sub('.smithy', '.json'))
config_files = smithy_build_files.map do |file|
if model_path.include?(File.dirname(file))
FileUtils.touch(file) # https://github.com/smithy-lang/smithy/issues/2537
" --config #{file}"
end
end
new = JSON.parse(`smithy ast#{config_files.join} #{model_path}`)
failures << model_path if old != new
end
if failures.any?
puts 'Fixture models out of sync:'
failures.each { |m| puts "\t#{m}" }

raise 'Fixture models are out of sync. Run bundle exec rake smithy:sync-fixtures to correct'
end
end

desc 'Run RBS spy tests for all Unit tests that use fixtures.'
task 'rbs:unit' do
env = {
'SMITHY_RUBY_RBS_TEST' => 'true'
}
sh(env, 'bundle exec rake smithy:spec:unit')
end

desc 'Run RBS spy tests for all generated endpoint provider specs.'
task 'rbs:endpoints' do
task('smithy:spec:endpoints').invoke('rbs_test')
end

desc 'Run RBS spy tests for all generated protocol test specs.'
task 'rbs:protocol_tests' do
task('smithy:spec:protocols').invoke('rbs_test')
end

desc 'Run RBS spy tests for unit tests and generated endpoint provider specs.'
task 'rbs' => %w[rbs:unit rbs:endpoints rbs:protocol_tests]
end

namespace 'smithy-client' do
RSpec::Core::RakeTask.new do |t|
t.pattern = 'gems/smithy-client/spec/**/*_spec.rb'
t.ruby_opts = '-I gems/smithy-client/spec'
t.rspec_opts = '--format documentation'
end

desc 'Run RBS validation.'
task 'rbs:validate' do
sh('bundle exec rbs -I gems/smithy-client/sig -I gems/smithy-schema/sig validate')
end

desc 'Run RBS spy tests on all unit tests.'
task 'rbs:test' do
env = {
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup',
'RBS_TEST_RAISE' => 'true',
'RBS_TEST_LOGLEVEL' => 'error',
'RBS_TEST_OPT' => '-I gems/smithy-client/sig -I gems/smithy-schema/sig',
'RBS_TEST_TARGET' => '"Smithy::Client,Smithy::Client::*"',
'RBS_TEST_DOUBLE_SUITE' => 'rspec'
}
sh(env,
'bundle exec rspec gems/smithy-client/spec -I gems/smithy-client/lib -I gems/smithy-client/spec ' \
"--require spec_helper --tag '~rbs_test:skip'")
end

desc 'Run RBS validation and spy tests.'
task 'rbs' => %w[rbs:validate rbs:test]
end

namespace 'smithy-schema' do
RSpec::Core::RakeTask.new do |t|
t.pattern = 'gems/smithy-schema/spec/**/*_spec.rb'
t.ruby_opts = '-I gems/smithy-schema/spec'
t.rspec_opts = '--format documentation'
end

desc 'Run RBS validation.'
task 'rbs:validate' do
sh('bundle exec rbs -I gems/smithy-schema/sig validate')
end

desc 'Run RBS spy tests on all unit tests.'
task 'rbs:test' do
env = {
'RUBYOPT' => '-r bundler/setup -r rbs/test/setup',
'RBS_TEST_RAISE' => 'true',
'RBS_TEST_LOGLEVEL' => 'error',
'RBS_TEST_OPT' => '-I gems/smithy-client/sig',
'RBS_TEST_TARGET' => '"Smithy::Schema,Smithy::Schema::*"',
'RBS_TEST_DOUBLE_SUITE' => 'rspec'
}
sh(env,
'bundle exec rspec gems/smithy-schema/spec -I gems/smithy-schema/lib -I gems/smithy-schema/spec ' \
"--require spec_helper --tag '~rbs_test:skip'")
end

desc 'Run RBS validation and spy tests.'
task 'rbs' => %w[rbs:validate rbs:test]
Dir.glob('tasks/**/*.rake').each do |task_file|
load(task_file)
end
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe Base do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/cbor/decoder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module CBOR
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/cbor/encoder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module CBOR
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/cbor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe CBOR do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/codecs/cbor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module Codecs
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe Configuration do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/endpoint_rules_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe EndpointRules do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/errors_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
module Errors
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/handler_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe HandlerBuilder do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/handler_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe HandlerContext do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/handler_list_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe HandlerList, rbs_test: :skip do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/handler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe Handler do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/http/headers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module HTTP
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/http/request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module HTTP
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/http/response_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module HTTP
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/input_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

require 'tempfile'

module Smithy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module NetHTTP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

require 'smithy-client/plugins/net_http'

module Smithy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

module Smithy
module Client
module NetHTTP
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/output_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe Output do
Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/param_converter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

require 'bigdecimal'
require 'stringio'

Expand Down
2 changes: 2 additions & 0 deletions gems/smithy-client/spec/smithy-client/param_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative '../spec_helper'

module Smithy
module Client
describe ParamValidator do
Expand Down
Loading

0 comments on commit ceca278

Please sign in to comment.