Skip to content

Commit

Permalink
Merge branch 'main' into FI-3428-share-session
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyssaWang authored Jan 15, 2025
2 parents c3eef07 + 7392983 commit 1fea0c7
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']
ruby-version: ['3.3.6']

steps:
- uses: actions/checkout@v3
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']
ruby-version: ['3.3.6']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
Expand All @@ -49,7 +49,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']
ruby-version: ['3.3.6']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:

AllCops:
NewCops: enable
TargetRubyVersion: 3.1
TargetRubyVersion: 3.3
Exclude:
- 'Gemfile'
- 'vendor/**/*'
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
3.3.6
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.1.2
ruby 3.3.6
nodejs 20.17.0
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '3.1.2'
ruby '3.3.6'

gemspec

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ DEPENDENCIES
yard-junk

RUBY VERSION
ruby 3.1.2p20
ruby 3.3.6p108

BUNDLED WITH
2.4.22
3 changes: 2 additions & 1 deletion inferno_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'sqlite3', '~> 1.4'
spec.add_dependency 'thor', '~> 1.2.1'
spec.add_dependency 'tty-markdown', '~> 0.7.1'
spec.required_ruby_version = Gem::Requirement.new('~> 3.1.2')
spec.required_ruby_version = Gem::Requirement.new('~> 3.3.6')
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/inferno-framework/inferno-core'
spec.metadata['changelog_uri'] = 'https://github.com/inferno-framework/inferno-core/blob/main/CHANGELOG.md'
Expand All @@ -57,6 +57,7 @@ Gem::Specification.new do |spec|
'spec/support/factory_bot.rb',
Dir['spec/factories/**/*.rb'],
Dir['spec/fixtures/**/*.rb'],
Dir['spec/shared/**/*.rb'],
Dir['spec/*.rb']
].flatten

Expand Down
4 changes: 2 additions & 2 deletions lib/inferno/apps/cli/execute/console_outputter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def print_error(_options, exception)

# private

def verbose_print(options, *args)
print(color.dim(*args)) if options[:verbose]
def verbose_print(options, *)
print(color.dim(*)) if options[:verbose]
end

def color
Expand Down
4 changes: 2 additions & 2 deletions lib/inferno/apps/cli/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def load_igs
end
end

def say_unless_quiet(*args)
say(*args) unless options['quiet']
def say_unless_quiet(*)
say(*) unless options['quiet']
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/templates/%library_name%.gemspec.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
# spec.homepage = 'TODO'
spec.license = 'Apache-2.0'
spec.add_dependency 'inferno_core', '~> <%= Inferno::VERSION %>'
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2')
spec.required_ruby_version = Gem::Requirement.new('>= 3.3.6')
spec.metadata['inferno_test_kit'] = 'true'
# spec.metadata['homepage_uri'] = spec.homepage
# spec.metadata['source_code_uri'] = 'TODO'
Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/templates/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require:
AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 3.1
TargetRubyVersion: 3.3
Exclude:
- 'Gemfile'
- 'vendor/**/*'
Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/templates/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
3.3.6
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/templates/.tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 3.1.2
ruby 3.3.6
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/templates/Dockerfile.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.1.2
FROM ruby:3.3.6

ENV INSTALL_PATH=/opt/inferno/
ENV APP_ENV=production
Expand Down
4 changes: 2 additions & 2 deletions lib/inferno/dsl/fhir_resource_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ def fhir_validators
# using multiple validators
# @param required_suite_options [Hash] suite options that must be
# selected in order to use this validator
def fhir_resource_validator(name = :default, required_suite_options: nil, &block)
def fhir_resource_validator(name = :default, required_suite_options: nil, &)
current_validators = fhir_validators[name] || []

new_validator = Inferno::DSL::FHIRResourceValidation::Validator.new(name, id, required_suite_options, &block)
new_validator = Inferno::DSL::FHIRResourceValidation::Validator.new(name, id, required_suite_options, &)

current_validators.reject! { |validator| validator.requirements == required_suite_options }
current_validators << new_validator
Expand Down
4 changes: 2 additions & 2 deletions lib/inferno/dsl/fhir_validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ def fhir_validators
# using multiple validators
# @param required_suite_options [Hash] suite options that must be
# selected in order to use this validator
def validator(name = :default, required_suite_options: nil, &block)
def validator(name = :default, required_suite_options: nil, &)
current_validators = fhir_validators[name] || []

new_validator = Inferno::DSL::FHIRValidation::Validator.new(required_suite_options, &block)
new_validator = Inferno::DSL::FHIRValidation::Validator.new(required_suite_options, &)

current_validators.reject! { |validator| validator.requirements == required_suite_options }
current_validators << new_validator
Expand Down
2 changes: 2 additions & 0 deletions lib/inferno/spec_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ module SpecSupport
FACTORY_PATH = File.expand_path('../../spec/factories', __dir__).freeze
REQUEST_HELPER_PATH = File.expand_path('../../spec/request_helper', __dir__).freeze
RUNNABLE_HELPER_PATH = File.expand_path('../../spec/runnable_helper', __dir__).freeze
TEST_KIT_SPEC = File.expand_path('../../spec/shared/test_kit_examples', __dir__).freeze

def self.require_helpers
require FACTORY_BOT_SUPPORT_PATH
require RUNNABLE_HELPER_PATH
require REQUEST_HELPER_PATH
require TEST_KIT_SPEC
end
end
end
133 changes: 133 additions & 0 deletions spec/shared/test_kit_examples.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
RSpec.shared_examples 'platform_deployable_test_kit' do
let(:test_kit_location) do
Object.const_source_location(described_class.name).first
end
let(:test_kit_gem) do
Bundler.definition.specs.find { |gem| test_kit_location.start_with? gem.full_gem_path }
end
let(:base_path) do
test_kit_gem.full_gem_path
end
let(:test_kit) do
described_class.const_get('Metadata')
rescue NameError
skip 'TestKit must be defined first'
end
let(:suites) do
test_kit.suite_ids.map { |id| Inferno::Repositories::TestSuites.new.find(id) }
end

describe 'TestKit' do
it 'defines test kit in the Metadata class' do
error_message =
"Define #{described_class.name}::Metadata at " \
"lib/#{described_class.name.underscore}/metadata.rb and require it in " \
"lib/#{described_class.name.underscore}.rb\n"

expect { described_class.const_get('Metadata') }.to_not raise_error(NameError), error_message

expect(described_class.const_get('Metadata') < Inferno::Entities::TestKit).to be(true)
end

it 'defines all required fields' do
required_fields = [
:id,
:title,
:description,
:suite_ids,
:version,
:maturity
]

required_fields.each do |field_name|
expect(test_kit.send(field_name)).to be_present
end
end

it 'has a description with a <!-- break -->' do
error_message =
'The test kit description must begin with one paragraph followed by "<!-- ' \
'break -->". The portion of the description above the break is displayed ' \
"on the test kit listing page.\n"

expect(test_kit.description).to include('<!-- break -->'), error_message
end

it 'has a maturity of "Low", "Medium", or "High"' do
expect(['Low', 'Medium', 'High']).to include(test_kit.maturity) # rubocop:disable RSpec/ExpectActual
end

it 'uses the correct ruby version in its Dockerfile' do
dockerfile_path = File.join(base_path, 'Dockerfile')
dockerfile_contents = File.read(dockerfile_path)

expect(dockerfile_contents.lines.first.chomp).to eq('FROM ruby:3.3.6')
end
end

describe 'suites' do
it 'relies on the test kit version rather than defining the version in the suites' do
suite_paths = suites.map { |suite| Object.const_source_location(suite.name).first }
suite_contents = suite_paths.map { |path| File.read(path) }

suite_contents.each_with_index do |suite, i|
error_message =
"Suite at #{suite_paths[i]} should not explicitly declare a version, as " \
'its version can now be determined by the version of its Test Kit.' \
"Remove the `version` method call in the suite definition.\n"

expect(suite).to_not match(/^\s+version(\s|\()\S+\)?/), error_message
end
end

it 'contains standard links' do
suites.each do |suite|
link_labels = suite.links.map { |link| link[:label] }

expected_labels = ['Report Issue', 'Open Source', 'Download']

error_message =
"Include the standard 'Report Issue', 'Open Source', and 'Download links in " \
'each suite.\n'
expect(link_labels).to match_array(expected_labels), error_message
end
end
end

describe 'presets' do
it 'includes presets in the gem' do
presets = Dir[
File.join(base_path, 'config', 'presets', '*.json'),
File.join(base_path, 'config', 'presets', '*.json.erb')
].map { |file_path| file_path.delete_prefix "#{Dir.pwd}/" }

missing_presets = presets - test_kit_gem.files

error_message =
"The following presets are not included in the gem: #{missing_presets.join(', ')}\n" \
"Ensure that config/presets is included in spec.files in #{test_kit_gem.name}.gemspec"

expect(missing_presets).to be_empty, error_message
end
end

describe 'gemspec' do
it 'uses git to determine files to include in the gem' do
gemspec_contents = File.read(File.join(base_path, "#{test_kit_gem.name}.gemspec"))

error_message =
'Use git to determine which files to include in the gem. In ' \
"#{test_kit_gem.name}.gemspec, use: " \
"spec.files = `[ -d .git ] && git ls-files -z lib config/presets LICENSE`.split(\"\\x0\")\n"

expect(gemspec_contents).to include('[ -d .git ] && git ls-files'), error_message
end

it 'includes the inferno test kit metadata tag' do
error_message =
%(Add "spec.metadata['inferno_test_kit'] = 'true'" to #{test_kit_gem.name}.gemspec)

expect(test_kit_gem.metadata['inferno_test_kit']).to eq('true'), error_message
end
end
end

0 comments on commit 1fea0c7

Please sign in to comment.