diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 06:07:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-01 06:07:27 +0000 |
commit | 510bc67dd2222ef511c08aff145cce2317d280df (patch) | |
tree | c5c60b0e824631ee576d0e15ebbf293341f53158 /scripts | |
parent | ed0dc960f6e0ec6d8e3de6925129b8db76647f4d (diff) | |
download | gitlab-ce-510bc67dd2222ef511c08aff145cce2317d280df.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/db_tasks | 21 | ||||
-rw-r--r-- | scripts/prepare_build.sh | 10 | ||||
-rw-r--r-- | scripts/rspec_helpers.sh | 10 | ||||
-rwxr-xr-x | scripts/verify-tff-mapping | 4 |
4 files changed, 30 insertions, 15 deletions
diff --git a/scripts/db_tasks b/scripts/db_tasks index 56c2eefef68..c3b7bb84355 100755 --- a/scripts/db_tasks +++ b/scripts/db_tasks @@ -1,12 +1,17 @@ -#!/bin/bash +#!/usr/bin/env ruby +# frozen_string_literal: true -root_path="$(cd "$(dirname "$0")/.." || exit ; pwd -P)" -task=$1 +require 'yaml' -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="${task}:main" -fi +task = ARGV.shift +raise ArgumentError, 'You need to pass a task name!' unless task -eval "bundle exec rake ${task} ${*}" +task = "${task}:main" unless database_config.one? +cmd = ['bundle', 'exec', 'rake', task, *ARGV] + +puts "Running: `#{cmd.join(' ')}`" + +system(*cmd) diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index d68432d9ec0..500e61ab76a 100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -17,10 +17,12 @@ else cp config/database.yml.postgresql config/database.yml fi -# Remove Geo database setting if `ee/` directory does not exist. When it does -# not exist, it runs the GitLab test suite "as if FOSS", meaning the jobs run -# in the context of gitlab-org/gitlab-foss where the Geo is not available. -if [ ! -d "ee/" ] ; then +# Set up Geo database if the job name matches `rspec-ee` or `geo`. +# Since Geo is an EE feature, we shouldn't set it up for non-EE tests. +if [[ "${CI_JOB_NAME}" =~ "rspec-ee" ]] || [[ "${CI_JOB_NAME}" =~ "geo" ]]; then + echoinfo "Geo DB will be set up." +else + echoinfo "Geo DB won't be set up." sed -i '/geo:/,/^$/d' config/database.yml fi diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh index 5845a6e3f25..5b2c84059ee 100644 --- a/scripts/rspec_helpers.sh +++ b/scripts/rspec_helpers.sh @@ -351,10 +351,18 @@ function filter_rspec_matched_foss_tests() { local matching_tests_file="${1}" 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}" } +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() { local pattern="" diff --git a/scripts/verify-tff-mapping b/scripts/verify-tff-mapping index 08d9d7a33fd..a9470337761 100755 --- a/scripts/verify-tff-mapping +++ b/scripts/verify-tff-mapping @@ -127,13 +127,13 @@ tests = [ { explanation: 'FOSS factory should map to factories spec', 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', source: 'ee/spec/factories/users.rb', - expected: ['spec/models/factories_spec.rb'] + expected: ['ee/spec/models/factories_spec.rb'] }, { |