Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/contracts/pipelines.rake')
-rw-r--r--lib/tasks/contracts/pipelines.rake39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/tasks/contracts/pipelines.rake b/lib/tasks/contracts/pipelines.rake
new file mode 100644
index 00000000000..c018645722e
--- /dev/null
+++ b/lib/tasks/contracts/pipelines.rake
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+return if Rails.env.production?
+
+require 'pact/tasks/verification_task'
+
+contracts = File.expand_path('../../../spec/contracts', __dir__)
+provider = File.expand_path('provider', contracts)
+
+# rubocop:disable Rails/RakeEnvironment
+namespace :contracts do
+ namespace :pipelines do
+ Pact::VerificationTask.new(:get_list_project_pipelines) do |pact|
+ pact.uri(
+ "#{contracts}/contracts/project/pipeline/index/pipelines#index-get_list_project_pipelines.json",
+ pact_helper: "#{provider}/pact_helpers/project/pipeline/get_list_project_pipelines_helper.rb"
+ )
+ end
+
+ Pact::VerificationTask.new(:get_pipeline_header_data) do |pact|
+ pact.uri(
+ "#{contracts}/contracts/project/pipeline/show/pipelines#show-get_pipeline_header_data.json",
+ pact_helper: "#{provider}/pact_helpers/project/pipeline/get_pipeline_header_data_helper.rb"
+ )
+ end
+
+ desc 'Run all pipeline contract tests'
+ task 'test:pipelines', :contract_mr do |_t, arg|
+ errors = %w[get_list_project_pipelines get_pipeline_header_data].each_with_object([]) do |task, err|
+ Rake::Task["contracts:pipelines:pact:verify:#{task}"].execute
+ rescue StandardError, SystemExit
+ err << "contracts:pipelines:pact:verify:#{task}"
+ end
+
+ raise StandardError, "Errors in tasks #{errors.join(', ')}" unless errors.empty?
+ end
+ end
+end
+# rubocop:enable Rails/RakeEnvironment