Skip to content

Commit

Permalink
FI-3302: Add CI actions to template (#574)
Browse files Browse the repository at this point in the history
* add ruby CI actions to template

* add rubocop to template

* fix template linting errors

* fix authors formatting

* fix specs

* add workflow_dispatch to github actions

* fix typo
  • Loading branch information
Jammjammjamm authored Dec 30, 2024
1 parent f30f8b3 commit 84977e0
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion lib/inferno/apps/cli/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_test_kit
private

def authors
options['author'].presence || [default_author]
(options['author'].presence || [default_author]).to_json.gsub('"', "'")
end

def default_author
Expand Down
7 changes: 1 addition & 6 deletions lib/inferno/apps/cli/templates/%library_name%.gemspec.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ Gem::Specification.new do |spec|
spec.version = <%= module_name %>::VERSION
spec.authors = <%= authors %>
# spec.email = ['TODO']
spec.date = Time.now.utc.strftime('%Y-%m-%d')
spec.summary = '<%= title_name %>'
# spec.description = <<~DESCRIPTION
# This is a big markdown description of the test kit.
# DESCRIPTION
# 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.add_dependency 'inferno_core', '~> <%= Inferno::VERSION %>'
spec.required_ruby_version = Gem::Requirement.new('>= 3.1.2')
spec.metadata['inferno_test_kit'] = 'true'
# spec.metadata['homepage_uri'] = spec.homepage
Expand Down
55 changes: 55 additions & 0 deletions lib/inferno/apps/cli/templates/.github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Ruby

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake

lint:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1.2']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Rubocop
run: bundle exec rubocop
77 changes: 77 additions & 0 deletions lib/inferno/apps/cli/templates/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
require:
- rubocop-rspec

AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 3.1
Exclude:
- 'Gemfile'
- 'vendor/**/*'

Layout/LineLength:
Max: 120

Layout/MultilineMethodCallIndentation:
EnforcedStyle: 'indented'

Style/Documentation:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/NumericLiterals:
Enabled: false

Style/OpenStructUse:
Exclude:
- 'spec/**/*'

Style/SymbolArray:
Enabled: false

Style/WordArray:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/ModuleLength:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Metrics/ParameterLists:
Enabled: false

RSpec/AnyInstance:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/NestedGroups:
Enabled: false

RSpec/NotToNot:
EnforcedStyle: to_not

Gemspec/RequireMFA:
Enabled: false
7 changes: 7 additions & 0 deletions lib/inferno/apps/cli/templates/Gemfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ gemspec

group :development, :test do
gem 'debug'
gem 'rubocop', '~> 1.9'
gem 'rubocop-rspec', require: false
end

group :test do
gem 'database_cleaner-sequel', '~> 1.8'
gem 'factory_bot', '~> 6.1'
gem 'rack-test'
gem 'rspec', '~> 3.10'
gem 'simplecov', '0.21.2', require: false
gem 'webmock', '~> 3.11'
end
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ module <%= module_name %>
# using their id
group from: :patient_group
end
end
end
4 changes: 2 additions & 2 deletions spec/inferno/cli/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
expect(File).to exist('test-fhir-app/lib/test_fhir_app.rb')

if cli_args.count('--author') == 1
expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include('authors ["ABC"]')
expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include("authors ['ABC']")
elsif cli_args.count('--author') == 2
expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include('authors ["ABC", "DEF"]')
expect(File.read('test-fhir-app/lib/test_fhir_app/metadata.rb')).to include("authors ['ABC','DEF']")
end

if cli_args.count('--implementation-guide') == 1
Expand Down

0 comments on commit 84977e0

Please sign in to comment.