diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /scripts | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'scripts')
16 files changed, 235 insertions, 12 deletions
diff --git a/scripts/frontend/graphql_possible_types_extraction.js b/scripts/frontend/graphql_possible_types_extraction.js new file mode 100755 index 00000000000..61f783086e7 --- /dev/null +++ b/scripts/frontend/graphql_possible_types_extraction.js @@ -0,0 +1,69 @@ +#!/usr/bin/env node + +const fs = require('fs/promises'); +const path = require('path'); +const assert = require('assert'); + +const ROOT_DIR = path.join(__dirname, '../../'); +const GRAPHQL_SCHEMA = path.join(ROOT_DIR, 'tmp/tests/graphql/gitlab_schema.json'); +const POSSIBLE_TYPES_REL = 'app/assets/javascripts/graphql_shared/possible_types.json'; +const POSSIBLE_TYPES = path.join(ROOT_DIR, POSSIBLE_TYPES_REL); + +function extractTypes(schema) { + return Object.fromEntries( + // eslint-disable-next-line no-underscore-dangle + schema.data.__schema.types + .filter((type) => type.possibleTypes) + .map(({ name, possibleTypes }) => [name, possibleTypes.map((subtype) => subtype.name)]), + ); +} + +async function main() { + let schema; + try { + schema = JSON.parse(await fs.readFile(GRAPHQL_SCHEMA, 'utf-8')); + } catch (e) { + console.error( + 'Could not read the GraphQL Schema, make sure to run: bundle exec rake gitlab:graphql:schema:dump', + ); + throw e; + } + + const possibleTypes = extractTypes(schema); + + if (process.argv.includes('--check')) { + const previousTypes = JSON.parse(await fs.readFile(POSSIBLE_TYPES, 'utf-8')); + + assert.deepStrictEqual( + previousTypes, + possibleTypes, + ` +${POSSIBLE_TYPES_REL} needs to be regenerated, please run: + node scripts/frontend/graphql_possible_types_extraction.js --write +and commit the changes! + `, + ); + return; + } + + if (process.argv.includes('--write')) { + const stringifiedPossibleTypes = JSON.stringify(possibleTypes, null, 2); + await fs.writeFile(POSSIBLE_TYPES, `${stringifiedPossibleTypes}\n`); + console.log(`Successfully updated ${POSSIBLE_TYPES_REL}`); + return; + } + + throw new Error(` +ERROR: Please use the script correctly: +Usage: graphql_possible_types_extraction [options] + +Options: + --check Check whether there are new Interface or Union types + --write Generate new possible types + `); +} + +main().catch((error) => { + console.warn(error.message); + process.exitCode = 1; +}); diff --git a/scripts/frontend/startup_css/constants.js b/scripts/frontend/startup_css/constants.js index 83f43143e1b..10d60657e09 100644 --- a/scripts/frontend/startup_css/constants.js +++ b/scripts/frontend/startup_css/constants.js @@ -50,7 +50,7 @@ const createMainOutput = ({ outFile, cssKeys, type }) => ({ htmlPaths: [ path.join(FIXTURES_ROOT, `startup_css/project-${type}.html`), path.join(FIXTURES_ROOT, `startup_css/project-${type}-signed-out.html`), - path.join(FIXTURES_ROOT, `startup_css/project-${type}-search-ff-on.html`), + path.join(FIXTURES_ROOT, `startup_css/project-${type}-search-ff-off.html`), ], cssKeys, purgeOptions: { diff --git a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js b/scripts/frontend/stylelint/stylelint_duplicate_selectors.js index 982ddf524a3..77c1f1292b7 100644 --- a/scripts/frontend/stylelint/stylelint-duplicate-selectors.js +++ b/scripts/frontend/stylelint/stylelint_duplicate_selectors.js @@ -1,5 +1,5 @@ const stylelint = require('stylelint'); -const utils = require('./stylelint-utils'); +const utils = require('./stylelint_utils'); const ruleName = 'stylelint-gitlab/duplicate-selectors'; diff --git a/scripts/frontend/stylelint/stylelint-utility-classes.js b/scripts/frontend/stylelint/stylelint_utility_classes.js index 14827145b54..ad2b2ddbb20 100644 --- a/scripts/frontend/stylelint/stylelint-utility-classes.js +++ b/scripts/frontend/stylelint/stylelint_utility_classes.js @@ -1,6 +1,6 @@ const stylelint = require('stylelint'); -const utils = require('./stylelint-utils'); -const utilityClasses = require('./utility-classes-map'); +const utils = require('./stylelint_utils'); +const utilityClasses = require('./utility_classes_map'); const ruleName = 'stylelint-gitlab/utility-classes'; diff --git a/scripts/frontend/stylelint/stylelint-utility-map.js b/scripts/frontend/stylelint/stylelint_utility_map.js index 676f83cd067..187b2065823 100644 --- a/scripts/frontend/stylelint/stylelint-utility-map.js +++ b/scripts/frontend/stylelint/stylelint_utility_map.js @@ -4,13 +4,13 @@ const postcss = require('postcss'); const prettier = require('prettier'); const sass = require('sass'); -const utils = require('./stylelint-utils'); +const utils = require('./stylelint_utils'); const ROOT_PATH = path.resolve(__dirname, '../../..'); -const hashMapPath = path.resolve(__dirname, './utility-classes-map.js'); +const hashMapPath = path.resolve(__dirname, './utility_classes_map.js'); // -// This creates a JS based hash map (saved in utility-classes-map.js) of the different values in the utility classes +// This creates a JS based hash map (saved in utility_classes_map.js) of the different values in the utility classes // sass.render( { diff --git a/scripts/frontend/stylelint/stylelint-utils.js b/scripts/frontend/stylelint/stylelint_utils.js index c9d9c7d9aad..c9d9c7d9aad 100644 --- a/scripts/frontend/stylelint/stylelint-utils.js +++ b/scripts/frontend/stylelint/stylelint_utils.js diff --git a/scripts/frontend/stylelint/utility-classes-map.js b/scripts/frontend/stylelint/utility_classes_map.js index a174812ff93..a174812ff93 100644 --- a/scripts/frontend/stylelint/utility-classes-map.js +++ b/scripts/frontend/stylelint/utility_classes_map.js diff --git a/scripts/gitlab_workhorse_component_helpers.sh b/scripts/gitlab_workhorse_component_helpers.sh index 06fe7b2ea51..ebd43a125b9 100644 --- a/scripts/gitlab_workhorse_component_helpers.sh +++ b/scripts/gitlab_workhorse_component_helpers.sh @@ -30,6 +30,7 @@ function create_gitlab_workhorse_package() { function extract_gitlab_workhorse_package() { local tar_working_folder="${TMP_TEST_FOLDER}" + mkdir -p "${tar_working_folder}" echoinfo "Extracting archive to ${tar_working_folder}" diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh index aba815cdf28..5a3f439009d 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.15-vale-2.15.0-markdownlint-0.31.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.15.5-markdownlint-0.31.1 ${cmd} ${args} else echo echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2 diff --git a/scripts/merge-simplecov b/scripts/merge-simplecov index 32a0cd86f82..24be731549b 100755 --- a/scripts/merge-simplecov +++ b/scripts/merge-simplecov @@ -5,4 +5,7 @@ require_relative '../spec/simplecov_env' SimpleCovEnv.configure_profile SimpleCovEnv.configure_formatter -SimpleCov.collate Dir.glob(File.join(SimpleCov.coverage_path, '*', '.resultset.json')) +resultset_files = Dir.glob(File.join(SimpleCov.coverage_path, '*', '.resultset.json')) +exit(0) if resultset_files.empty? + +SimpleCov.collate(resultset_files) diff --git a/scripts/qa/testcases-check b/scripts/qa/testcases-check new file mode 100755 index 00000000000..1d7a9d04e7b --- /dev/null +++ b/scripts/qa/testcases-check @@ -0,0 +1,79 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'json' + +TESTCASE_FORMAT = %r{https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/\d+}.freeze + +testcases = [] +missing_testcases = [] +formatted_duplicates = [] +testcase_format_errors = [] +missing_message = %"\n*** The following tests are missing testcase links:\n\n%s\n" +duplicate_message = %"\n*** The following tests have duplicate testcase links:\n\n%s" +format_message = %"\n*** The following testcase links are incorrectly formatted:\n\n%s\n" + +test_metadata_file = ARGV.shift + +unless test_metadata_file + puts "usage: #{__FILE__} <test_metadata_file>" + exit 1 +end + +file = File.read(test_metadata_file) + +unless file =~ %r{.*\"examples\":\[\{\"id\"\:.*} + puts "\nRspec output did not match regex. Check test-metadata.json file.\n" + exit 1 +end + +puts "\nAnalyzing testcase data...\n" + +data_hash = JSON.parse(file) +tests = data_hash['examples'] + +tests.each do |test| + next if test['id'] =~ %r{.\/qa\/specs\/features\/sanity\/*} + + if test['testcase'] + testcases.push(["#{test['testcase']}", "#{test['id']} - #{test['full_description']}"]) + + unless TESTCASE_FORMAT =~ test['testcase'] + testcase_format_errors.push( + <<~FORMAT_ERRORS + ==> #{test['testcase']} in file: #{test['id']} with title: + #{test['full_description']} + FORMAT_ERRORS + ) + end + else + missing_testcases.push(" ==> #{test['id']} - #{test['full_description']}\n") + end +end + +testcase_list = testcases.group_by {|testcase| testcase.shift}.transform_values(&:flatten) + +duplicates = testcase_list.select {|k, v| v.count > 1} + +unless duplicates.empty? + duplicates.each do |duplicate| + formatted_duplicates.append( + <<~DUPLICATES + Testcase link #{duplicate[0]} is used in too many tests: + ==> #{duplicate[1].join("\n ==> ")}\n + DUPLICATES + ) + end +end + +if formatted_duplicates.empty? && missing_testcases.empty? && testcase_format_errors.empty? + puts "\nNo errors found." +else + puts "\n*** Testcase link violations detected! ***\n" + puts duplicate_message % formatted_duplicates.join("\n") unless formatted_duplicates.empty? + puts missing_message % missing_testcases.join("\n") unless missing_testcases.empty? + puts format_message % testcase_format_errors.join("\n") unless testcase_format_errors.empty? + puts "\n*** Please link a unique test case from the GitLab project for the errors listed above.\n" + puts " See: https://docs.gitlab.com/ee/development/testing_guide/end_to_end/best_practices.html#link-a-test-to-its-test-case." + exit 1 +end diff --git a/scripts/review_apps/base-config.yaml b/scripts/review_apps/base-config.yaml index 0f6603fea8c..91c645a0ed9 100644 --- a/scripts/review_apps/base-config.yaml +++ b/scripts/review_apps/base-config.yaml @@ -1,3 +1,6 @@ +safe-to-evict: &safe-to-evict + cluster-autoscaler.kubernetes.io/safe-to-evict: "true" + global: appConfig: enableUsagePing: false @@ -29,6 +32,8 @@ gitlab: storageClass: ssd nodeSelector: preemptible: "false" + podAnnotations: + <<: *safe-to-evict gitlab-exporter: enabled: false mailroom: @@ -107,6 +112,8 @@ gitlab-runner: memory: 150M nodeSelector: preemptible: "true" + podAnnotations: + <<: *safe-to-evict minio: resources: requests: @@ -117,6 +124,8 @@ minio: memory: 280M nodeSelector: preemptible: "true" + podAnnotations: + <<: *safe-to-evict nginx-ingress: controller: config: @@ -159,6 +168,8 @@ postgresql: master: nodeSelector: preemptible: "false" + podAnnotations: + <<: *safe-to-evict prometheus: install: false redis: @@ -174,6 +185,8 @@ redis: master: nodeSelector: preemptible: "true" + podAnnotations: + <<: *safe-to-evict registry: hpa: minReplicas: 1 diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh index 695de95b8fc..f529c8eaafe 100755 --- a/scripts/review_apps/review-apps.sh +++ b/scripts/review_apps/review-apps.sh @@ -213,7 +213,7 @@ function create_application_secret() { local initial_root_password_shared_secret local gitlab_license_shared_secret - initial_root_password_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-initial-root-password | tail -n 1) + initial_root_password_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-initial-root-password 2> /dev/null | tail -n 1) if [[ "${initial_root_password_shared_secret}" == "" ]]; then echoinfo "Creating the 'shared-gitlab-initial-root-password' secret in the ${namespace} namespace..." true kubectl create secret generic --namespace "${namespace}" \ @@ -226,7 +226,7 @@ function create_application_secret() { if [ -z "${REVIEW_APPS_EE_LICENSE_FILE}" ]; then echo "License not found" && return; fi - gitlab_license_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-license | tail -n 1) + gitlab_license_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-license 2> /dev/null | tail -n 1) if [[ "${gitlab_license_shared_secret}" == "" ]]; then echoinfo "Creating the 'shared-gitlab-license' secret in the ${namespace} namespace..." true kubectl create secret generic --namespace "${namespace}" \ diff --git a/scripts/static-analysis b/scripts/static-analysis index 9c6a948adc1..317652eb075 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -55,6 +55,7 @@ class StaticAnalysis Task.new(%w[yarn run internal:stylelint], 8), Task.new(%w[scripts/lint-conflicts.sh], 1), 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) ].compact.freeze diff --git a/scripts/vendor_template b/scripts/vendor_template new file mode 100755 index 00000000000..96d013ea772 --- /dev/null +++ b/scripts/vendor_template @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# Run it as: +# vendor_template https://gitlab.com/pages/hugo hugo "Pages/Hugo template" +# + +## Check which OS the script runs from since gtar/tar behaves differently +## on macOS and Linux +if [ "$(uname)" == "Darwin" ]; then + GTAR="gtar" +else + GTAR="tar" +fi + +## Check if jq is installed +hash jq 2>/dev/null || echo "ERROR: jq is not installed. Install it and run the script again." + +REPO_URL=$1 +SHORT_NAME=$2 +COMMENT=$3 +FILENAME="$SHORT_NAME.tar.gz" + +# Check if the extracted project exists +if [ ! -f $FILENAME ] +then + echo + echo "ERROR: $FILENAME doesn't exist. Did you export the project?" + exit 1 +fi + +$GTAR --list --file="$FILENAME" +rm -rf tar-base project-$SHORT_NAME +mkdir -p "./tar-base" +tar xf "$2.tar.gz" -C "./tar-base" ./VERSION ./tree/project.json +git clone "$REPO_URL" project-$SHORT_NAME +cd project-$SHORT_NAME +rm -rf .git +git init +git add -A . +git commit --author "GitLab <root@localhost>" -m "$COMMENT" +git bundle create project.bundle --all +mv -f project.bundle ../tar-base/ +cd ../tar-base +cat tree/project.json | jq '.issues = [] | .releases = [] | .merge_requests = [] | .ci_pipelines = [] | .pipeline_schedules = [] | .services = [] | .pipelines = [] | .protected_branches = [] | .project_members = [] | .labels = [] | del(.ci_cd_settings, .external_authorization_classification_label, .project_feature)' -c > project.json +rm -rf tree +ls -alth +tar cvzf "$FILENAME" ./ +cd .. + +echo "=> Moving $FILENAME to the vendored templates" +mv tar-base/$FILENAME vendor/project_templates/ + +echo "=> Cleaning up" +rm -rf tar-base "project-$SHORT_NAME" $FILENAME + +echo "=> The following files are included in the bundled repo:" +$GTAR --list --file="vendor/project_templates/$FILENAME" diff --git a/scripts/verify-tff-mapping b/scripts/verify-tff-mapping index b09fd09a737..b3462f74faa 100755 --- a/scripts/verify-tff-mapping +++ b/scripts/verify-tff-mapping @@ -149,7 +149,7 @@ class MappingTest end end -results = tests.map { |test| MappingTest.new(test) } +results = tests.map { |test| MappingTest.new(**test) } failed_tests = results.select(&:failed?) if failed_tests.any? |