diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 00:15:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 00:15:07 +0300 |
commit | e53eae82b097308623e77a69f8cc3138cca3cf68 (patch) | |
tree | d8a99e1a3ca49739a8e7f2cad4b2f4c622c6c8c4 /scripts/gitlab_component_helpers.sh | |
parent | de0e57e387034634a861555b878923cd077a039f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/gitlab_component_helpers.sh')
-rw-r--r-- | scripts/gitlab_component_helpers.sh | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/scripts/gitlab_component_helpers.sh b/scripts/gitlab_component_helpers.sh index 798135a5490..cf9b042b529 100644 --- a/scripts/gitlab_component_helpers.sh +++ b/scripts/gitlab_component_helpers.sh @@ -53,8 +53,6 @@ export GITLAB_ASSETS_PACKAGE_URL="${API_PACKAGES_BASE_URL}/assets/${NODE_ENV}-${ # Fixtures constants 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}" # Generic helper functions function archive_doesnt_exist() { @@ -62,12 +60,12 @@ function archive_doesnt_exist() { status=$(curl -I --silent --retry 3 --output /dev/null -w "%{http_code}" "${package_url}") - if [[ "${status}" != "200" ]]; then - echoinfo "The archive was not found. The server returned status ${status}." - return 0 - else + if [[ "${status}" = "200" ]]; then echoinfo "The archive was found. The server returned status ${status}." return 1 + else + echoinfo "The archive was not found. The server returned status ${status}." + return 0 fi } @@ -160,28 +158,6 @@ 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 @@ -208,8 +184,41 @@ function create_fixtures_package() { create_package "${FIXTURES_PACKAGE}" "${FIXTURES_PATH}" } -function upload_fixtures_package() { - upload_package "${FIXTURES_PACKAGE}" "${FIXTURES_PACKAGE_URL}" +function download_and_extract_fixtures() { + read_curl_package "${FIXTURES_PACKAGE_URL}" | extract_package +} + +function export_fixtures_package_variables() { + export FIXTURES_PACKAGE="fixtures-${FIXTURES_SHA}.tar.gz" + export FIXTURES_PACKAGE_URL="${API_PACKAGES_BASE_URL}/fixtures/${FIXTURES_SHA}/${FIXTURES_PACKAGE}" +} + +function export_fixtures_sha_for_download() { + export FIXTURES_SHA="${CI_MERGE_REQUEST_TARGET_BRANCH_SHA:-${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_SHA}}" + export_fixtures_package_variables +} + +function export_fixtures_sha_for_upload() { + export FIXTURES_SHA="${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}" + export_fixtures_package_variables +} + +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 only_js_files_changed { @@ -235,3 +244,7 @@ function only_js_files_changed { echoinfo "Only JS files were changed" return 0 } + +function upload_fixtures_package() { + upload_package "${FIXTURES_PACKAGE}" "${FIXTURES_PACKAGE_URL}" +} |