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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-04 15:10:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-04 15:10:22 +0300
commiteef37e3313a4f3413633d043e08d85020246ed5e (patch)
treefdd0834ef6c46343af13137e1aa49fd8faf9a69c /tooling
parent191020103bd4d2aad99c62a35201c05d9df74f8f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'tooling')
-rwxr-xr-xtooling/bin/find_change_diffs27
-rwxr-xr-xtooling/bin/qa/check_if_only_quarantined_specs18
2 files changed, 45 insertions, 0 deletions
diff --git a/tooling/bin/find_change_diffs b/tooling/bin/find_change_diffs
new file mode 100755
index 00000000000..8ac26d56476
--- /dev/null
+++ b/tooling/bin/find_change_diffs
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require 'gitlab'
+require 'pathname'
+
+# This script saves the diffs of changes in an MR to the directory specified as the first argument
+
+gitlab_token = ENV.fetch('PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE')
+gitlab_endpoint = ENV.fetch('CI_API_V4_URL')
+mr_project_path = ENV.fetch('CI_MERGE_REQUEST_PROJECT_PATH')
+mr_iid = ENV.fetch('CI_MERGE_REQUEST_IID')
+
+abort("ERROR: Please specify a directory to write MR diffs into.") if ARGV.empty?
+output_diffs_dir = Pathname.new(ARGV.shift).expand_path
+
+Gitlab.configure do |config|
+ config.endpoint = gitlab_endpoint
+ config.private_token = gitlab_token
+end
+
+Gitlab.merge_request_changes(mr_project_path, mr_iid).changes.each do |change|
+ next if change['diff'].empty?
+
+ output_diffs_dir.join(File.dirname(change['new_path'])).mkpath
+ output_diffs_dir.join("#{change['new_path']}.diff").write(change['diff'])
+end
diff --git a/tooling/bin/qa/check_if_only_quarantined_specs b/tooling/bin/qa/check_if_only_quarantined_specs
new file mode 100755
index 00000000000..8a36761c58a
--- /dev/null
+++ b/tooling/bin/qa/check_if_only_quarantined_specs
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+require 'pathname'
+
+# This script assumes the first argument is a directory of files containing diffs of changes from an MR. It exits with a
+# success code if all diffs add a line that quarantines a test. If any diffs are not specs, or they are specs that don't
+# quarantine a test, it exits with code 1 to indicate failure (i.e., there was _not_ only quarantined specs).
+
+abort("ERROR: Please specify the directory containing MR diffs.") if ARGV.empty?
+diffs_dir = Pathname.new(ARGV.shift).expand_path
+
+diffs_dir.glob('**/*').each do |path|
+ next if path.directory?
+
+ exit 1 unless path.to_s.end_with?('_spec.rb.diff')
+ exit 1 unless path.read.match?(/^\+.*, quarantine:/)
+end