Commit b5c7d10c authored by Dan Davison's avatar Dan Davison

Merge branch 'poc-allure-report' into 'master'

Generate allure report for review-qa

See merge request gitlab-org/gitlab!61217
parents 0ef83437 d4dc4af5
......@@ -121,6 +121,7 @@ review-stop:
QA_ARTIFACTS_DIR: "${CI_PROJECT_DIR}/qa"
QA_CAN_TEST_GIT_PROTOCOL_V2: "false"
QA_DEBUG: "true"
QA_GENERATE_ALLURE_REPORT: "true"
GITLAB_USERNAME: "root"
GITLAB_PASSWORD: "${REVIEW_APPS_ROOT_PASSWORD}"
GITLAB_ADMIN_USERNAME: "root"
......@@ -141,6 +142,23 @@ review-stop:
expire_in: 7 days
when: always
.allure-report-base:
image:
name: ${GITLAB_DEPENDENCY_PROXY}andrcuns/allure-report-publisher:0.0.6
entrypoint: [""]
stage: post-qa
variables:
GIT_STRATEGY: none
STORAGE_CREDENTIALS: $QA_ALLURE_REPORT_GCS_CREDENTIALS
script:
- |
allure-report-publisher upload gcs \
--results-glob="qa/gitlab-qa-run-*/**/allure-results/*" \
--bucket="gitlab-qa-allure-reports" \
--prefix="$ALLURE_REPORT_PATH_PREFIX/$CI_COMMIT_REF_SLUG" \
--copy-latest \
--color
review-qa-smoke:
extends:
- .review-qa-base
......@@ -210,6 +228,22 @@ parallel-spec-reports:
junit: qa/gitlab-qa-run-*/**/rspec-*.xml
expire_in: 31d
allure-report-qa-smoke:
extends:
- .allure-report-base
- .review:rules:review-qa-smoke
needs: ["review-qa-smoke"]
variables:
ALLURE_REPORT_PATH_PREFIX: gitlab-review-smoke
allure-report-qa-all:
extends:
- .allure-report-base
- .review:rules:review-qa-all
needs: ["review-qa-all"]
variables:
ALLURE_REPORT_PATH_PREFIX: gitlab-review-all
danger-review:
extends:
- .default-retry
......
......@@ -3,3 +3,4 @@ tmp/
.tool-versions
.ruby-gemset
urls.yml
reports/
......@@ -4,6 +4,7 @@ source 'https://rubygems.org'
gem 'gitlab-qa'
gem 'activesupport', '~> 6.0.3.3' # This should stay in sync with the root's Gemfile
gem 'allure-rspec', '~> 2.13.10'
gem 'capybara', '~> 3.29.0'
gem 'capybara-screenshot', '~> 1.0.23'
gem 'rake', '~> 12.3.3'
......
......@@ -19,6 +19,14 @@ GEM
rack-test (>= 1.1.0, < 2.0)
rest-client (>= 2.0.2, < 3.0)
rspec (~> 3.8)
allure-rspec (2.13.10)
allure-ruby-commons (= 2.13.10)
rspec-core (>= 3.8, < 4)
allure-ruby-commons (2.13.10)
mime-types (>= 3.3, < 4)
oj (>= 3.10, < 4)
require_all (>= 2, < 4)
uuid (>= 2.3, < 3)
ast (2.4.1)
binding_ninja (0.2.3)
byebug (9.1.0)
......@@ -74,6 +82,8 @@ GEM
rake
launchy (2.4.3)
addressable (~> 2.3)
macaddr (1.7.2)
systemu (~> 2.6.5)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.9.0)
......@@ -96,6 +106,7 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.11.5)
parallel (1.19.2)
parallel_tests (2.29.0)
parallel
......@@ -119,6 +130,7 @@ GEM
rack (>= 1.0, < 3)
rake (12.3.3)
regexp_parser (1.6.0)
require_all (3.0.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
......@@ -154,6 +166,7 @@ GEM
selenium-webdriver (3.142.6)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
systemu (2.6.5)
thread_safe (0.3.6)
timecop (0.9.1)
tzinfo (1.2.9)
......@@ -169,6 +182,8 @@ GEM
equalizer (~> 0.0.9)
parser (>= 2.6.5)
procto (~> 0.0.2)
uuid (2.3.9)
macaddr (~> 1.0)
watir (6.18.0)
regexp_parser (>= 1.2, < 3)
selenium-webdriver (>= 3.8)
......@@ -182,6 +197,7 @@ PLATFORMS
DEPENDENCIES
activesupport (~> 6.0.3.3)
airborne (~> 0.3.4)
allure-rspec (~> 2.13.10)
capybara (~> 3.29.0)
capybara-screenshot (~> 1.0.23)
chemlab (~> 0.5)
......
......@@ -45,6 +45,7 @@ module QA
autoload :IPAddress, 'qa/runtime/ip_address'
autoload :Search, 'qa/runtime/search'
autoload :ApplicationSettings, 'qa/runtime/application_settings'
autoload :AllureReport, 'qa/runtime/allure_report'
module API
autoload :Client, 'qa/runtime/api/client'
......
# frozen_string_literal: true
module QA
module Runtime
class AllureReport
class << self
# Configure allure reports
#
# @return [void]
def configure!
return unless Env.generate_allure_report?
require 'allure-rspec'
configure_allure
configure_attachments
configure_rspec
end
private
# Configure allure reporter
#
# @return [void]
def configure_allure
AllureRspec.configure do |config|
config.results_directory = 'tmp/allure-results'
config.clean_results_directory = true
end
end
# Set up failure screenshot attachments
#
# @return [void]
def configure_attachments
Capybara::Screenshot.after_save_screenshot do |path|
Allure.add_attachment(
name: 'screenshot',
source: File.open(path),
type: Allure::ContentType::PNG,
test_case: true
)
end
Capybara::Screenshot.after_save_html do |path|
Allure.add_attachment(
name: 'html',
source: File.open(path),
type: 'text/html',
test_case: true
)
end
end
# Configure rspec
#
# @return [void]
def configure_rspec
RSpec.configure do |config|
config.formatter = AllureRspecFormatter
config.before do |example|
next if example.attempts && example.attempts > 0
testcase = example.metadata[:testcase]
example.tms('Testcase', testcase) if testcase
issue = example.metadata.dig(:quarantine, :issue)
example.issue('Issue', issue) if issue
example.add_link(name: "Job(#{ENV['CI_JOB_NAME']})", url: ENV['CI_JOB_URL']) if ENV['CI']
end
end
end
end
end
end
end
......@@ -2,7 +2,6 @@
require 'gitlab/qa'
require 'uri'
require 'active_support/core_ext/object/blank'
module QA
module Runtime
......@@ -53,6 +52,10 @@ module QA
enabled?(ENV['QA_DEBUG'], default: false)
end
def generate_allure_report?
enabled?(ENV['QA_GENERATE_ALLURE_REPORT'], default: false)
end
def default_branch
ENV['QA_DEFAULT_BRANCH'] || 'master'
end
......
......@@ -19,15 +19,15 @@ module QA
define_singleton_method(attribute) do
attributes[attribute.to_sym].tap do |value|
if value.to_s.empty?
raise ArgumentError, "Empty `#{attribute}` attribute!"
end
raise ArgumentError, "Empty `#{attribute}` attribute!" if value.to_s.empty?
end
end
end
def from_env(var)
JSON.parse(Runtime::Env.runtime_scenario_attributes).each { |k, v| define(k, v) }
return if var.blank?
JSON.parse(var).each { |k, v| define(k, v) }
end
def method_missing(name, *)
......
......@@ -4,6 +4,7 @@ require_relative '../qa'
require 'rspec/retry'
require 'rspec-parameterized'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
require 'knapsack'
......@@ -11,8 +12,8 @@ if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
end
QA::Runtime::Browser.configure!
QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes) if QA::Runtime::Env.runtime_scenario_attributes
QA::Runtime::AllureReport.configure!
QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes)
Dir[::File.join(__dir__, "support/helpers/*.rb")].sort.each { |f| require f }
Dir[::File.join(__dir__, "support/matchers/*.rb")].sort.each { |f| require f }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment