Commit 7f775275 authored by Albert Salim's avatar Albert Salim

Add job to check for ee ruby code in foss

This job runs in gitlab MR pipelines when
the pipeline is a pipeline for merged result.

It runs as if foss, without ee/ directory.
It detects ruby foss files changed and runs matching
rspec test files to detect any EE dependency
that might exist in FOSS.
parent 09ad296e
......@@ -92,3 +92,4 @@ webpack-dev-server.json
/.nvimrc
.solargraph.yml
apollo.config.js
matching_foss_tests.txt
......@@ -324,3 +324,26 @@ db:rollback geo:
- bundle exec rake geo:db:migrate
# EE: default refs (MRs, master, schedules) jobs #
##################################################
##################################################
# EE: merged result MR pipelines
rspec verify-no-ee-in-foss:
extends:
- .rspec-base
- .as-if-foss
- .rails:rules:ee-only
- .use-pg11
script:
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- git fetch origin $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- run_timed_command "scripts/gitaly-test-build"
- run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh
- scripts/find_foss_tests matching_foss_tests.txt
- rspec_simple_job "--tag ~quarantine --tag ~geo --tag ~level:migration $(cat matching_foss_tests.txt)"
artifacts:
expire_in: 7d
paths:
- matching_foss_tests.txt
# EE: merged result MR pipelines
##################################################
#!/usr/bin/env ruby
require_relative '../lib/gitlab/popen'
require_relative '../lib/quality/test_file_finder'
output_file = ARGV.shift
source = ENV.fetch('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME')
target = ENV.fetch('CI_MERGE_REQUEST_TARGET_BRANCH_NAME')
git_diff = Gitlab::Popen.popen_with_detail(%w[git diff --name-only] + ["origin/#{target}...origin/#{source}"])
unless git_diff.status.success?
warn "**** #{git_diff.cmd.join(' ')} had the following error(s):"
warn git_diff.stderr
exit git_diff.status.exitstatus
end
changed_files = git_diff.stdout.split("\n")
tests_to_run = changed_files.flat_map do |file|
test_files = Quality::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(' '))
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