Commit 12d7c00f authored by Albert Salim's avatar Albert Salim

Extract list of changed files to artifact

parent 0fd00976
...@@ -70,11 +70,13 @@ verify-tests-yml: ...@@ -70,11 +70,13 @@ verify-tests-yml:
- install_gitlab_gem - install_gitlab_gem
- install_tff_gem - install_tff_gem
- retrieve_tests_mapping - retrieve_tests_mapping
- 'if [ -n "$CI_MERGE_REQUEST_IID" ]; then tooling/bin/find_tests ${MATCHED_TESTS_FILE}; fi' - 'if [ -n "$CI_MERGE_REQUEST_IID" ]; then tooling/bin/find_changes ${CHANGES_FILE}; fi'
- 'if [ -n "$CI_MERGE_REQUEST_IID" ]; then echo "test files affected: $(cat $MATCHED_TESTS_FILE)"; fi' - 'if [ -n "$CI_MERGE_REQUEST_IID" ]; then tooling/bin/find_tests ${CHANGES_FILE} ${MATCHED_TESTS_FILE}; fi'
- 'if [ -n "$CI_MERGE_REQUEST_IID" ]; then echo "related rspec tests: $(cat $MATCHED_TESTS_FILE)"; fi'
artifacts: artifacts:
expire_in: 7d expire_in: 7d
paths: paths:
- ${CHANGES_FILE}
- ${MATCHED_TESTS_FILE} - ${MATCHED_TESTS_FILE}
detect-tests: detect-tests:
...@@ -83,6 +85,7 @@ detect-tests: ...@@ -83,6 +85,7 @@ detect-tests:
- .rails:rules:detect-tests - .rails:rules:detect-tests
variables: variables:
RSPEC_TESTS_MAPPING_ENABLED: "true" RSPEC_TESTS_MAPPING_ENABLED: "true"
CHANGES_FILE: tmp/changed_files.txt
MATCHED_TESTS_FILE: tmp/matching_tests.txt MATCHED_TESTS_FILE: tmp/matching_tests.txt
detect-tests as-if-foss: detect-tests as-if-foss:
...@@ -91,6 +94,7 @@ detect-tests as-if-foss: ...@@ -91,6 +94,7 @@ detect-tests as-if-foss:
- .rails:rules:detect-tests - .rails:rules:detect-tests
- .as-if-foss - .as-if-foss
variables: variables:
CHANGES_FILE: tmp/changed_foss_files.txt
MATCHED_TESTS_FILE: tmp/matching_foss_tests.txt MATCHED_TESTS_FILE: tmp/matching_foss_tests.txt
before_script: before_script:
- '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb' - '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb'
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'gitlab'
gitlab_token = ENV.fetch('DANGER_GITLAB_API_TOKEN', '')
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')
output_file = ARGV.shift
Gitlab.configure do |config|
config.endpoint = gitlab_endpoint
config.private_token = gitlab_token
end
mr_changes = Gitlab.merge_request_changes(mr_project_path, mr_iid)
file_changes = mr_changes.changes.map { |change| change['new_path'] }
File.write(output_file, file_changes.join(' '))
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require 'gitlab'
require 'test_file_finder' require 'test_file_finder'
gitlab_token = ENV.fetch('DANGER_GITLAB_API_TOKEN', '') changes = ARGV.shift
gitlab_endpoint = ENV.fetch('CI_API_V4_URL')
Gitlab.configure do |config|
config.endpoint = gitlab_endpoint
config.private_token = gitlab_token
end
output_file = ARGV.shift output_file = ARGV.shift
mr_project_path = ENV.fetch('CI_MERGE_REQUEST_PROJECT_PATH') changed_files = File.read(changes).split(' ')
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'] }
tff = TestFileFinder::FileFinder.new(paths: changed_files).tap do |file_finder| tff = TestFileFinder::FileFinder.new(paths: changed_files).tap do |file_finder|
file_finder.use TestFileFinder::MappingStrategies::PatternMatching.load('tests.yml') file_finder.use TestFileFinder::MappingStrategies::PatternMatching.load('tests.yml')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment