summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /scripts
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
downloadgitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/docs_screenshots.rb2
-rwxr-xr-xscripts/lint-doc.sh6
-rw-r--r--scripts/prepare_build.sh6
-rwxr-xr-xscripts/review_apps/review-apps.sh12
-rwxr-xr-xscripts/slack10
-rwxr-xr-xscripts/used-feature-flags94
6 files changed, 113 insertions, 17 deletions
diff --git a/scripts/docs_screenshots.rb b/scripts/docs_screenshots.rb
index e02d67de748..7472d9ea37b 100755
--- a/scripts/docs_screenshots.rb
+++ b/scripts/docs_screenshots.rb
@@ -22,7 +22,7 @@ end
def rename_image(file, milestone)
path = File.dirname(file)
- basename = File.basename(file)
+ basename = File.basename(file, ".*")
final_name = File.join(path, "#{basename}_v#{milestone}.png")
FileUtils.mv(file, final_name)
end
diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh
index 4886323c836..87256269de2 100755
--- a/scripts/lint-doc.sh
+++ b/scripts/lint-doc.sh
@@ -40,8 +40,8 @@ then
fi
# Do not use 'README.md', instead use 'index.md'
-# Number of 'README.md's as of 2020-05-28
-NUMBER_READMES=44
+# Number of 'README.md's as of 2020-10-13
+NUMBER_READMES=36
FIND_READMES=$(find doc/ -name "README.md" | wc -l)
echo '=> Checking for new README.md files...'
echo
@@ -77,7 +77,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 ${cmd} ${args}
+ docker run -t -v ${PWD}:/gitlab -w /gitlab --rm registry.gitlab.com/gitlab-org/gitlab-docs/lint:latest ${cmd} ${args}
else
echo
echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2
diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh
index 1243609dc24..e95f20bc26c 100644
--- a/scripts/prepare_build.sh
+++ b/scripts/prepare_build.sh
@@ -2,7 +2,7 @@
export SETUP_DB=${SETUP_DB:-true}
export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true}
-export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production --without=development --jobs=$(nproc) --path=vendor --retry=3 --quiet"}
+export BUNDLE_INSTALL_FLAGS=${BUNDLE_INSTALL_FLAGS:-"--without=production development --jobs=$(nproc) --path=vendor --retry=3 --quiet"}
if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
bundle --version
@@ -14,10 +14,6 @@ if [ "$USE_BUNDLE_INSTALL" != "false" ]; then
run_timed_command "bundle pristine pg"
fi
-# Only install knapsack after bundle install! Otherwise oddly some native
-# gems could not be found under some circumstance. No idea why, hours wasted.
-run_timed_command "gem install knapsack --no-document"
-
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
diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh
index 862c3b4bb62..b8cbe625e5b 100755
--- a/scripts/review_apps/review-apps.sh
+++ b/scripts/review_apps/review-apps.sh
@@ -48,7 +48,13 @@ function delete_release() {
return
fi
- helm_delete_release "${namespace}" "${release}"
+ # Check if helm release exists before attempting to delete
+ # There may be situation where k8s resources exist, but helm release does not,
+ # for example, following a failed helm install.
+ # In such cases, we still want to continue to clean up k8s resources.
+ if deploy_exists "${namespace}" "${release}"; then
+ helm_delete_release "${namespace}" "${release}"
+ fi
kubectl_cleanup_release "${namespace}" "${release}"
}
@@ -131,7 +137,7 @@ function run_task() {
local ruby_cmd="${1}"
local task_runner_pod=$(get_pod "task-runner")
- kubectl exec -it --namespace "${namespace}" "${task_runner_pod}" -- gitlab-rails runner "${ruby_cmd}"
+ kubectl exec --namespace "${namespace}" "${task_runner_pod}" -- gitlab-rails runner "${ruby_cmd}"
}
function disable_sign_ups() {
@@ -144,7 +150,7 @@ function disable_sign_ups() {
# Create the root token
local ruby_cmd="token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api], name: 'Token to disable sign-ups'); token.set_token('${REVIEW_APPS_ROOT_TOKEN}'); begin; token.save!; rescue(ActiveRecord::RecordNotUnique); end"
- run_task "${ruby_cmd}"
+ retry "run_task \"${ruby_cmd}\""
# Disable sign-ups
local signup_enabled=$(retry 'curl --silent --show-error --request PUT --header "PRIVATE-TOKEN: ${REVIEW_APPS_ROOT_TOKEN}" "${CI_ENVIRONMENT_URL}/api/v4/application/settings?signup_enabled=false" | jq ".signup_enabled"')
diff --git a/scripts/slack b/scripts/slack
index 60bc70a8542..293f8070504 100755
--- a/scripts/slack
+++ b/scripts/slack
@@ -1,6 +1,5 @@
#!/bin/bash
-# This is copied from:
-# https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/bin/slack
+# This is based on https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/bin/slack
#
# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set).
# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it).
@@ -8,10 +7,11 @@
CHANNEL=$1
MSG=$2
ICON_EMOJI=$3
+USERNAME=$4
-if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then
- echo "Missing argument(s) - Use: $0 channel message icon_emoji"
+if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ] || [ -z "$USERNAME" ]; then
+ echo "Missing argument(s) - Use: $0 channel message icon_emoji username"
echo "and set CI_SLACK_WEBHOOK_URL environment variable."
else
- curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "GitLab QA Bot", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL"
+ curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "'"$USERNAME"'", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL"
fi
diff --git a/scripts/used-feature-flags b/scripts/used-feature-flags
new file mode 100755
index 00000000000..07b8d2063ef
--- /dev/null
+++ b/scripts/used-feature-flags
@@ -0,0 +1,94 @@
+#!/usr/bin/env ruby
+
+class String
+ def red
+ "\e[31m#{self}\e[0m"
+ end
+
+ def yellow
+ "\e[33m#{self}\e[0m"
+ end
+
+ def green
+ "\e[32m#{self}\e[0m"
+ end
+
+ def bold
+ "\e[1m#{self}\e[0m"
+ end
+end
+
+flags_paths = [
+ 'config/feature_flags/**/*.yml'
+]
+
+# For EE additionally process `ee/` feature flags
+if File.exist?('ee/app/models/license.rb') && !%w[true 1].include?(ENV['FOSS_ONLY'].to_s)
+ flags_paths << 'ee/config/feature_flags/**/*.yml'
+end
+
+all_flags = {}
+additional_flags = Set.new
+
+# Iterate all defined feature flags
+# to discover which were used
+flags_paths.each do |flags_path|
+ puts flags_path
+ Dir.glob(flags_path).each do |path|
+ feature_flag_name = File.basename(path, '.yml')
+
+ all_flags[feature_flag_name] = File.exist?(File.join('tmp', 'feature_flags', feature_flag_name + '.used'))
+ end
+end
+
+# Iterate all used feature flags
+# to discover which flags are undefined
+Dir.glob('tmp/feature_flags/*.used').each do |path|
+ feature_flag_name = File.basename(path, '.used')
+
+ additional_flags.add(feature_flag_name) unless all_flags[feature_flag_name]
+end
+
+used_flags = all_flags.select { |name, used| used }
+unused_flags = all_flags.reject { |name, used| used }
+
+puts "=========================================".green.bold
+puts "Feature Flags usage summary:".green.bold
+puts
+
+puts "- #{all_flags.count + additional_flags.count} was found"
+puts "- #{unused_flags.count} appear(s) to be UNUSED".yellow
+puts "- #{additional_flags.count} appear(s) to be unknown".yellow
+puts "- #{used_flags.count} appear(s) to be used".green
+puts
+
+if additional_flags.count > 0
+ puts "==================================================".green.bold
+ puts "There are feature flags that appears to be unknown".yellow
+ puts
+ puts "They appear to be used by CI, but we do lack their YAML definition".yellow
+ puts "This is likely expected, so feel free to ignore that list:".yellow
+ puts
+ additional_flags.sort.each do |name|
+ puts "- #{name}".yellow
+ end
+ puts
+end
+
+if unused_flags.count > 0
+ puts "========================================".green.bold
+ puts "These feature flags appears to be UNUSED".red.bold
+ puts
+ puts "If they are really no longer needed REMOVE their .yml definition".red
+ puts "If they are needed you need to ENSURE that their usage is covered with specs to continue.".red
+ puts
+ unused_flags.keys.sort.each do |name|
+ puts "- #{name}".yellow
+ end
+ puts
+ puts "Feature flag usage check failed.".red.bold
+ exit(1)
+end
+
+puts "Everything is fine here!".green
+puts