Commit bc4eef17 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '220883-suggest-to-run-run-as-if-foss-when-too-many-test-files-detected-in-rspec-foss-impact' into 'master'

Suggest to run RUN AS-IF-FOSS when too many test files detected in rspec foss-impact

Closes #220883

See merge request gitlab-org/gitlab!34361
parents 32d6426b 1960fb7c
...@@ -355,7 +355,7 @@ rspec foss-impact: ...@@ -355,7 +355,7 @@ rspec foss-impact:
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- source scripts/rspec_helpers.sh - source scripts/rspec_helpers.sh
- tooling/bin/find_foss_tests tmp/matching_foss_tests.txt - tooling/bin/find_foss_tests tmp/matching_foss_tests.txt
- 'if [[ -n "$(cat tmp/matching_foss_tests.txt)" ]]; then rspec_simple_job "--tag ~quarantine --tag ~geo --tag ~level:migration $(cat tmp/matching_foss_tests.txt)"; fi' - rspec_matched_tests tmp/matching_foss_tests.txt "--tag ~quarantine --tag ~geo --tag ~level:migration"
artifacts: artifacts:
expire_in: 7d expire_in: 7d
paths: paths:
......
...@@ -422,6 +422,8 @@ ...@@ -422,6 +422,8 @@
rules: rules:
- <<: *if-not-ee - <<: *if-not-ee
when: never when: never
- <<: *if-merge-request-title-as-if-foss
when: never
- <<: *if-security-merge-request - <<: *if-security-merge-request
changes: *code-backstage-patterns changes: *code-backstage-patterns
- <<: *if-dot-com-gitlab-org-merge-request - <<: *if-dot-com-gitlab-org-merge-request
......
...@@ -110,3 +110,27 @@ function rspec_paralellized_job() { ...@@ -110,3 +110,27 @@ function rspec_paralellized_job() {
date date
} }
function rspec_matched_tests() {
local test_file_count_threshold=20
local matching_tests_file=${1}
local rspec_opts=${2}
local test_files="$(cat "${matching_tests_file}")"
local test_file_count=$(wc -w "${matching_tests_file}" | awk {'print $1'})
if [[ "${test_file_count}" -gt "${test_file_count_threshold}" ]]; then
echo "There are more than ${test_file_count_threshold} FOSS test files matched,"
echo "which would take too long to run in this job."
echo "To reduce the likelihood of breaking FOSS pipelines,"
echo "please add [RUN AS-IF-FOSS] to the MR title and restart the pipeline."
echo "This would run all as-if-foss jobs in this merge request"
echo "and remove this job from the pipeline."
exit 1
fi
if [[ -n $test_files ]]; then
rspec_simple_job "${rspec_opts} ${test_files}"
else
echo "No test files to run"
fi
}
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