summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /scripts
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gitaly-test-build2
-rwxr-xr-xscripts/gitaly-test-spawn14
-rwxr-xr-xscripts/insert-rspec-profiling-data2
-rwxr-xr-xscripts/lint-doc.sh2
-rwxr-xr-xscripts/setup/find-jh-branch.rb102
-rwxr-xr-xscripts/undercoverage2
-rwxr-xr-xscripts/used-feature-flags6
-rw-r--r--scripts/utils.sh2
8 files changed, 113 insertions, 19 deletions
diff --git a/scripts/gitaly-test-build b/scripts/gitaly-test-build
index e6afadccc7e..adc9b56ca4f 100755
--- a/scripts/gitaly-test-build
+++ b/scripts/gitaly-test-build
@@ -13,8 +13,6 @@ class GitalyTestBuild
include GitalySetup
def run
- set_bundler_config
-
# If we have the binaries from the cache, we can skip building them again
if File.exist?(tmp_tests_gitaly_bin_dir)
GitalySetup::LOGGER.debug "Gitaly binary already built. Skip building...\n"
diff --git a/scripts/gitaly-test-spawn b/scripts/gitaly-test-spawn
index e7e25a217b2..eed79f75224 100755
--- a/scripts/gitaly-test-spawn
+++ b/scripts/gitaly-test-spawn
@@ -9,17 +9,11 @@ class GitalyTestSpawn
include GitalySetup
def run
- set_bundler_config
- install_gitaly_gems if ENV['CI']
- check_gitaly_config!
+ install_gitaly_gems
- # # Uncomment line below to see all gitaly logs merged into CI trace
- # spawn('sleep 1; tail -f log/gitaly-test.log')
-
- # In local development this pid file is used by rspec.
- IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), start_gitaly)
- IO.write(File.expand_path('../tmp/tests/gitaly2.pid', __dir__), start_gitaly2)
- IO.write(File.expand_path('../tmp/tests/praefect.pid', __dir__), start_praefect)
+ # Optionally specify the path to the gitaly config toml as first argument.
+ # Used by workhorse in test.
+ spawn_gitaly(ARGV[0])
end
end
diff --git a/scripts/insert-rspec-profiling-data b/scripts/insert-rspec-profiling-data
index b2011858558..be25972644c 100755
--- a/scripts/insert-rspec-profiling-data
+++ b/scripts/insert-rspec-profiling-data
@@ -12,7 +12,7 @@ module RspecProfiling
# This disables the automatic creation of the database and
# table. In the future, we may want a way to specify the host of
# the database to connect so that we can call #install.
- Result.establish_connection(results_url)
+ Result.establish_connection(results_url) # rubocop: disable Database/EstablishConnection
end
def results_url
diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh
index 1698d724fd2..a036b3f7342 100755
--- a/scripts/lint-doc.sh
+++ b/scripts/lint-doc.sh
@@ -128,7 +128,7 @@ function run_locally_or_in_docker() {
$cmd $args
elif hash docker 2>/dev/null
then
- docker run -t -v ${PWD}:/gitlab -w /gitlab --rm registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.14-vale-2.12.0-markdownlint-0.29.0 ${cmd} ${args}
+ docker run -t -v ${PWD}:/gitlab -w /gitlab --rm registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.15-vale-2.14.0-markdownlint-0.30.0 ${cmd} ${args}
else
echo
echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2
diff --git a/scripts/setup/find-jh-branch.rb b/scripts/setup/find-jh-branch.rb
new file mode 100755
index 00000000000..812e1c210f4
--- /dev/null
+++ b/scripts/setup/find-jh-branch.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+# In spec/scripts/setup/find_jh_branch_spec.rb we completely stub it
+require 'gitlab' unless Object.const_defined?(:Gitlab)
+
+require_relative '../api/default_options'
+
+class FindJhBranch
+ JH_DEFAULT_BRANCH = 'main-jh'
+ JH_PROJECT_PATH = 'gitlab-jh/gitlab'
+ BranchNotFound = Class.new(RuntimeError)
+
+ def run
+ return JH_DEFAULT_BRANCH unless merge_request?
+
+ jh_merge_request_ref_name ||
+ default_branch_merge_request_ref_name ||
+ stable_branch_merge_request_ref_name ||
+ default_branch_for_non_stable
+ end
+
+ private
+
+ def merge_request?
+ !!merge_request_id
+ end
+
+ def jh_merge_request_ref_name
+ branch_exist?(JH_PROJECT_PATH, jh_ref_name) && jh_ref_name
+ end
+
+ def default_branch_merge_request_ref_name
+ target_default_branch? && JH_DEFAULT_BRANCH
+ end
+
+ def stable_branch_merge_request_ref_name
+ target_stable_branch? && begin
+ jh_stable_branch_name = merge_request.target_branch.sub(/\-ee\z/, '-jh')
+
+ branch_exist?(JH_PROJECT_PATH, jh_stable_branch_name) &&
+ jh_stable_branch_name
+ end
+ end
+
+ def default_branch_for_non_stable
+ if target_stable_branch?
+ raise(BranchNotFound, "Cannot find a suitable JH branch")
+ else
+ JH_DEFAULT_BRANCH
+ end
+ end
+
+ def branch_exist?(project_path, branch_name)
+ !!gitlab.branch(project_path, branch_name)
+ rescue Gitlab::Error::NotFound
+ false
+ end
+
+ def target_default_branch?
+ merge_request.target_branch == default_branch
+ end
+
+ def target_stable_branch?
+ merge_request.target_branch.match?(/\A(?:\d+\-)+\d+\-stable\-ee\z/)
+ end
+
+ def ref_name
+ ENV['CI_COMMIT_REF_NAME']
+ end
+
+ def default_branch
+ ENV['CI_DEFAULT_BRANCH']
+ end
+
+ def merge_request_project_id
+ ENV['CI_MERGE_REQUEST_PROJECT_ID']
+ end
+
+ def merge_request_id
+ ENV['CI_MERGE_REQUEST_IID']
+ end
+
+ def jh_ref_name
+ "#{ref_name}-jh"
+ end
+
+ def merge_request
+ @merge_request ||= gitlab.merge_request(merge_request_project_id, merge_request_id)
+ end
+
+ def gitlab
+ @gitlab ||= Gitlab.client(
+ endpoint: API::DEFAULT_OPTIONS[:endpoint],
+ private_token: API::DEFAULT_OPTIONS[:api_token] || ''
+ )
+ end
+end
+
+if $0 == __FILE__
+ puts FindJhBranch.new.run
+end
diff --git a/scripts/undercoverage b/scripts/undercoverage
index cc7415d67ac..d6e6197911e 100755
--- a/scripts/undercoverage
+++ b/scripts/undercoverage
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
-bundle exec undercover -c "${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$(git merge-base origin/master HEAD)}"
+bundle exec undercover -c "${1:-$(git merge-base origin/master HEAD)}"
diff --git a/scripts/used-feature-flags b/scripts/used-feature-flags
index 552adbfbd9f..89ea99c6984 100755
--- a/scripts/used-feature-flags
+++ b/scripts/used-feature-flags
@@ -3,7 +3,7 @@
require 'set'
require 'fileutils'
-require_relative 'lib/gitlab'
+require_relative '../lib/gitlab_edition'
class String
def red
@@ -28,7 +28,7 @@ flags_paths = [
]
# For EE additionally process `ee/` feature flags
-if Gitlab.ee?
+if GitlabEdition.ee?
flags_paths << 'ee/config/feature_flags/**/*.yml'
# Geo feature flags are constructed dynamically and there's no explicit checks in the codebase so we mark all
@@ -43,7 +43,7 @@ if Gitlab.ee?
end
# For JH additionally process `jh/` feature flags
-if Gitlab.jh?
+if GitlabEdition.jh?
flags_paths << 'jh/config/feature_flags/**/*.yml'
Dir.glob('jh/app/replicators/geo/*_replicator.rb').each_with_object(Set.new) do |path, memo|
diff --git a/scripts/utils.sh b/scripts/utils.sh
index ed27edcadb2..15047d35fc3 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -39,7 +39,7 @@ function bundle_install_script() {
bundle --version
bundle config set path "$(pwd)/vendor"
bundle config set clean 'true'
- test -d jh && bundle config set gemfile 'jh/Gemfile'
+ test -d jh && bundle config set --local gemfile 'jh/Gemfile'
echo "${BUNDLE_WITHOUT}"
bundle config