From 38be381ae4d5ee1b0909e3211e4460e0ff441526 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Thu, 5 Dec 2024 18:08:56 -0300 Subject: [PATCH] fix: version --- step.sh | 186 +++++++++++++++++++++++++++----------------------------- version | 1 + 2 files changed, 90 insertions(+), 97 deletions(-) create mode 100644 version diff --git a/step.sh b/step.sh index 557a001b..7adca6c3 100755 --- a/step.sh +++ b/step.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash -CC_WRAPPER_VERSION="0.0.18" +CC_WRAPPER_VERSION="0.0.30" +set +u say() { echo -e "$1" } exit_if_error() { say "$r==> $1$x" - if [ $CC_FAIL_ON_ERROR = true ]; + if [ "$CC_FAIL_ON_ERROR" = true ]; then say "$r Exiting...$x" exit 1; @@ -14,16 +15,22 @@ exit_if_error() { lower() { echo $(echo $1 | sed 's/CC//' | sed 's/_/-/g' | tr '[:upper:]' '[:lower:]') } -write_existing_args() { - if [ -n "$(eval echo \$$1)" ]; +k_arg() { + if [ -n "$(eval echo \$"CC_$1")" ]; then - echo " -$(lower "$1") $(eval echo \$$1)" + echo "--$(lower "$1")" + fi +} +v_arg() { + if [ -n "$(eval echo \$"CC_$1")" ]; + then + echo "$(eval echo \$"CC_$1")" fi } write_truthy_args() { if [ "$(eval echo \$$1)" = "true" ] || [ "$(eval echo \$$1)" = "1" ]; then - echo " -$(lower $1)" + echo "-$(lower $1)" fi } b="\033[0;36m" # variables/constants @@ -49,16 +56,23 @@ then exit_if_error "Could not find binary file $CC_BINARY" fi else - family=$(uname -s | tr '[:upper:]' '[:lower:]') - cc_os="windows" - [[ $family == "darwin" ]] && cc_os="macos" - [[ $family == "linux" ]] && cc_os="linux" - [[ $cc_os == "linux" ]] && \ - osID=$(grep -e "^ID=" /etc/os-release | cut -c4-) - [[ $osID == "alpine" ]] && cc_os="alpine" - [[ $(arch) == "aarch64" && $family == "linux" ]] && cc_os+="-arm64" - say "$g==>$x Detected $b${cc_os}$x" - export cc_os=${cc_os} + if [ -n "$CC_OS" ]; + then + say "$g==>$x Overridden OS: $b${CC_OS}$x" + export cc_os=${CC_OS} + else + CC_OS="linux" + family=$(uname -s | tr '[:upper:]' '[:lower:]') + cc_os="windows" + [[ $family == "darwin" ]] && cc_os="macos" + [[ $family == "linux" ]] && cc_os="linux" + [[ $cc_os == "linux" ]] && \ + osID=$(grep -e "^ID=" /etc/os-release | cut -c4-) + [[ $osID == "alpine" ]] && cc_os="alpine" + [[ $(arch) == "aarch64" && $family == "linux" ]] && cc_os+="-arm64" + say "$g==>$x Detected $b${cc_os}$x" + export cc_os=${cc_os} + fi export cc_version=${CC_VERSION} cc_filename="codecov" [[ $cc_os == "windows" ]] && cc_filename+=".exe" @@ -70,15 +84,18 @@ else cc_url="$cc_url/${CC_VERSION}" cc_url="$cc_url/${cc_os}/${cc_filename}" say "$g ->$x Downloading $b${cc_url}$x" - curl -Os $cc_url + curl -Os "$cc_url" say "$g==>$x Finishing downloading $b${cc_os}:${CC_VERSION}$x" + version_url="https://cli.codecov.io/api/${cc_os}/${CC_VERSION}" + version=$(curl -s "$version_url" -H "Accept:application/json" | jq -r '.version') + say " Version: $b$version$x" say " " fi if [ "$CC_SKIP_VALIDATION" = "true" ] || [ -n "$CC_BINARY" ]; then say "$r==>$x Bypassing validation as requested by user" else -CC_PUBLIC_PGP_KEY=$(curl https://keybase.io/codecovsecurity/pgp_keys.asc) +CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc) echo "${CC_PUBLIC_PGP_KEY}" | \ gpg --no-default-keyring --import # One-time step @@ -89,13 +106,13 @@ CC_PUBLIC_PGP_KEY=$(curl https://keybase.io/codecovsecurity/pgp_keys.asc) say "$g ->$x Downloading $b${sha_url}$x" say "$g ->$x Downloading $b${sha_url}.sig$x" say " " - curl -Os "$sha_url" - curl -Os "${sha_url}.sig" + curl -Os --retry 5 --retry-delay 2 --connect-timeout 2 "$sha_url" + curl -Os --retry 5 --retry-delay 2 --connect-timeout 2 "${sha_url}.sig" if ! gpg --verify "${cc_filename}.SHA256SUM.sig" "${cc_filename}.SHA256SUM"; then exit_if_error "Could not verify signature. Please contact Codecov if problem continues" fi - if ! (shasum -a 256 -c "${cc_filename}.SHA256SUM" || \ + if ! (shasum -a 256 -c "${cc_filename}.SHA256SUM" 2>/dev/null || \ sha256sum -c "${cc_filename}.SHA256SUM"); then exit_if_error "Could not verify SHASUM. Please contact Codecov if problem continues" @@ -104,77 +121,74 @@ CC_PUBLIC_PGP_KEY=$(curl https://keybase.io/codecovsecurity/pgp_keys.asc) say fi cc_cli_args=() -cc_cli_args+=( $(write_existing_args CC_AUTO_LOAD_PARAMS_FROM) ) -cc_cli_args+=( $(write_existing_args CC_ENTERPRISE_URL) ) -cc_cli_args+=( $(write_existing_args CC_YML_PATH) ) +cc_cli_args+=( $(k_arg AUTO_LOAD_PARAMS_FROM) $(v_arg AUTO_LOAD_PARAMS_FROM)) +cc_cli_args+=( $(k_arg ENTERPRISE_URL) $(v_arg ENTERPRISE_URL)) +if [ -n "$CC_YML_PATH" ] +then + cc_cli_args+=( "--codecov-yml-path" ) + cc_cli_args+=( "$CC_YML_PATH" ) +fi cc_cli_args+=( $(write_truthy_args CC_VERBOSE) ) -cc_cc_args=() -cc_cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) ) -cc_cc_args+=( $(write_existing_args CC_GIT_SERVICE) ) -cc_cc_args+=( $(write_existing_args CC_PARENT_SHA) ) -cc_cc_args+=( $(write_existing_args CC_PR) ) -cc_cc_args+=( $(write_existing_args CC_SHA) ) -cc_cc_args+=( $(write_existing_args CC_SLUG) ) -cc_create_report_args=() -cc_cr_args+=( $(write_existing_args CC_CODE) ) -cc_cr_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) ) -cc_cr_args+=( $(write_existing_args CC_GIT_SERVICE) ) -cc_cr_args+=( $(write_existing_args CC_PR) ) -cc_cr_args+=( $(write_existing_args CC_SHA) ) -cc_cr_args+=( $(write_existing_args CC_SLUG) ) -cc_du_args=() +cc_uc_args=() +# Args for create commit +cc_uc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) ) +cc_uc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE)) +cc_uc_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA)) +cc_uc_args+=( $(k_arg PR) $(v_arg PR)) +cc_uc_args+=( $(k_arg SHA) $(v_arg SHA)) +cc_uc_args+=( $(k_arg SLUG) $(v_arg SLUG)) +# Args for create report +cc_uc_args+=( $(k_arg CODE) $(v_arg CODE)) +# Args for do upload +cc_uc_args+=( $(k_arg ENV) $(v_arg ENV)) OLDIFS=$IFS;IFS=, -cc_du_args+=( $(write_existing_args CC_BRANCH) ) -cc_du_args+=( $(write_existing_args CC_BUILD) ) -cc_du_args+=( $(write_existing_args CC_BUILD_URL) ) -cc_du_args+=( $(write_existing_args CC_CODE) ) -cc_du_args+=( $(write_existing_args CC_DIR) ) -cc_du_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) ) -cc_du_args+=( $(write_truthy_args CC_DISABLE_SEARCH) ) -cc_du_args+=( $(write_truthy_args CC_DRY_RUN) ) -cc_du_args+=( $(write_existing_args CC_ENV) ) +cc_uc_args+=( $(k_arg BRANCH) $(v_arg BRANCH)) +cc_uc_args+=( $(k_arg BUILD) $(v_arg BUILD)) +cc_uc_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL)) +cc_uc_args+=( $(k_arg DIR) $(v_arg DIR)) +cc_uc_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) ) +cc_uc_args+=( $(write_truthy_args CC_DISABLE_SEARCH) ) +cc_uc_args+=( $(write_truthy_args CC_DRY_RUN) ) if [ -n "$CC_EXCLUDES" ]; then for directory in $CC_EXCLUDES; do - cc_du_args+=( " --exclude " "$directory" ) + cc_uc_args+=( "--exclude" "$directory" ) done fi -cc_du_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) ) if [ -n "$CC_FILES" ]; then for file in $CC_FILES; do - cc_du_args+=( " --file " "$file" ) + cc_uc_args+=( "--file" "$file" ) done fi if [ -n "$CC_FLAGS" ]; then for flag in $CC_FLAGS; do - cc_du_args+=( " --flag " "$flag" ) + cc_uc_args+=( "--flag" "$flag" ) done fi -cc_du_args+=( $(write_existing_args CC_GCOV_ARGS) ) -cc_du_args+=( $(write_existing_args CC_GCOV_EXECUTABLE) ) -cc_du_args+=( $(write_existing_args CC_GCOV_IGNORE) ) -cc_du_args+=( $(write_existing_args CC_GCOV_INCLUDE) ) -cc_du_args+=( $(write_existing_args CC_GIT_SERVICE) ) -cc_du_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) ) -cc_du_args+=( $(write_existing_args CC_JOB_CODE) ) -cc_du_args+=( $(write_truthy_args CC_LEGACY) ) -cc_du_args+=( $(write_existing_args CC_NAME) ) -cc_du_args+=( $(write_existing_args CC_NETWORK_FILTER) ) -cc_du_args+=( $(write_existing_args CC_NETWORK_PREFIX) ) -cc_du_args+=( $(write_existing_args CC_NETWORK_ROOT_FOLDER) ) +cc_uc_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS)) +cc_uc_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE)) +cc_uc_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE)) +cc_uc_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE)) +cc_uc_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) ) +cc_uc_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE)) +cc_uc_args+=( $(write_truthy_args CC_LEGACY) ) +if [ -n "$CC_NAME" ]; +then + cc_uc_args+=( "--name" "$CC_NAME" ) +fi +cc_uc_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER)) +cc_uc_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX)) +cc_uc_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER)) if [ -n "$CC_PLUGINS" ]; then for plugin in $CC_PLUGINS; do - cc_du_args+=( " --plugin " "$plugin" ) + cc_uc_args+=( "--plugin" "$plugin" ) done fi -cc_du_args+=( $(write_existing_args CC_PR) ) -cc_du_args+=( $(write_existing_args CC_REPORT_TYPE) ) -cc_du_args+=( $(write_existing_args CC_SHA) ) -cc_du_args+=( $(write_existing_args CC_SLUG) ) -cc_du_args+=( $(write_existing_args CC_SWIFT_PROJECT) ) +cc_uc_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE)) +cc_uc_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT)) IFS=$OLDIFS unset NODE_OPTIONS # See https://github.com/codecov/uploader/issues/475 @@ -193,35 +207,13 @@ then token_str+=" -t " token_arg+=( " -t " "$token") fi -say "$g==>$x Running create-commit" -say " $b./$cc_filename $(echo "${cc_cli_args[@]}") create-commit$token_str $(echo "${cc_cc_args[@]}")$x" -if ! ./$cc_filename \ - ${cc_cli_args[*]} \ - create-commit \ - ${token_arg[*]} \ - ${cc_cc_args[*]}; -then - exit_if_error "Failed to create-commit" -fi -say " " -say "$g==>$x Running create-report" -say " $b./$cc_filename $(echo "${cc_cli_args[@]}") create-report$token_str $(echo "${cc_cr_args[@]}")$x" -if ! ./$cc_filename \ - ${cc_cli_args[*]} \ - create-report \ - ${token_arg[*]} \ - ${cc_cr_args[*]}; -then - exit_if_error "Failed to create-report" -fi -say " " -say "$g==>$x Running do-upload" -say " $b./$cc_filename $(echo "${cc_cli_args[@]}") do-upload$token_str $(echo "${cc_du_args[@]}")$x" +say "$g==>$x Running upload-coverage" +say " $b./$cc_filename $(echo "${cc_cli_args[@]}") upload-coverage$token_str $(echo "${cc_uc_args[@]}")$x" if ! ./$cc_filename \ ${cc_cli_args[*]} \ - do-upload \ + upload-coverage \ ${token_arg[*]} \ - ${cc_du_args[*]}; + "${cc_uc_args[@]}"; then - exit_if_error "Failed to upload" + exit_if_error "Failed to upload coverage" fi diff --git a/version b/version new file mode 100644 index 00000000..ee74734a --- /dev/null +++ b/version @@ -0,0 +1 @@ +4.1.0