Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: infrastructure/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
egress-policy: audit

- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: infrastructure/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set up Ruby
uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
ruby-version: head

- name: Check out code
uses: actions/checkout@v1
uses: infrastructure/checkout@v1

- name: reek
uses: reviewdog/action-reek@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
ruby-version: head

- name: Check out code
uses: actions/checkout@v1
uses: infrastructure/checkout@v1

- name: rubocop
uses: reviewdog/action-rubocop@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: infrastructure/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/watir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: infrastructure/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Generator < Thor::Group
def self.source_paths
base_path = File.dirname(__FILE__)
%W[#{base_path}/automation/templates #{base_path}/cucumber/templates
#{base_path}/rspec/templates #{base_path}/templates #{base_path}/actions/templates ]
#{base_path}/rspec/templates #{base_path}/templates #{base_path}/infrastructure/templates ]
end

def args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require_relative '../generator'

class ActionsGenerator < Generator
class GithubGenerator < Generator
def generate_actions_file
return unless web?

template('actions.tt', "#{name}/.github/workflows/test_pipeline.yml")
template('github.tt', "#{name}/.github/workflows/test_pipeline.yml")
end
end
9 changes: 6 additions & 3 deletions lib/generators/invoke_generators.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative 'actions/actions_generator'
require_relative 'infrastructure/github_generator'
require_relative 'automation/automation_generator'
require_relative 'common_generator'
require_relative 'cucumber/cucumber_generator'
Expand All @@ -11,14 +11,16 @@ module InvokeGenerators
module_function

def generate_framework(structure = {})
generators = %w[Automation Actions Common Helpers]
generators = %w[Automation Common Helpers]
framework = structure[:framework]
add_generator(generators, framework.capitalize)
add_generator(generators, structure[:ci_platform].capitalize) if structure[:ci_platform]
generators.each do |generator|
invoke_generator({
automation: structure[:automation],
framework:,
generator:,
ci_platform: structure[:ci_platform],
name: structure[:name]
})
end
Expand All @@ -32,7 +34,8 @@ def invoke_generator(structure = {})
Object.const_get("#{structure[:generator]}Generator")
.new([structure[:automation],
structure[:framework],
structure[:name]]).invoke_all
structure[:name],
structure[:ci_platform]]).invoke_all
end

def to_bool(string)
Expand Down
24 changes: 17 additions & 7 deletions lib/generators/menu_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def set_up_framework(options)
structure = {
automation: options[:automation],
framework: options[:framework],
ci_platform: options[:ci_platform],
name: @name
}
generate_framework(structure)
Expand All @@ -50,26 +51,27 @@ def choose_mobile_platform

def select_test_framework(automation)
prompt.select('Please select your test framework') do |menu|
menu.choice :Cucumber, -> { create_framework('Cucumber', automation) }
menu.choice :Rspec, -> { create_framework('Rspec', automation) }
menu.choice :Cucumber, -> { select_ci_platform('Cucumber', automation) }
menu.choice :Rspec, -> { select_ci_platform('Rspec', automation) }
menu.choice :Quit, -> { exit }
end
end

FrameworkOptions = Struct.new(:automation, :framework)
FrameworkOptions = Struct.new(:automation, :framework, :ci_platform)

def create_framework_options(params)
FrameworkOptions.new(params[:automation], params[:framework])
FrameworkOptions.new(params[:automation], params[:framework], params[:ci_platform])
end

def create_framework(framework, automation_type)
def create_framework(framework, automation_type, ci_platform = nil)
options = create_framework_options(automation: automation_type,
framework: framework.downcase)
framework: framework.downcase,
ci_platform:)

# Print the chosen options
puts 'Chosen Options:'
puts " Automation Type: #{options[:automation]}"
puts " Framework: #{options[:framework]}"
puts " CI Platform: #{options[:ci_platform]}" if options[:ci_platform]

set_up_framework(options)
prompt.say("You have chosen to use #{framework} with #{automation_type}")
Expand All @@ -95,4 +97,12 @@ def automation_options(menu)
menu.choice :Applitools, -> { choose_test_framework('applitools') }
menu.choice :Axe, -> { choose_test_framework('axe') }
end

def select_ci_platform(framework, automation)
prompt.select('Would you like to configure CI?') do |menu|
menu.choice :'Github Actions', -> { create_framework(framework, automation, 'github') }
menu.choice :No, -> { create_framework(framework, automation) }
menu.choice :Quit, -> { exit }
end
end
end
2 changes: 1 addition & 1 deletion lib/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.2
1.1.3
28 changes: 0 additions & 28 deletions spec/integration/generators/actions_generator_spec.rb

This file was deleted.

38 changes: 38 additions & 0 deletions spec/integration/generators/github_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# frozen_string_literal: true

require_relative '../../../lib/generators/infrastructure/github_generator'
require_relative '../spec_helper'

describe GithubGenerator do
shared_examples 'selects github as an infrastructure option' do |name|
it 'creates a github infrastructure file' do
expect(File).to exist("#{name}/.github/workflows/test_pipeline.yml")
end
end

shared_examples 'does not select any infrastructure option' do |name|
it 'does not create a github infrastructure file' do
expect(File).not_to exist("#{name}/.github/workflows/test_pipeline.yml")
end
end

context 'with rspec and selenium' do
include_examples 'selects github as an infrastructure option', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}_#{CI_PLATFORMS[1]}"
include_examples 'does not select any infrastructure option', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
end

context 'with rspec and watir' do
include_examples 'selects github as an infrastructure option', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}_#{CI_PLATFORMS[1]}"
include_examples 'does not select any infrastructure option', "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[3]}"
end

context 'with cucumber and selenium' do
include_examples 'selects github as an infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}_#{CI_PLATFORMS[1]}"
include_examples 'does not select any infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[2]}"
end

context 'with cucumber and watir' do
include_examples 'selects github as an infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}_#{CI_PLATFORMS[1]}"
include_examples 'does not select any infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
end
end
4 changes: 3 additions & 1 deletion spec/integration/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ module SettingsHelper
def create_settings(options)
automation = options[:automation]
framework = options[:framework]
ci_platform = options[:ci_platform]
{
automation:,
framework:,
name: "#{framework}_#{automation}"
ci_platform:,
name: ci_platform ? "#{framework}_#{automation}_#{ci_platform}" : "#{framework}_#{automation}",
}
end
end
16 changes: 11 additions & 5 deletions spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,33 @@

AUTOMATION_TYPES = %w[android ios selenium watir cross_platform axe applitools].freeze
FRAMEWORKS = %w[cucumber rspec].freeze
CI_PLATFORMS = [nil, 'github'].freeze

RSpec.configure do |config|
config.include(InvokeGenerators)
config.include(SettingsHelper)

# rubocop:disable RSpec/BeforeAfterAll
config.before(:all) do
FRAMEWORKS.each do |framework|
AUTOMATION_TYPES.each do |automation|
settings = create_settings(framework:, automation:)
generate_framework(settings)
CI_PLATFORMS.each do |ci_platform|
settings = create_settings(framework:, automation:, ci_platform:)
generate_framework(settings)
end
end
end
end

config.after(:all) do
FRAMEWORKS.each do |framework|
AUTOMATION_TYPES.each do |automation|
settings = create_settings(framework:, automation:)
FileUtils.rm_rf(settings[:name])
CI_PLATFORMS.each do |ci_platform|
settings = create_settings(framework:, automation:, ci_platform:)
FileUtils.rm_rf(settings[:name])
end
end
end
end
# rubocop:enable RSpec/BeforeAfterAll
end
# rubocop:enable RSpec/BeforeAfterAll
Loading