Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /scripts
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'scripts')
-rw-r--r--scripts/allowed_warnings.txt8
-rwxr-xr-xscripts/build_assets_image5
-rwxr-xr-xscripts/flaky_examples/prune-old-flaky-examples17
-rwxr-xr-xscripts/frontend/po_to_json.js14
-rwxr-xr-xscripts/gitaly-test-build1
-rwxr-xr-xscripts/gitaly-test-spawn1
-rw-r--r--scripts/gitlab_component_helpers.sh4
-rwxr-xr-xscripts/lint-docs-blueprints.rb2
-rwxr-xr-xscripts/lint-vendored-gems.sh5
-rwxr-xr-xscripts/merge-simplecov1
-rw-r--r--scripts/prepare_build.sh39
-rwxr-xr-xscripts/qa/testcases-check2
-rwxr-xr-xscripts/remote_development/run-smoke-test-suite.sh32
-rwxr-xr-xscripts/review_apps/review-apps.sh21
-rw-r--r--scripts/rspec_helpers.sh128
-rwxr-xr-xscripts/setup-test-env2
-rwxr-xr-xscripts/static-analysis3
-rw-r--r--scripts/utils.sh48
-rwxr-xr-xscripts/validate_migration_timestamps2
19 files changed, 217 insertions, 118 deletions
diff --git a/scripts/allowed_warnings.txt b/scripts/allowed_warnings.txt
index cc7d14c1d3c..cb684166348 100644
--- a/scripts/allowed_warnings.txt
+++ b/scripts/allowed_warnings.txt
@@ -27,3 +27,11 @@ ruby\/2\.7\.0\/net\/protocol\.rb:66: warning: previous definition of ProtocRetry
# fine in both Ruby 2 and Ruby 3, it's unlikely it'll change again.
# This can be removed when support for Ruby 2 is dropped.
warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
+
+# As of Ruby 3.1, one-line typesafe/destructuring pattern matching via "rightward assignment" has
+# been included for multiple years with no significant negative feedback or indications of removal.
+# In the event that it is removed in a future Ruby release, the changes required to fix it are
+# isolated and minor, and will have no fundamental effect on the logic. See the section
+# "Rightward assignment pattern matching and destructuring with types" in
+# ee/lib/remote_development/README.md for more information and context.
+warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
diff --git a/scripts/build_assets_image b/scripts/build_assets_image
index 00f21e5dede..b799947f73d 100755
--- a/scripts/build_assets_image
+++ b/scripts/build_assets_image
@@ -33,6 +33,11 @@ if ([ "${CI_PROJECT_NAME}" = "gitlab" ] && [ "${FOSS_ONLY}" != "1" ]) || ([ "${C
ASSETS_IMAGE_NAME="gitlab-assets-ee"
fi
+# Generate this image for https://jihulab.com/gitlab-cn/gitlab and https://gitlab.com/gitlab-jh/jh-team/gitlab
+if ([ "${CI_PROJECT_NAMESPACE}" = "gitlab-cn" ] || [ "${CI_PROJECT_NAMESPACE}" = "gitlab-jh" ]); then
+ ASSETS_IMAGE_NAME="gitlab-assets-jh"
+fi
+
ASSETS_IMAGE_PATH="${CI_REGISTRY}/${CI_PROJECT_PATH}/${ASSETS_IMAGE_NAME}"
# Used in MR pipelines
diff --git a/scripts/flaky_examples/prune-old-flaky-examples b/scripts/flaky_examples/prune-old-flaky-examples
index a5b50a7e8ea..fc31f0f6996 100755
--- a/scripts/flaky_examples/prune-old-flaky-examples
+++ b/scripts/flaky_examples/prune-old-flaky-examples
@@ -1,15 +1,17 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-# tooling/rspec_flaky/flaky_examples_collection.rb is requiring
-# `active_support/hash_with_indifferent_access`, and we install the `activesupport`
-# gem manually on the CI
-require 'rubygems'
-require_relative '../../tooling/rspec_flaky/report'
+require 'bundler/inline'
+
+gemfile do
+ source 'https://rubygems.org'
+
+ gem 'rspec_flaky', path: 'gems/rspec_flaky'
+end
report_file = ARGV.shift
unless report_file
- puts 'usage: prune-old-flaky-specs <report-file> <new-report-file>'
+ puts "usage: #{__FILE__} <report-file> <new-report-file>"
exit 1
end
@@ -20,5 +22,6 @@ puts "Current report has #{report.size} entries."
new_report = report.prune_outdated
-puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than #{RspecFlaky::Report::OUTDATED_DAYS_THRESHOLD} days were removed."
+puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than " \
+ "#{RspecFlaky::Report::OUTDATED_DAYS_THRESHOLD} days were removed."
puts "Saved #{new_report_file}." if new_report.write(new_report_file)
diff --git a/scripts/frontend/po_to_json.js b/scripts/frontend/po_to_json.js
index fba68a61814..015a74135a2 100755
--- a/scripts/frontend/po_to_json.js
+++ b/scripts/frontend/po_to_json.js
@@ -73,18 +73,6 @@ function convertPoToJed(data, locale) {
* due to potential unnecessary double escaping.
* But for now it is here to ensure that the old and new output
* are equivalent.
- * @param str
- * @returns {string}
- */
- function escapeMsgid(str) {
- return `${str}`.replace(/([\\"])/g, '\\$1');
- }
-
- /**
- * TODO: This replacer might be unnecessary _or_ even cause bugs.
- * due to potential unnecessary double escaping.
- * But for now it is here to ensure that the old and new output
- * are equivalent.
*
* NOTE: The replacements of `\n` and `\t` need to be iterated on,
* because: In the cases where we see those chars, they:
@@ -119,7 +107,7 @@ function convertPoToJed(data, locale) {
}
*/
- acc[escapeMsgid(msgid)] = msgstr.map(escapeMsgstr);
+ acc[msgid] = msgstr.map(escapeMsgstr);
return acc;
}, {});
diff --git a/scripts/gitaly-test-build b/scripts/gitaly-test-build
index 6901593009a..cfa089b327e 100755
--- a/scripts/gitaly-test-build
+++ b/scripts/gitaly-test-build
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
+require_relative '../config/bundler_setup'
require 'fileutils'
require_relative '../spec/support/helpers/gitaly_setup'
diff --git a/scripts/gitaly-test-spawn b/scripts/gitaly-test-spawn
index 475c7715bdd..9285b561ae0 100755
--- a/scripts/gitaly-test-spawn
+++ b/scripts/gitaly-test-spawn
@@ -3,6 +3,7 @@
# This script is used both in CI and in local development 'rspec' runs.
+require_relative '../config/bundler_setup'
require_relative '../spec/support/helpers/gitaly_setup'
class GitalyTestSpawn
diff --git a/scripts/gitlab_component_helpers.sh b/scripts/gitlab_component_helpers.sh
index d7e5519f057..98688d38643 100644
--- a/scripts/gitlab_component_helpers.sh
+++ b/scripts/gitlab_component_helpers.sh
@@ -50,6 +50,10 @@ if [[ "${FOSS_ONLY:-no}" = "1" ]] || [[ "${CI_PROJECT_NAME}" = "gitlab-foss" ]];
export GITLAB_EDITION="foss"
fi
+if [[ "${CI_SERVER_HOST}" = "jihulab.com" ]]; then
+ export GITLAB_EDITION="jh"
+fi
+
export GITLAB_ASSETS_HASH="${GITLAB_ASSETS_HASH:-"NO_HASH"}"
export GITLAB_ASSETS_PACKAGE="assets-${NODE_ENV}-${GITLAB_EDITION}-${GITLAB_ASSETS_HASH}-${GITLAB_ASSETS_PACKAGE_VERSION}.tar.gz"
export GITLAB_ASSETS_PACKAGE_URL="${API_PACKAGES_BASE_URL}/assets/${NODE_ENV}-${GITLAB_EDITION}-${GITLAB_ASSETS_HASH}/${GITLAB_ASSETS_PACKAGE}"
diff --git a/scripts/lint-docs-blueprints.rb b/scripts/lint-docs-blueprints.rb
index d0a0a6a05de..f3c60a45fda 100755
--- a/scripts/lint-docs-blueprints.rb
+++ b/scripts/lint-docs-blueprints.rb
@@ -4,7 +4,7 @@
# Taken from Jekyll
# https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13
-YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m.freeze
+YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
READ_LIMIT_BYTES = 1024
require 'yaml'
diff --git a/scripts/lint-vendored-gems.sh b/scripts/lint-vendored-gems.sh
deleted file mode 100755
index ac8b837bbd1..00000000000
--- a/scripts/lint-vendored-gems.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# Rubocop doesn't have a good way to run excluded files without a separate invocation:
-# https://github.com/rubocop/rubocop/issues/6323
-find vendor/gems -name \*.gemspec | xargs bundle exec rubocop --only Gemspec/AvoidExecutingGit
diff --git a/scripts/merge-simplecov b/scripts/merge-simplecov
index 24be731549b..7db12839382 100755
--- a/scripts/merge-simplecov
+++ b/scripts/merge-simplecov
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
+require_relative '../config/bundler_setup'
require_relative '../spec/simplecov_env'
SimpleCovEnv.configure_profile
SimpleCovEnv.configure_formatter
diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh
index 536da48f07f..36fe4a010a0 100644
--- a/scripts/prepare_build.sh
+++ b/scripts/prepare_build.sh
@@ -10,43 +10,6 @@ fi
cp config/gitlab.yml.example config/gitlab.yml
sed -i 's/bin_path: \/usr\/bin\/git/bin_path: \/usr\/local\/bin\/git/' config/gitlab.yml
-if [ "$DECOMPOSED_DB" == "true" ]; then
- echo "Using decomposed database config (config/database.yml.decomposed-postgresql)"
- cp config/database.yml.decomposed-postgresql config/database.yml
-else
- echo "Using decomposed database config (config/database.yml.postgresql)"
- cp config/database.yml.postgresql config/database.yml
-
- if [ "$CI_CONNECTION_DB" != "true" ]; then
- echo "Disabling ci connection in config/database.yml"
- sed -i "/ci:$/, /geo:$/ {s|^|#|;s|# geo:| geo:|;}" config/database.yml
- fi
-fi
-
-# 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
-
-# Set up Embedding database if the job name matches `rspec-ee`
-# Since Embedding is an EE feature, we shouldn't set it up for non-EE tests.
-if [[ "${CI_JOB_NAME}" =~ "rspec-ee" ]]; then
- echoinfo "Embedding DB will be set up."
-else
- echoinfo "Embedding DB won't be set up."
- sed -i '/embedding:/,/^$/d' config/database.yml
-fi
-
-# Set user to a non-superuser to ensure we test permissions
-sed -i 's/username: root/username: gitlab/g' config/database.yml
-
-sed -i 's/localhost/postgres/g' config/database.yml
-sed -i 's/username: git/username: postgres/g' config/database.yml
-
cp config/cable.yml.example config/cable.yml
sed -i 's|url:.*$|url: redis://redis:6379|g' config/cable.yml
@@ -60,6 +23,8 @@ if [[ "$USE_REDIS_CLUSTER" != "false" ]] && [[ "$SETUP_DB" != "false" ]]; then
sed -i 's|- .*$|- redis://rediscluster:7001|g' config/redis.yml
fi
+setup_database_yml
+
if [ "$SETUP_DB" != "false" ]; then
setup_db
elif getent hosts postgres; then
diff --git a/scripts/qa/testcases-check b/scripts/qa/testcases-check
index 26098678f7c..2bc1ea2c5c7 100755
--- a/scripts/qa/testcases-check
+++ b/scripts/qa/testcases-check
@@ -3,7 +3,7 @@
require 'json'
-TESTCASE_FORMAT = %r{https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/\d+}.freeze
+TESTCASE_FORMAT = %r{https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/\d+}
testcases = []
missing_testcases = []
diff --git a/scripts/remote_development/run-smoke-test-suite.sh b/scripts/remote_development/run-smoke-test-suite.sh
index 5c1c5532a05..52e7546d47d 100755
--- a/scripts/remote_development/run-smoke-test-suite.sh
+++ b/scripts/remote_development/run-smoke-test-suite.sh
@@ -31,20 +31,27 @@ printf "${Color_Off}"
printf "${BBlue}Running Remote Development backend specs${Color_Off}\n\n"
-# NOTE: For some reason this test started causing the following spec file in the list to blow up with
-# "Failed to write to log, write log/workhorse-test.log: file already closed". Just removing
-# it for now.
-# ee/spec/graphql/api/workspace_spec.rb
-
bin/spring rspec -r spec_helper \
ee/spec/features/remote_development/workspaces_spec.rb \
ee/spec/finders/remote_development/workspaces_finder_spec.rb \
+ee/spec/graphql/api/workspace_spec.rb \
ee/spec/graphql/types/query_type_spec.rb \
ee/spec/graphql/types/remote_development/workspace_type_spec.rb \
ee/spec/graphql/types/subscription_type_spec.rb \
-ee/spec/lib/remote_development/workspaces/create/create_processor_spec.rb \
-ee/spec/lib/remote_development/workspaces/create/devfile_processor_spec.rb \
-ee/spec/lib/remote_development/workspaces/create/devfile_validator_spec.rb \
+ee/spec/lib/remote_development/agent_config/main_integration_spec.rb \
+ee/spec/lib/remote_development/unmatched_result_error_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/authorizer_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/creator_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/devfile_fetcher_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/devfile_flattener_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/editor_component_injector_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/main_integration_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/main_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/post_flatten_devfile_validator_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/pre_flatten_devfile_validator_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/project_cloner_component_injector_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/volume_component_injector_spec.rb \
+ee/spec/lib/remote_development/workspaces/create/volume_definer_spec.rb \
ee/spec/lib/remote_development/workspaces/reconcile/actual_state_calculator_spec.rb \
ee/spec/lib/remote_development/workspaces/reconcile/agent_info_parser_spec.rb \
ee/spec/lib/remote_development/workspaces/reconcile/agent_info_spec.rb \
@@ -53,19 +60,24 @@ ee/spec/lib/remote_development/workspaces/reconcile/params_parser_spec.rb \
ee/spec/lib/remote_development/workspaces/reconcile/reconcile_processor_scenarios_spec.rb \
ee/spec/lib/remote_development/workspaces/reconcile/reconcile_processor_spec.rb \
ee/spec/lib/remote_development/workspaces/states_spec.rb \
-ee/spec/lib/remote_development/workspaces/update/update_processor_spec.rb \
+ee/spec/lib/remote_development/workspaces/update/authorizer_spec.rb \
+ee/spec/lib/remote_development/workspaces/update/main_integration_spec.rb \
+ee/spec/lib/remote_development/workspaces/update/main_spec.rb \
+ee/spec/lib/remote_development/workspaces/update/updater_spec.rb \
ee/spec/models/remote_development/remote_development_agent_config_spec.rb \
ee/spec/models/remote_development/workspace_spec.rb \
ee/spec/requests/api/graphql/mutations/remote_development/workspaces/create_spec.rb \
ee/spec/requests/api/graphql/mutations/remote_development/workspaces/update_spec.rb \
ee/spec/requests/api/graphql/remote_development/current_user_workspaces_spec.rb \
-ee/spec/requests/api/graphql/remote_development/workspaces_by_ids_spec.rb \
ee/spec/requests/api/graphql/remote_development/workspace_by_id_spec.rb \
+ee/spec/requests/api/graphql/remote_development/workspaces_by_ids_spec.rb \
ee/spec/requests/api/internal/kubernetes_spec.rb \
ee/spec/services/remote_development/agent_config/update_service_spec.rb \
ee/spec/services/remote_development/workspaces/create_service_spec.rb \
ee/spec/services/remote_development/workspaces/reconcile_service_spec.rb \
ee/spec/services/remote_development/workspaces/update_service_spec.rb \
spec/graphql/types/subscription_type_spec.rb \
+spec/lib/result_spec.rb \
+spec/support_specs/matchers/result_matchers_spec.rb
printf "\n✅✅✅ ${BGreen}All Remote Development specs passed successfully!${Color_Off} ✅✅✅\n"
diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh
index 660257b042a..af6c2ec5383 100755
--- a/scripts/review_apps/review-apps.sh
+++ b/scripts/review_apps/review-apps.sh
@@ -229,11 +229,11 @@ function download_chart() {
else
echoinfo "Downloading the GitLab chart..." true
- curl --location -o gitlab.tar.bz2 "https://gitlab.com/gitlab-org/charts/gitlab/-/archive/${GITLAB_HELM_CHART_REF}/gitlab-${GITLAB_HELM_CHART_REF}.tar.bz2"
+ curl --location -o gitlab.tar.bz2 "${GITLAB_HELM_CHART_PROJECT_URL}/-/archive/${GITLAB_HELM_CHART_REF}/gitlab-${GITLAB_HELM_CHART_REF}.tar.bz2"
tar -xjf gitlab.tar.bz2
echoinfo "Adding the gitlab repo to Helm..."
- helm repo add gitlab https://charts.gitlab.io
+ helm repo add gitlab "${GITLAB_HELM_REPO_URL}"
echoinfo "Building the gitlab chart's dependencies..."
helm dependency build "gitlab-${GITLAB_HELM_CHART_REF}"
@@ -261,19 +261,20 @@ function deploy() {
local namespace="${CI_ENVIRONMENT_SLUG}"
local release="${CI_ENVIRONMENT_SLUG}"
local base_config_file_ref="${CI_DEFAULT_BRANCH}"
+
if [[ "$(base_config_changed)" == "true" ]]; then base_config_file_ref="${CI_COMMIT_SHA}"; fi
- local base_config_file="https://gitlab.com/gitlab-org/gitlab/raw/${base_config_file_ref}/scripts/review_apps/base-config.yaml"
+ local base_config_file="${GITLAB_REPO_URL}/raw/${base_config_file_ref}/scripts/review_apps/base-config.yaml"
echoinfo "Deploying ${release} to ${CI_ENVIRONMENT_URL} ..." true
- IMAGE_REPOSITORY="registry.gitlab.com/gitlab-org/build/cng-mirror"
- gitlab_toolbox_image_repository="${IMAGE_REPOSITORY}/gitlab-toolbox-ee"
- gitlab_sidekiq_image_repository="${IMAGE_REPOSITORY}/gitlab-sidekiq-ee"
- gitlab_webservice_image_repository="${IMAGE_REPOSITORY}/gitlab-webservice-ee"
+ IMAGE_REPOSITORY="${GITLAB_IMAGE_REPOSITORY}"
+ gitlab_toolbox_image_repository="${IMAGE_REPOSITORY}/gitlab-toolbox-${GITLAB_IMAGE_SUFFIX}"
+ gitlab_sidekiq_image_repository="${IMAGE_REPOSITORY}/gitlab-sidekiq-${GITLAB_IMAGE_SUFFIX}"
+ gitlab_webservice_image_repository="${IMAGE_REPOSITORY}/gitlab-webservice-${GITLAB_IMAGE_SUFFIX}"
gitlab_gitaly_image_repository="${IMAGE_REPOSITORY}/gitaly"
gitaly_image_tag=$(parse_gitaly_image_tag)
gitlab_shell_image_repository="${IMAGE_REPOSITORY}/gitlab-shell"
- gitlab_workhorse_image_repository="${IMAGE_REPOSITORY}/gitlab-workhorse-ee"
+ gitlab_workhorse_image_repository="${IMAGE_REPOSITORY}/gitlab-workhorse-${GITLAB_IMAGE_SUFFIX}"
sentry_enabled="false"
if [ -n "${REVIEW_APPS_SENTRY_DSN}" ]; then
@@ -394,7 +395,9 @@ function verify_deploy() {
mkdir -p curl-logs/
- for i in {1..60}; do # try for 5 minutes
+ # By default, try for 5 minutes, with 5 of sleep between attempts
+ local max_try_times=$((${GITLAB_VERIFY_DEPLOY_TIMEOUT_MINUTES:-5} * 60 / 5))
+ for i in {1..$max_try_times}; do
local now=$(date '+%H:%M:%S')
echo "[${now}] Verifying deployment at ${CI_ENVIRONMENT_URL}/users/sign_in"
log_name="curl-logs/${now}.log"
diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh
index 8be98cb6346..fd478cbd3ae 100644
--- a/scripts/rspec_helpers.sh
+++ b/scripts/rspec_helpers.sh
@@ -20,19 +20,19 @@ function retrieve_tests_metadata() {
}
function update_tests_metadata() {
- local rspec_flaky_folder_path="$(dirname "${FLAKY_RSPEC_SUITE_REPORT_PATH}")/"
- local knapsack_folder_path="$(dirname "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}")/"
+ local rspec_flaky_folder_path="$(dirname "${FLAKY_RSPEC_SUITE_REPORT_PATH:-unknown_folder}")/"
+ local knapsack_folder_path="$(dirname "${KNAPSACK_RSPEC_SUITE_REPORT_PATH:-unknown_folder}")/"
- echo "{}" > "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}"
+ echo "{}" > "${KNAPSACK_RSPEC_SUITE_REPORT_PATH:-unknown_file}"
- scripts/merge-reports "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" ${knapsack_folder_path}rspec*.json
+ scripts/merge-reports "${KNAPSACK_RSPEC_SUITE_REPORT_PATH:-unknown_file}" ${knapsack_folder_path:-unknown_folder}rspec*.json
export FLAKY_RSPEC_GENERATE_REPORT="true"
- scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH}" ${rspec_flaky_folder_path}all_*.json
+ scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH:-unknown_file}" ${rspec_flaky_folder_path:-unknown_folder}all_*.json
# Prune flaky tests that weren't flaky in the last 7 days, *after* updating the flaky tests detected
# in this pipeline, so that first_flaky_at for tests that are still flaky is maintained.
- scripts/flaky_examples/prune-old-flaky-examples "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
+ scripts/flaky_examples/prune-old-flaky-examples "${FLAKY_RSPEC_SUITE_REPORT_PATH:-unknown_file}"
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
if [[ -n "$RSPEC_PROFILING_PGSSLKEY" ]]; then
@@ -70,10 +70,10 @@ function update_tests_mapping() {
return 0
fi
- scripts/generate-test-mapping "${RSPEC_TESTS_MAPPING_PATH}" crystalball/rspec*.yml
- scripts/pack-test-mapping "${RSPEC_TESTS_MAPPING_PATH}" "${RSPEC_PACKED_TESTS_MAPPING_PATH}"
- gzip "${RSPEC_PACKED_TESTS_MAPPING_PATH}"
- rm -f crystalball/rspec*.yml "${RSPEC_PACKED_TESTS_MAPPING_PATH}"
+ scripts/generate-test-mapping "${RSPEC_TESTS_MAPPING_PATH:-unknown_file}" crystalball/rspec*.yml
+ scripts/pack-test-mapping "${RSPEC_TESTS_MAPPING_PATH:-unknown_file}" "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
+ gzip "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
+ rm -f crystalball/rspec*.yml "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
}
function crystalball_rspec_data_exists() {
@@ -123,7 +123,46 @@ function rspec_simple_job_with_retry () {
function rspec_db_library_code() {
local db_files="spec/lib/gitlab/database/"
- rspec_simple_job_with_retry "-- ${db_files}"
+ rspec_simple_job_with_retry "--tag ~click_house -- ${db_files}"
+}
+
+# Below is the list of options (https://linuxcommand.org/lc3_man_pages/seth.html)
+#
+# allexport same as -a
+# braceexpand same as -B
+# emacs use an emacs-style line editing interface
+# errexit same as -e
+# errtrace same as -E
+# functrace same as -T
+# hashall same as -h
+# histexpand same as -H
+# history enable command history
+# ignoreeof the shell will not exit upon reading EOF
+# interactive-comments
+# allow comments to appear in interactive commands
+# keyword same as -k
+# monitor same as -m
+# noclobber same as -C
+# noexec same as -n
+# noglob same as -f
+# nolog currently accepted but ignored
+# notify same as -b
+# nounset same as -u
+# onecmd same as -t
+# physical same as -P
+# pipefail the return value of a pipeline is the status of
+# the last command to exit with a non-zero status,
+# or zero if no command exited with a non-zero status
+# posix change the behavior of bash where the default
+# operation differs from the Posix standard to
+# match the standard
+# privileged same as -p
+# verbose same as -v
+# vi use a vi-style line editing interface
+# xtrace same as -x
+function debug_shell_options() {
+ echoinfo "Shell set options (set -o) enabled:"
+ echoinfo "$(set -o | grep 'on$')"
}
function debug_rspec_variables() {
@@ -151,21 +190,34 @@ function debug_rspec_variables() {
function handle_retry_rspec_in_new_process() {
local rspec_run_status="${1}"
+ if [[ $rspec_run_status -eq 3 ]]; then
+ echoerr "Not retrying failing examples since we failed early on purpose!"
+ exit 1
+ fi
+
if [[ $rspec_run_status -eq 2 ]]; then
echoerr "Not retrying failing examples since there were errors happening outside of the RSpec examples!"
- elif [[ $rspec_run_status -eq 1 ]]; then
- # Experiment to retry failed examples in a new RSpec process: https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/1148
- if [[ "${RETRY_FAILED_TESTS_IN_NEW_PROCESS}" == "true" ]]; then
- retry_failed_rspec_examples
- rspec_run_status=$?
- else
- echoerr "Not retrying failing examples since \$RETRY_FAILED_TESTS_IN_NEW_PROCESS != 'true'!"
+ exit 1
+ fi
+
+ if [[ $rspec_run_status -eq 1 ]]; then
+ if is_rspec_last_run_results_file_missing; then
+ exit 1
fi
+
+ local failed_examples_count=$(grep -c " failed" "${RSPEC_LAST_RUN_RESULTS_FILE}")
+ if [[ "${failed_examples_count}" -eq "${RSPEC_FAIL_FAST_THRESHOLD}" ]]; then
+ echoerr "Not retrying failing examples since we reached the maximum number of allowed test failures!"
+ exit 1
+ fi
+
+ retry_failed_rspec_examples
+ rspec_run_status=$?
else
echosuccess "No examples to retry, congrats!"
fi
- exit $rspec_run_status
+ exit "${rspec_run_status}"
}
function rspec_paralellized_job() {
@@ -222,6 +274,7 @@ function rspec_paralellized_job() {
fi
debug_rspec_variables
+ debug_shell_options
if [[ -n "${rspec_tests_mapping_enabled}" ]]; then
tooling/bin/parallel_rspec --rspec_args "$(rspec_args "${rspec_opts}")" --filter "${RSPEC_TESTS_FILTER_FILE}" || rspec_run_status=$?
@@ -237,9 +290,12 @@ function rspec_paralellized_job() {
function retry_failed_rspec_examples() {
local rspec_run_status=0
- # Sometimes the file isn't created or is empty. In that case we exit(1) ourselves, otherwise, RSpec would
- # not run any examples an exit successfully, actually hiding failed tests!
- if [[ ! -f "${RSPEC_LAST_RUN_RESULTS_FILE}" ]] || [[ ! -s "${RSPEC_LAST_RUN_RESULTS_FILE}" ]]; then
+ if [[ "${RETRY_FAILED_TESTS_IN_NEW_PROCESS}" != "true" ]]; then
+ echoerr "Not retrying failing examples since \$RETRY_FAILED_TESTS_IN_NEW_PROCESS != 'true'!"
+ exit 1
+ fi
+
+ if is_rspec_last_run_results_file_missing; then
exit 1
fi
@@ -315,7 +371,7 @@ function rspec_rerun_previous_failed_tests() {
local test_file_count_threshold=${RSPEC_PREVIOUS_FAILED_TEST_FILE_COUNT_THRESHOLD:-10}
local matching_tests_file=${1}
local rspec_opts=${2}
- local test_files="$(cat "${matching_tests_file}")"
+ local test_files="$(select_existing_files < "${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
@@ -395,14 +451,14 @@ function cleanup_individual_job_reports() {
local rspec_flaky_folder_path="$(dirname "${FLAKY_RSPEC_SUITE_REPORT_PATH}")/"
local knapsack_folder_path="$(dirname "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}")/"
- rm -rf ${knapsack_folder_path}rspec*.json \
- ${rspec_flaky_folder_path}all_*.json \
- ${rspec_flaky_folder_path}new_*.json \
- ${rspec_flaky_folder_path}skipped_flaky_tests_*_report.txt \
- ${rspec_flaky_folder_path}retried_tests_*_report.txt \
- ${RSPEC_LAST_RUN_RESULTS_FILE} \
- ${RSPEC_PROFILING_FOLDER_PATH}/**/*
- rmdir ${RSPEC_PROFILING_FOLDER_PATH} || true
+ rm -rf ${knapsack_folder_path:-unknown_folder}rspec*.json \
+ ${rspec_flaky_folder_path:-unknown_folder}all_*.json \
+ ${rspec_flaky_folder_path:-unknown_folder}new_*.json \
+ ${rspec_flaky_folder_path:-unknown_folder}skipped_flaky_tests_*_report.txt \
+ ${rspec_flaky_folder_path:-unknown_folder}retried_tests_*_report.txt \
+ ${RSPEC_LAST_RUN_RESULTS_FILE:-unknown_folder} \
+ ${RSPEC_PROFILING_FOLDER_PATH:-unknown_folder}/**/*
+ rmdir ${RSPEC_PROFILING_FOLDER_PAT:-unknown_folder} || true
}
function generate_flaky_tests_reports() {
@@ -417,3 +473,13 @@ function generate_flaky_tests_reports() {
cleanup_individual_job_reports
}
+
+function is_rspec_last_run_results_file_missing() {
+ # Sometimes the file isn't created or is empty.
+ if [[ ! -f "${RSPEC_LAST_RUN_RESULTS_FILE}" ]] || [[ ! -s "${RSPEC_LAST_RUN_RESULTS_FILE}" ]]; then
+ echoerr "The file set inside RSPEC_LAST_RUN_RESULTS_FILE ENV variable does not exist or is empty. As a result, we won't retry failed specs."
+ return 0
+ else
+ return 1
+ fi
+}
diff --git a/scripts/setup-test-env b/scripts/setup-test-env
index ae00b569ce3..1c39483bb7a 100755
--- a/scripts/setup-test-env
+++ b/scripts/setup-test-env
@@ -25,8 +25,8 @@ require_relative '../lib/system_check/helpers'
require 'omniauth'
require 'omniauth-github'
require 'etc'
+require 'gitlab/utils/all'
require_relative '../lib/gitlab/access'
-require_relative '../lib/gitlab/utils'
unless defined?(License)
# This is needed to allow use of `Gitlab::ImportSources.values` in `1_settings.rb`.
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 0d03dd42c73..41583166e04 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -51,8 +51,7 @@ class StaticAnalysis
Task.new(%w[yarn run block-dependencies], 1),
Task.new(%w[yarn run check-dependencies], 1),
Task.new(%w[scripts/lint-rugged], 1),
- Task.new(%w[scripts/gemfile_lock_changed.sh], 1),
- Task.new(%w[scripts/lint-vendored-gems.sh], 1)
+ Task.new(%w[scripts/gemfile_lock_changed.sh], 1)
].compact.freeze
def run_tasks!(options = {})
diff --git a/scripts/utils.sh b/scripts/utils.sh
index edfcf0f2dac..800b81f1dea 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -127,6 +127,50 @@ function assets_compile_script() {
section_end "assets-compile"
}
+function setup_database_yml() {
+ if [ "$DECOMPOSED_DB" == "true" ]; then
+ if [ "$CLUSTERWIDE_DB" == "true" ]; then
+ echo "Using decomposed database config, containing clusterwide connection (config/database.yml.decomposed-clusterwide-postgresql)"
+ cp config/database.yml.decomposed-clusterwide-postgresql config/database.yml
+ else
+ echo "Using decomposed database config (config/database.yml.decomposed-postgresql)"
+ cp config/database.yml.decomposed-postgresql config/database.yml
+ fi
+ else
+ echo "Using two connections, single database config (config/database.yml.postgresql)"
+ cp config/database.yml.postgresql config/database.yml
+
+ if [ "$CI_CONNECTION_DB" != "true" ]; then
+ echo "Disabling ci connection in config/database.yml"
+ sed -i "/ci:$/, /geo:$/ {s|^|#|;s|# geo:| geo:|;}" config/database.yml
+ fi
+ fi
+
+ # 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
+
+ # Set up Embedding database if the job name matches `rspec-ee`
+ # Since Embedding is an EE feature, we shouldn't set it up for non-EE tests.
+ if [[ "${CI_JOB_NAME}" =~ "rspec-ee" ]]; then
+ echoinfo "Embedding DB will be set up."
+ else
+ echoinfo "Embedding DB won't be set up."
+ sed -i '/embedding:/,/^$/d' config/database.yml
+ fi
+
+ # Set user to a non-superuser to ensure we test permissions
+ sed -i 's/username: root/username: gitlab/g' config/database.yml
+
+ sed -i 's/localhost/postgres/g' config/database.yml
+ sed -i 's/username: git/username: postgres/g' config/database.yml
+}
+
function setup_db_user_only() {
source scripts/create_postgres_user.sh
}
@@ -162,6 +206,10 @@ function install_junit_merge_gem() {
run_timed_command "gem install junit_merge --no-document --version 0.1.2"
}
+function select_existing_files() {
+ ruby -e 'print $stdin.read.split(" ").select { |f| File.exist?(f) }.join(" ")'
+}
+
function fail_on_warnings() {
local cmd="$*"
local warning_file
diff --git a/scripts/validate_migration_timestamps b/scripts/validate_migration_timestamps
index d3722e7a4af..affcd2ad0a2 100755
--- a/scripts/validate_migration_timestamps
+++ b/scripts/validate_migration_timestamps
@@ -6,7 +6,7 @@ require 'time'
MIGRATION_DIRS = %w[db/migrate db/post_migrate].freeze
VERSION_DIGITS = 14
-MIGRATION_TIMESTAMP_REGEX = /\A(?<version>\d{#{VERSION_DIGITS}})_/.freeze
+MIGRATION_TIMESTAMP_REGEX = /\A(?<version>\d{#{VERSION_DIGITS}})_/
maximum_timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i