diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /tooling/bin | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'tooling/bin')
-rwxr-xr-x | tooling/bin/find_foss_tests | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tooling/bin/find_foss_tests b/tooling/bin/find_foss_tests new file mode 100755 index 00000000000..c694210ad40 --- /dev/null +++ b/tooling/bin/find_foss_tests @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative '../../lib/gitlab/popen' +require_relative '../lib/tooling/test_file_finder' + +require 'gitlab' + +gitlab_token = ENV.fetch('DANGER_GITLAB_API_TOKEN', '') + +Gitlab.configure do |config| + config.endpoint = 'https://gitlab.com/api/v4' + config.private_token = gitlab_token +end + +output_file = ARGV.shift + +mr_project_path = ENV.fetch('CI_MERGE_REQUEST_PROJECT_PATH') +mr_iid = ENV.fetch('CI_MERGE_REQUEST_IID') + +mr_changes = Gitlab.merge_request_changes(mr_project_path, mr_iid) +changed_files = mr_changes.changes.map { |change| change['new_path'] } + +tests_to_run = changed_files.flat_map do |file| + test_files = Tooling::TestFileFinder.new(file, foss_test_only: true).test_files + test_files.select { |f| File.exist?(f) } +end + +File.write(output_file, tests_to_run.uniq.join(' ')) |