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-03-21 00:14:25 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-21 00:14:25 +0300
commit40a329556f63d919a68dd80bb37b087d1f0e6336 (patch)
tree86c2712bf48f66d0e7dbe7e115e5f01c78193ad0 /scripts
parent96b01499986c01d0c95176860a7606b7616a3836 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gitlab_component_helpers.sh89
-rw-r--r--scripts/rspec_helpers.sh5
2 files changed, 76 insertions, 18 deletions
diff --git a/scripts/gitlab_component_helpers.sh b/scripts/gitlab_component_helpers.sh
index 309e339de01..798135a5490 100644
--- a/scripts/gitlab_component_helpers.sh
+++ b/scripts/gitlab_component_helpers.sh
@@ -52,22 +52,9 @@ export GITLAB_ASSETS_PACKAGE="assets-${NODE_ENV}-${GITLAB_EDITION}-${GITLAB_ASSE
export GITLAB_ASSETS_PACKAGE_URL="${API_PACKAGES_BASE_URL}/assets/${NODE_ENV}-${GITLAB_EDITION}-${GITLAB_ASSETS_HASH}/${GITLAB_ASSETS_PACKAGE}"
# Fixtures constants
-
-# Export the SHA variable for updating/downloading fixture packages, using the following order of precedence:
-# 1. If MERGE_BASE_SHA is defined, use its value.
-# 2. If CI_MERGE_REQUEST_SOURCE_BRANCH_SHA is defined, use its value for merge request pipelines.
-# 3. Otherwise, use the value of CI_COMMIT_SHA for default branch pipelines or merge requests with detached pipelines.
-if [ -n "${MERGE_BASE_SHA:-}" ]; then
- export FIXTURES_SHA="${MERGE_BASE_SHA}"
-elif [ -n "${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-}" ]; then
- export FIXTURES_SHA="${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"
-else
- export FIXTURES_SHA="${CI_COMMIT_SHA}"
-fi
-
export FIXTURES_PATH="tmp/tests/frontend/**/*"
-export FIXTURES_PACKAGE="fixtures-${FIXTURES_SHA}.tar.gz"
-export FIXTURES_PACKAGE_URL="${API_PACKAGES_BASE_URL}/fixtures/${FIXTURES_SHA}/${FIXTURES_PACKAGE}"
+export FIXTURES_PACKAGE="fixtures-${FIXTURES_SHA:-}.tar.gz"
+export FIXTURES_PACKAGE_URL="${API_PACKAGES_BASE_URL}/fixtures/${FIXTURES_SHA:-}/${FIXTURES_PACKAGE}"
# Generic helper functions
function archive_doesnt_exist() {
@@ -75,7 +62,13 @@ function archive_doesnt_exist() {
status=$(curl -I --silent --retry 3 --output /dev/null -w "%{http_code}" "${package_url}")
- [[ "${status}" != "200" ]]
+ if [[ "${status}" != "200" ]]; then
+ echoinfo "The archive was not found. The server returned status ${status}."
+ return 0
+ else
+ echoinfo "The archive was found. The server returned status ${status}."
+ return 1
+ fi
}
function create_package() {
@@ -167,10 +160,50 @@ function upload_gitlab_assets_package() {
}
# Fixtures functions
+function download_and_extract_fixtures() {
+ read_curl_package "${FIXTURES_PACKAGE_URL}" | extract_package
+}
+
function fixtures_archive_doesnt_exist() {
+ echoinfo "Checking if the package is available at ${FIXTURES_PACKAGE_URL} ..."
+
archive_doesnt_exist "${FIXTURES_PACKAGE_URL}"
}
+function fixtures_directory_exists() {
+ local fixtures_directory="tmp/tests/frontend/"
+
+ if [[ -d "${fixtures_directory}" ]]; then
+ echo "${fixtures_directory} directory exists"
+ return 0
+ else
+ echo "${fixtures_directory} directory does not exist"
+ return 1
+ fi
+}
+
+function check_fixtures_download() {
+ if [[ "${REUSE_FRONTEND_FIXTURES_ENABLED:-}" != "true" ]]; then
+ return 1
+ fi
+
+ # Note: Currently, reusing frontend fixtures is only supported in EE.
+ # Other projects will be supported through this issue in the future: https://gitlab.com/gitlab-org/gitlab/-/issues/393615.
+ if [[ "${CI_PROJECT_NAME}" != "gitlab" ]] || [[ "${CI_JOB_NAME}" =~ "foss" ]]; then
+ return 1
+ fi
+
+ if [[ -z "${CI_MERGE_REQUEST_IID:-}" ]]; then
+ return 1
+ else
+ if only_js_files_changed && ! fixtures_archive_doesnt_exist; then
+ return 0
+ else
+ return 1
+ fi
+ fi
+}
+
function create_fixtures_package() {
create_package "${FIXTURES_PACKAGE}" "${FIXTURES_PATH}"
}
@@ -178,3 +211,27 @@ function create_fixtures_package() {
function upload_fixtures_package() {
upload_package "${FIXTURES_PACKAGE}" "${FIXTURES_PACKAGE_URL}"
}
+
+function only_js_files_changed {
+ local target_branch_sha="${CI_MERGE_REQUEST_TARGET_BRANCH_SHA:-}"
+ local source_branch_sha="${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-}"
+
+ if [[ -z "${target_branch_sha}" || -z "${source_branch_sha}" ]]; then
+ echoinfo "The commit hash(es) provided are missing or are empty."
+ echoinfo "Please provide valid commit hash(es)."
+ return 1
+ fi
+
+ local changed_files
+ changed_files=$(git diff --name-only "${target_branch_sha}..${source_branch_sha}")
+
+ for file in $changed_files; do
+ if [[ ! $file = *.js ]]; then
+ echoinfo "Changes were made to files other than JS files"
+ return 1
+ fi
+ done
+
+ echoinfo "Only JS files were changed"
+ return 0
+}
diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh
index de735e03db0..bd2c01dac5e 100644
--- a/scripts/rspec_helpers.sh
+++ b/scripts/rspec_helpers.sh
@@ -164,7 +164,8 @@ function rspec_paralellized_job() {
local test_tool="${job_name[0]}"
local test_level="${job_name[1]}"
local report_name=$(echo "${CI_JOB_NAME}" | sed -E 's|[/ ]|_|g') # e.g. 'rspec unit pg12 1/24' would become 'rspec_unit_pg12_1_24'
- local rspec_opts="${1}"
+ local rspec_opts="${1:-}"
+ local rspec_tests_mapping_enabled="${RSPEC_TESTS_MAPPING_ENABLED:-}"
local spec_folder_prefixes=""
local rspec_flaky_folder_path="$(dirname "${FLAKY_RSPEC_SUITE_REPORT_PATH}")/"
local knapsack_folder_path="$(dirname "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}")/"
@@ -218,7 +219,7 @@ function rspec_paralellized_job() {
debug_rspec_variables
- if [[ -n "${RSPEC_TESTS_MAPPING_ENABLED}" ]]; then
+ 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=$?
else
tooling/bin/parallel_rspec --rspec_args "$(rspec_args "${rspec_opts}")" || rspec_run_status=$?