2021-12-07 13:10:32 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
namespace :knapsack do
|
2022-04-29 20:09:38 -04:00
|
|
|
desc "Run tests with knapsack runner"
|
|
|
|
task :rspec, [:rspec_args] do |_, args|
|
2022-05-05 08:08:03 -04:00
|
|
|
rspec_args = args[:rspec_args]&.split(' ') || []
|
|
|
|
|
2022-05-04 14:08:35 -04:00
|
|
|
unless QA::Runtime::Env.knapsack?
|
|
|
|
QA::Runtime::Logger.info("This environment is not compatible with parallel knapsack execution!")
|
|
|
|
QA::Runtime::Logger.info("Falling back to standard execution")
|
|
|
|
|
2022-05-05 08:08:03 -04:00
|
|
|
exit RSpec::Core::Runner.run([*rspec_args, "qa/specs/features"])
|
2022-05-04 14:08:35 -04:00
|
|
|
end
|
2022-04-29 20:09:38 -04:00
|
|
|
|
2022-05-05 08:08:03 -04:00
|
|
|
exit QA::Specs::KnapsackRunner.run(rspec_args)
|
2022-04-29 20:09:38 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 14:11:24 -04:00
|
|
|
desc "Download latest knapsack reports for parallel jobs"
|
|
|
|
task :download, [:stage_name] do |_, args|
|
|
|
|
test_stage_name = args[:stage_name]
|
2022-10-25 08:10:36 -04:00
|
|
|
knapsack_reports = ENV["QA_KNAPSACK_REPORTS"]&.split(",")
|
|
|
|
ci_token = ENV["QA_GITLAB_CI_TOKEN"]
|
2022-05-18 17:07:37 -04:00
|
|
|
|
2022-10-25 08:10:36 -04:00
|
|
|
reports = if knapsack_reports
|
|
|
|
knapsack_reports
|
|
|
|
else
|
|
|
|
unless ci_token
|
|
|
|
QA::Runtime::Logger.error("Missing QA_GITLAB_CI_TOKEN for automatically detecting parallel jobs")
|
|
|
|
next
|
|
|
|
end
|
2022-08-08 14:11:24 -04:00
|
|
|
|
|
|
|
QA::Support::ParallelPipelineJobs
|
2022-10-25 08:10:36 -04:00
|
|
|
.fetch(stage_name: test_stage_name, access_token: ci_token)
|
2022-08-08 14:11:24 -04:00
|
|
|
.map { |job| job.tr(":", "-") }
|
|
|
|
end
|
|
|
|
|
|
|
|
reports.each do |report_name|
|
2022-05-18 17:07:37 -04:00
|
|
|
QA::Support::KnapsackReport.new(report_name).download_report
|
|
|
|
rescue StandardError => e
|
|
|
|
QA::Runtime::Logger.error(e)
|
|
|
|
end
|
2021-12-07 13:10:32 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Merge and upload knapsack report"
|
2021-12-28 16:16:11 -05:00
|
|
|
task :upload, [:glob] do |_task, args|
|
2022-04-29 20:09:38 -04:00
|
|
|
QA::Support::KnapsackReport.upload_report(args[:glob])
|
2021-12-07 13:10:32 -05:00
|
|
|
end
|
2022-01-14 19:15:15 -05:00
|
|
|
|
|
|
|
desc "Report long running spec files"
|
|
|
|
task :notify_long_running_specs do
|
2022-06-02 08:09:21 -04:00
|
|
|
QA::Tools::LongRunningSpecReporter.execute
|
2022-01-14 19:15:15 -05:00
|
|
|
end
|
2021-12-07 13:10:32 -05:00
|
|
|
end
|