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

find_foss_tests « bin « tooling - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c694210ad4031342f059c7a4ff2301796cbdef5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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(' '))