debian-mirror-gitlab/lib/tasks/contracts.rake

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.8 KiB
Ruby
Raw Normal View History

2022-05-07 20:08:51 +05:30
# frozen_string_literal: true
2022-07-23 23:45:48 +05:30
return if Rails.env.production?
2022-05-07 20:08:51 +05:30
require 'pact/tasks/verification_task'
2022-07-23 23:45:48 +05:30
contracts = File.expand_path('../../spec/contracts', __dir__)
2022-05-07 20:08:51 +05:30
provider = File.expand_path('provider', contracts)
# rubocop:disable Rails/RakeEnvironment
namespace :contracts do
namespace :mr do
2022-07-23 23:45:48 +05:30
Pact::VerificationTask.new(:diffs_batch) do |pact|
2022-05-07 20:08:51 +05:30
pact.uri(
2022-07-23 23:45:48 +05:30
"#{contracts}/contracts/project/merge_request/show/mergerequest#show-merge_request_diffs_batch_endpoint.json",
pact_helper: "#{provider}/pact_helpers/project/merge_request/diffs_batch_helper.rb"
2022-05-07 20:08:51 +05:30
)
end
2022-07-23 23:45:48 +05:30
Pact::VerificationTask.new(:diffs_metadata) do |pact|
2022-05-07 20:08:51 +05:30
pact.uri(
2022-07-23 23:45:48 +05:30
"#{contracts}/contracts/project/merge_request/show/" \
"mergerequest#show-merge_request_diffs_metadata_endpoint.json",
pact_helper: "#{provider}/pact_helpers/project/merge_request/diffs_metadata_helper.rb"
2022-05-07 20:08:51 +05:30
)
end
2022-07-23 23:45:48 +05:30
Pact::VerificationTask.new(:discussions) do |pact|
2022-05-07 20:08:51 +05:30
pact.uri(
2022-07-23 23:45:48 +05:30
"#{contracts}/contracts/project/merge_request/show/mergerequest#show-merge_request_discussions_endpoint.json",
pact_helper: "#{provider}/pact_helpers/project/merge_request/discussions_helper.rb"
2022-05-07 20:08:51 +05:30
)
end
desc 'Run all merge request contract tests'
task 'test:merge_request', :contract_mr do |_t, arg|
raise(ArgumentError, 'Merge request contract tests require contract_mr to be set') unless arg[:contract_mr]
ENV['CONTRACT_MR'] = arg[:contract_mr]
errors = %w[metadata discussions diffs].each_with_object([]) do |task, err|
Rake::Task["contracts:mr:pact:verify:#{task}"].execute
rescue StandardError, SystemExit
err << "contracts:mr:pact:verify:#{task}"
end
raise StandardError, "Errors in tasks #{errors.join(', ')}" unless errors.empty?
end
end
end
# rubocop:enable Rails/RakeEnvironment