Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fi-2413-optional-grou…
Browse files Browse the repository at this point in the history
…ps-prioritize-pass
  • Loading branch information
Shaumik-Ashraf committed Jan 17, 2024
2 parents 2ed8d13 + b7ecc81 commit 4644b7e
Show file tree
Hide file tree
Showing 42 changed files with 1,229 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PATH
dry-configurable (= 0.13.0)
dry-container (= 0.9.0)
dry-core (= 0.8.1)
dry-inflector (= 0.3)
dry-system (= 0.20.0)
faraday (~> 1.2)
faraday_middleware (~> 1.2)
Expand Down
1 change: 1 addition & 0 deletions inferno_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'dry-configurable', '0.13.0'
spec.add_runtime_dependency 'dry-container', '0.9.0'
spec.add_runtime_dependency 'dry-core', '0.8.1'
spec.add_runtime_dependency 'dry-inflector', '0.3'
spec.add_runtime_dependency 'dry-system', '0.20.0'
spec.add_runtime_dependency 'faraday', '~> 1.2'
spec.add_runtime_dependency 'faraday_middleware', '~> 1.2'
Expand Down
3 changes: 3 additions & 0 deletions lib/inferno/apps/cli/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative 'services'
require_relative 'suite'
require_relative 'suites'
require_relative 'new'

module Inferno
module CLI
Expand Down Expand Up @@ -49,6 +50,8 @@ def suites

desc 'suite SUBCOMMAND ...ARGS', 'Perform suite-based operations'
subcommand 'suite', Suite

register(New, 'new', 'new TEST_KIT_NAME', 'Run `inferno new --help` for full help')
end
end
end
103 changes: 103 additions & 0 deletions lib/inferno/apps/cli/new.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
require 'thor'
require 'bundler'
require_relative '../../utils/named_thor_actions'
require_relative '../../version'

module Inferno
module CLI
class New < Thor::Group
include Thor::Actions
include Inferno::Utils::NamedThorActions

desc <<~HELP
Generate a new Inferno test kit for FHIR software testing
Examples:
`inferno new test_fhir_app`
=> generates an Inferno app
`inferno new test_my_ig -a MyName`
=> generates Inferno app and specifies MyName as gemspec author
https://inferno-framework.github.io/index.html
HELP

def self.banner
'inferno new TEST_KIT_NAME'
end

def self.source_root
File.join(__dir__, 'templates')
end

argument :name,
type: :string,
required: true,
desc: 'name for new Inferno project'
class_option :author,
type: :string,
aliases: '-a',
default: [],
repeatable: true,
desc: "Author names for gemspec file; you may use '-a' multiple times"
class_option :skip_bundle,
type: :boolean,
aliases: '-b',
default: false,
desc: 'Do not run bundle install'

add_runtime_options!

def create_app
directory('.', root_name, { mode: :preserve, recursive: true, verbose: !options['quiet'] })

bundle_install
inferno_migrate

say_unless_quiet "Created #{root_name} Inferno test kit!", :green

return unless options['pretend']

say_unless_quiet 'This was a dry run; re-run without `--pretend` to actually create project',
:yellow
end

private

def ig_path
File.join('lib', library_name, 'igs')
end

def authors
options['author'].presence || [default_author]
end

def default_author
ENV['USER'] || ENV['USERNAME'] || 'PUT_YOUR_NAME_HERE'
end

def bundle_install
return if options['skip_bundle']

inside(root_name) do
Bundler.with_unbundled_env do
run 'bundle install', verbose: !options['quiet'], capture: options['quiet']
end
end
end

def inferno_migrate
return if options['skip_bundle']

inside(root_name) do
run 'bundle exec inferno migrate', verbose: !options['quiet'], capture: options['quiet']
end
end

def say_unless_quiet(*args)
say(*args) unless options['quiet']
end
end
end
end
26 changes: 26 additions & 0 deletions lib/inferno/apps/cli/templates/%library_name%.gemspec.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Gem::Specification.new do |spec|
spec.name = '<%= library_name %>'
spec.version = '0.0.1'
spec.authors = <%= authors %>
# spec.email = ['TODO']
spec.date = Time.now.utc.strftime('%Y-%m-%d')
spec.summary = '<%= title_name %> Test Kit'
spec.description = '<%= human_name %> Inferno test kit for FHIR'
# spec.homepage = 'TODO'
spec.license = 'Apache-2.0'
spec.add_runtime_dependency 'inferno_core', '~> <%= Inferno::VERSION %>'
spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8'
spec.add_development_dependency 'factory_bot', '~> 6.1'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'webmock', '~> 3.11'
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2')
# spec.metadata['homepage_uri'] = spec.homepage
# spec.metadata['source_code_uri'] = 'TODO'
spec.files = [
Dir['lib/**/*.rb'],
Dir['lib/**/*.json'],
'LICENSE'
].flatten

spec.require_paths = ['lib']
end
22 changes: 22 additions & 0 deletions lib/inferno/apps/cli/templates/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.env.local
.env.*.local
.env.development
.env.test
Dockerfile
.gitignore

.byebug_history
**/.DS_Store
.vscode/*
.project
.settings/.jsdtscope
.settings/org.eclipse.wst.jsdt.ui.superType.container
.settings/org.eclipse.wst.jsdt.ui.superType.name
.idea

/coverage
/data
/.git
/.github
/log
/tmp
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JS_HOST=""
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VALIDATOR_URL=http://localhost/validatorapi
REDIS_URL=redis://localhost:6379/0
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REDIS_URL=redis://redis:6379/0
VALIDATOR_URL=http://validator_service:4567
2 changes: 2 additions & 0 deletions lib/inferno/apps/cli/templates/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VALIDATOR_URL=https://example.com/validatorapi
ASYNC_JOBS=false
20 changes: 20 additions & 0 deletions lib/inferno/apps/cli/templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/data/*.db
/data/redis/**/*.rdb
/data/redis/**/*.aof
/data/redis/**/*.manifest
/tmp
.env.local
.env.*.local
**/.DS_Store
.vscode/*
.project
.settings/.jsdtscope
.settings/org.eclipse.wst.jsdt.ui.superType.container
.settings/org.eclipse.wst.jsdt.ui.superType.name
.idea

/coverage
/spec/examples.txt
/docs/yard
.yardoc
node_modules
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.2
1 change: 1 addition & 0 deletions lib/inferno/apps/cli/templates/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.2
22 changes: 22 additions & 0 deletions lib/inferno/apps/cli/templates/Dockerfile.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ruby:3.1.2

ENV INSTALL_PATH=/opt/inferno/
ENV APP_ENV=production
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

ADD *.gemspec $INSTALL_PATH
ADD Gemfile* $INSTALL_PATH
RUN gem install bundler
# The below RUN line is commented out for development purposes, because any change to the
# required gems will break the dockerfile build process.
# If you want to run in Deploy mode, just run `bundle install` locally to update
# Gemfile.lock, and uncomment the following line.
# RUN bundle config set --local deployment 'true'
RUN bundle install

ADD . $INSTALL_PATH

EXPOSE 4567
CMD ["bundle", "exec", "puma"]
9 changes: 9 additions & 0 deletions lib/inferno/apps/cli/templates/Gemfile.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec

group :development, :test do
gem 'debug'
end
Loading

0 comments on commit 4644b7e

Please sign in to comment.