Skip to content
代码片段 群组 项目
未验证 提交 54a1a8d3 编辑于 作者: Rémy Coutable's avatar Rémy Coutable
浏览文件

ci: Only set up Geo database for the 'rspec-ee' jobs


Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
上级 373f088e
No related branches found
No related tags found
无相关合并请求
...@@ -150,8 +150,9 @@ variables: ...@@ -150,8 +150,9 @@ variables:
RSPEC_FOSS_IMPACT_PIPELINE_YML: rspec-foss-impact-pipeline.yml RSPEC_FOSS_IMPACT_PIPELINE_YML: rspec-foss-impact-pipeline.yml
RSPEC_LAST_RUN_RESULTS_FILE: rspec/rspec_last_run_results.txt RSPEC_LAST_RUN_RESULTS_FILE: rspec/rspec_last_run_results.txt
RSPEC_MATCHING_JS_FILES_PATH: rspec/js_matching_files.txt RSPEC_MATCHING_JS_FILES_PATH: rspec/js_matching_files.txt
RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt
RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt
RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt
RSPEC_MATCHING_TESTS_EE_PATH: rspec/matching_tests-ee.txt
RSPEC_PACKED_TESTS_MAPPING_PATH: crystalball/packed-mapping.json RSPEC_PACKED_TESTS_MAPPING_PATH: crystalball/packed-mapping.json
RSPEC_PROFILING_FOLDER_PATH: rspec/profiling RSPEC_PROFILING_FOLDER_PATH: rspec/profiling
RSPEC_TESTS_MAPPING_PATH: crystalball/mapping.json RSPEC_TESTS_MAPPING_PATH: crystalball/mapping.json
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
.run-dev-fixtures-script: &run-dev-fixtures-script .run-dev-fixtures-script: &run-dev-fixtures-script
- run_timed_command "scripts/gitaly-test-spawn" - run_timed_command "scripts/gitaly-test-spawn"
- run_timed_command "RAILS_ENV=test bundle exec rake db:seed_fu" - run_timed_command "bundle exec rake db:seed_fu"
run-dev-fixtures: run-dev-fixtures:
extends: extends:
......
...@@ -794,20 +794,33 @@ rspec-ee system pg13: ...@@ -794,20 +794,33 @@ rspec-ee system pg13:
################################################## ##################################################
# EE: Canonical MR pipelines # EE: Canonical MR pipelines
rspec fail-fast: .rspec-fail-fast:
extends: extends:
- .rspec-ee-base-pg12 # This job also runs EE spec which needs elasticsearch
- .rails:rules:rspec fail-fast - .rails:rules:rspec fail-fast
stage: test stage: test
needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets", "detect-tests"] needs: ["setup-test-env", "retrieve-tests-metadata", "compile-test-assets", "detect-tests"]
script: script:
- !reference [.base-script, script] - !reference [.base-script, script]
- rspec_fail_fast "${RSPEC_MATCHING_TESTS_PATH}" "--tag ~quarantine --tag ~zoekt" - rspec_fail_fast "${MATCHING_TESTS_PATH}" "--tag ~quarantine --tag ~zoekt"
artifacts: artifacts:
expire_in: 7d expire_in: 7d
paths: paths:
- tmp/capybara/ - tmp/capybara/
rspec fail-fast:
extends:
- .rspec-fail-fast
- .rspec-base-pg12
variables:
MATCHING_TESTS_PATH: "${RSPEC_MATCHING_TESTS_FOSS_PATH}"
rspec-ee fail-fast:
extends:
- .rspec-fail-fast
- .rspec-base-pg12
variables:
MATCHING_TESTS_PATH: "${RSPEC_MATCHING_TESTS_EE_PATH}"
rspec-foss-impact:pipeline-generate: rspec-foss-impact:pipeline-generate:
extends: extends:
- .rails:rules:rspec-foss-impact - .rails:rules:rspec-foss-impact
......
...@@ -137,10 +137,11 @@ detect-tests: ...@@ -137,10 +137,11 @@ detect-tests:
tooling/bin/find_tests ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_TESTS_PATH}; tooling/bin/find_tests ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_TESTS_PATH};
tooling/bin/find_changes ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_TESTS_PATH} ${FRONTEND_FIXTURES_MAPPING_PATH}; tooling/bin/find_changes ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_TESTS_PATH} ${FRONTEND_FIXTURES_MAPPING_PATH};
filter_rspec_matched_foss_tests ${RSPEC_MATCHING_TESTS_PATH} ${RSPEC_MATCHING_TESTS_FOSS_PATH}; filter_rspec_matched_foss_tests ${RSPEC_MATCHING_TESTS_PATH} ${RSPEC_MATCHING_TESTS_FOSS_PATH};
filter_rspec_matched_ee_tests ${RSPEC_MATCHING_TESTS_PATH} ${RSPEC_MATCHING_TESTS_EE_PATH};
tooling/bin/view_to_js_mappings ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_JS_FILES_PATH}; tooling/bin/view_to_js_mappings ${RSPEC_CHANGED_FILES_PATH} ${RSPEC_MATCHING_JS_FILES_PATH};
echoinfo "Changed files: $(cat $RSPEC_CHANGED_FILES_PATH)"; echoinfo "Changed files: $(cat $RSPEC_CHANGED_FILES_PATH)";
echoinfo "Related RSpec tests: $(cat $RSPEC_MATCHING_TESTS_PATH)";
echoinfo "Related FOSS RSpec tests: $(cat $RSPEC_MATCHING_TESTS_FOSS_PATH)"; echoinfo "Related FOSS RSpec tests: $(cat $RSPEC_MATCHING_TESTS_FOSS_PATH)";
echoinfo "Related EE RSpec tests: $(cat $RSPEC_MATCHING_TESTS_EE_PATH)";
echoinfo "Related JS files: $(cat $RSPEC_MATCHING_JS_FILES_PATH)"; echoinfo "Related JS files: $(cat $RSPEC_MATCHING_JS_FILES_PATH)";
fi fi
artifacts: artifacts:
...@@ -149,8 +150,9 @@ detect-tests: ...@@ -149,8 +150,9 @@ detect-tests:
- ${FRONTEND_FIXTURES_MAPPING_PATH} - ${FRONTEND_FIXTURES_MAPPING_PATH}
- ${RSPEC_CHANGED_FILES_PATH} - ${RSPEC_CHANGED_FILES_PATH}
- ${RSPEC_MATCHING_JS_FILES_PATH} - ${RSPEC_MATCHING_JS_FILES_PATH}
- ${RSPEC_MATCHING_TESTS_FOSS_PATH}
- ${RSPEC_MATCHING_TESTS_PATH} - ${RSPEC_MATCHING_TESTS_PATH}
- ${RSPEC_MATCHING_TESTS_FOSS_PATH}
- ${RSPEC_MATCHING_TESTS_EE_PATH}
detect-previous-failed-tests: detect-previous-failed-tests:
extends: extends:
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
require 'spec_helper' require 'spec_helper'
# We only test factories in EE as `FactoryBot.factories` include both FOSS and EE factories there.
# Otherwise, we'd test EE factories even in `rspec` jobs which are supposed to run only FOSS tests.
# It should be fine since FOSS is a subset of EE anyway, so if this test file passes on EE, it means
# FOSS factories are valid (and FOSS doesn't **add** anything to EE so we're good).
# `:saas` is used to test `gitlab_subscription` factory. # `:saas` is used to test `gitlab_subscription` factory.
# It's not available on FOSS but also this very factory is not. # It's not available on FOSS but also this very factory is not.
RSpec.describe 'factories', :saas, :with_license, feature_category: :tooling do RSpec.describe 'factories', :saas, :with_license, feature_category: :tooling do
......
#!/bin/bash #!/usr/bin/env ruby
# frozen_string_literal: true
root_path="$(cd "$(dirname "$0")/.." || exit ; pwd -P)" require 'yaml'
task=$1
shift rails_env = ENV.fetch('RAILS_ENV')
database_config = YAML.load_file(File.join(File.expand_path('..', __dir__), 'config', 'database.yml'))[rails_env]
if [[ -d "${root_path}/ee/" || "${DECOMPOSED_DB}" == "true" ]]; then task = ARGV.shift
task="${task}:main" raise ArgumentError, 'You need to pass a task name!' unless task
fi
eval "bundle exec rake ${task} ${*}" task = "${task}:main" unless database_config.one?
cmd = ['bundle', 'exec', 'rake', task, *ARGV]
puts "Running: `#{cmd.join(' ')}`"
system(*cmd)
...@@ -17,10 +17,12 @@ else ...@@ -17,10 +17,12 @@ else
cp config/database.yml.postgresql config/database.yml cp config/database.yml.postgresql config/database.yml
fi fi
# Remove Geo database setting if `ee/` directory does not exist. When it does # Set up Geo database if the job name matches `rspec-ee` or `geo`.
# not exist, it runs the GitLab test suite "as if FOSS", meaning the jobs run # Since Geo is an EE feature, we shouldn't set it up for non-EE tests.
# in the context of gitlab-org/gitlab-foss where the Geo is not available. if [[ "${CI_JOB_NAME}" =~ "rspec-ee" ]] || [[ "${CI_JOB_NAME}" =~ "geo" ]]; then
if [ ! -d "ee/" ] ; then echoinfo "Geo DB will be set up."
else
echoinfo "Geo DB won't be set up."
sed -i '/geo:/,/^$/d' config/database.yml sed -i '/geo:/,/^$/d' config/database.yml
fi fi
......
...@@ -351,10 +351,18 @@ function filter_rspec_matched_foss_tests() { ...@@ -351,10 +351,18 @@ function filter_rspec_matched_foss_tests() {
local matching_tests_file="${1}" local matching_tests_file="${1}"
local foss_matching_tests_file="${2}" local foss_matching_tests_file="${2}"
# Keep only files that exists (i.e. exclude EE speficic files) # Keep only FOSS files that exists
cat ${matching_tests_file} | ruby -e 'puts $stdin.read.split(" ").select { |f| f.start_with?("spec/") && File.exist?(f) }.join(" ")' > "${foss_matching_tests_file}" cat ${matching_tests_file} | ruby -e 'puts $stdin.read.split(" ").select { |f| f.start_with?("spec/") && File.exist?(f) }.join(" ")' > "${foss_matching_tests_file}"
} }
function filter_rspec_matched_ee_tests() {
local matching_tests_file="${1}"
local ee_matching_tests_file="${2}"
# Keep only EE files that exists
cat ${matching_tests_file} | ruby -e 'puts $stdin.read.split(" ").select { |f| f.start_with?("ee/spec/") && File.exist?(f) }.join(" ")' > "${ee_matching_tests_file}"
}
function generate_frontend_fixtures_mapping() { function generate_frontend_fixtures_mapping() {
local pattern="" local pattern=""
......
...@@ -127,13 +127,13 @@ tests = [ ...@@ -127,13 +127,13 @@ tests = [
{ {
explanation: 'FOSS factory should map to factories spec', explanation: 'FOSS factory should map to factories spec',
source: 'spec/factories/users.rb', source: 'spec/factories/users.rb',
expected: ['spec/models/factories_spec.rb'] expected: ['ee/spec/models/factories_spec.rb']
}, },
{ {
explanation: 'EE factory should map to factories spec', explanation: 'EE factory should map to factories spec',
source: 'ee/spec/factories/users.rb', source: 'ee/spec/factories/users.rb',
expected: ['spec/models/factories_spec.rb'] expected: ['ee/spec/models/factories_spec.rb']
}, },
{ {
......
...@@ -63,7 +63,7 @@ mapping: ...@@ -63,7 +63,7 @@ mapping:
# EE/FOSS factory should map to factories spec # EE/FOSS factory should map to factories spec
- source: (ee/)?spec/factories/.+\.rb - source: (ee/)?spec/factories/.+\.rb
test: spec/models/factories_spec.rb test: ee/spec/models/factories_spec.rb
# Whats New should map to its respective spec # Whats New should map to its respective spec
- source: data/whats_new/\w*.yml - source: data/whats_new/\w*.yml
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册