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
11 changes: 11 additions & 0 deletions lib/generators/infrastructure/gitlab_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require_relative '../generator'

class GitlabGenerator < Generator
def generate_gitlab_file
return unless web?

template('gitlab.tt', "#{name}/gitlab-ci.yml")
end
end
2 changes: 1 addition & 1 deletion lib/generators/infrastructure/templates/github.tt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
ruby-version: 3.4.0
bundler-cache: true

- name: Checkout repository
Expand Down
43 changes: 43 additions & 0 deletions lib/generators/infrastructure/templates/gitlab.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
stages:
- setup
- test
- report

variables:
RUBY_VERSION: "3.4.0"

setup_ruby:
stage: setup
image: ruby:${RUBY_VERSION}
script:
- bundle install --jobs $(nproc) --retry 3
cache:
paths:
- vendor/bundle

run_tests:
stage: test
image: ruby:${RUBY_VERSION}
script:
- mkdir -p allure-results
- <%- if framework == 'cucumber' -%> cucumber features --format pretty <%- else -%> bundle exec rspec spec --format documentation <%- end%>
artifacts:
paths:
- allure-results/
when: always

pages:
stage: report
image: alpine/git
dependencies:
- run_tests
script:
- apk add --no-cache curl unzip
- curl -o allure.zip -L https://github.com/allure-framework/allure2/releases/latest/download/allure-commandline.zip
- unzip allure.zip -d /tmp/
- /tmp/allure-*/bin/allure generate allure-results --clean -o public
artifacts:
paths:
- public
only:
- main
1 change: 1 addition & 0 deletions lib/generators/invoke_generators.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative 'infrastructure/github_generator'
require_relative 'infrastructure/gitlab_generator'
require_relative 'automation/automation_generator'
require_relative 'common_generator'
require_relative 'cucumber/cucumber_generator'
Expand Down
1 change: 1 addition & 0 deletions lib/generators/menu_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def automation_options(menu)
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 :'Gitlab CI/CD', -> { create_framework(framework, automation, 'gitlab') }
menu.choice :No, -> { create_framework(framework, automation) }
menu.choice :Quit, -> { exit }
end
Expand Down
38 changes: 38 additions & 0 deletions spec/integration/generators/gitlab_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/gitlab_generator'
require_relative '../spec_helper'

describe GitlabGenerator do
shared_examples 'selects gitlab as an infrastructure option' do |name|
it 'creates a gitlab infrastructure file' do
expect(File).to exist("#{name}/gitlab-ci.yml")
end
end

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

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

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

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

context 'with cucumber and watir' do
include_examples 'selects gitlab as an infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}_#{CI_PLATFORMS[2]}"
include_examples 'does not select any infrastructure option', "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES[3]}"
end
end
2 changes: 1 addition & 1 deletion spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

RSpec.configure do |config|
config.include(InvokeGenerators)
Expand Down
Loading