From c6cacbb1aeddb1193217142f64587b7daa2a75b5 Mon Sep 17 00:00:00 2001 From: Zxilly <31370133+Zxilly@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:32:55 +0800 Subject: [PATCH 1/3] Add check for `CC_USE_PYTHON` environment variable and skip steps if set * **scripts/run.sh** - Add a check for the `CC_USE_PYTHON` environment variable at the beginning of the script - Skip the `download.sh` and `validate.sh` scripts if `CC_USE_PYTHON` is set * **scripts/set_defaults.sh** - Add a default value for the `CC_USE_PYTHON` environment variable --- scripts/run.sh | 9 +++++++-- scripts/set_defaults.sh | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) mode change 100755 => 100644 scripts/run.sh mode change 100755 => 100644 scripts/set_defaults.sh diff --git a/scripts/run.sh b/scripts/run.sh old mode 100755 new mode 100644 index 24db745..db26c98 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,9 +1,14 @@ #!/usr/bin/env bash +if [ -n "$CC_USE_PYTHON" ]; then + echo "CC_USE_PYTHON is set, skipping download and validation steps." +else + . ./download.sh + . ./validate.sh +fi + . ./version.sh . ./set_defaults.sh -. ./download.sh -. ./validate.sh . ./set_cli_args.sh . ./set_create_commit_args.sh diff --git a/scripts/set_defaults.sh b/scripts/set_defaults.sh old mode 100755 new mode 100644 index 947232e..db29e7a --- a/scripts/set_defaults.sh +++ b/scripts/set_defaults.sh @@ -48,3 +48,4 @@ say " _____ _ CODECOV_VERSION="${CODECOV_VERSION:-latest}" CODECOV_FAIL_ON_ERROR="${CODECOV_FAIL_ON_ERROR:-false}" +CC_USE_PYTHON="${CC_USE_PYTHON:-false}" From 23fb3537f20127d868d83a284c6799e74ba3148c Mon Sep 17 00:00:00 2001 From: Zxilly <31370133+Zxilly@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:40:16 +0000 Subject: [PATCH 2/3] feat: update upload command --- scripts/run.sh | 6 +++--- scripts/upload.sh | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/run.sh b/scripts/run.sh index db26c98..79e313e 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +. ./version.sh +. ./set_defaults.sh + if [ -n "$CC_USE_PYTHON" ]; then echo "CC_USE_PYTHON is set, skipping download and validation steps." else @@ -7,9 +10,6 @@ else . ./validate.sh fi -. ./version.sh -. ./set_defaults.sh - . ./set_cli_args.sh . ./set_create_commit_args.sh . ./set_create_report_args.sh diff --git a/scripts/upload.sh b/scripts/upload.sh index 7657be7..a48574c 100755 --- a/scripts/upload.sh +++ b/scripts/upload.sh @@ -3,7 +3,13 @@ unset NODE_OPTIONS # See https://github.com/codecov/uploader/issues/475 -chmod +x $codecov_filename +if [ -z "$CC_USE_PYTHON" ]; +then + chmod +x $codecov_filename + bin="./$codecov_filename" +else + bin="codecov-cli" +fi if [ -n "$CODECOV_TOKEN_VAR" ]; then @@ -22,8 +28,8 @@ then fi say "$g==>$x Running create-commit" -say " $b./$codecov_filename $(echo "${codecov_cli_args[@]}") create-commit$token_str $(echo "${codecov_cc_args[@]}")$x" -if ! ./$codecov_filename \ +say " $b$bin $(echo "${codecov_cli_args[@]}") create-commit$token_str $(echo "${codecov_cc_args[@]}")$x" +if ! $bin \ ${codecov_cli_args[*]} \ create-commit \ ${token_arg[*]} \ @@ -34,8 +40,8 @@ fi say " " say "$g==>$x Running create-report" -say " $b./$codecov_filename $(echo "${codecov_cli_args[@]}") create-report$token_str $(echo "${codecov_cr_args[@]}")$x" -if ! ./$codecov_filename \ +say " $b$bin $(echo "${codecov_cli_args[@]}") create-report$token_str $(echo "${codecov_cr_args[@]}")$x" +if ! $bin \ ${codecov_cli_args[*]} \ create-report \ ${token_arg[*]} \ @@ -46,8 +52,8 @@ fi say " " say "$g==>$x Running do-upload" -say " $b./$codecov_filename $(echo "${codecov_cli_args[@]}") do-upload$token_str $(echo "${codecov_du_args[@]}")$x" -if ! ./$codecov_filename \ +say " $b$bin $(echo "${codecov_cli_args[@]}") do-upload$token_str $(echo "${codecov_du_args[@]}")$x" +if ! $bin \ ${codecov_cli_args[*]} \ do-upload \ ${token_arg[*]} \ From 1fb5f4a722745358c732338601d866733dd2ab2a Mon Sep 17 00:00:00 2001 From: Zxilly <31370133+Zxilly@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:41:12 +0000 Subject: [PATCH 3/3] chore: build script --- dist/codecov.sh | 25 ++++++++++++++++++------- env | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dist/codecov.sh b/dist/codecov.sh index f32ee2f..7849925 100755 --- a/dist/codecov.sh +++ b/dist/codecov.sh @@ -41,6 +41,10 @@ say " _____ _ " CC_VERSION="${CC_VERSION:-latest}" CC_FAIL_ON_ERROR="${CC_FAIL_ON_ERROR:-false}" +CC_USE_PYTHON="${CC_USE_PYTHON:-false}" +if [ -n "$CC_USE_PYTHON" ]; then + echo "CC_USE_PYTHON is set, skipping download and validation steps." +else if [ -n "$CC_BINARY" ]; then if [ -f "$CC_BINARY" ]; @@ -114,6 +118,7 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc) say "$g==>$x CLI integrity verified" say fi +fi cc_cli_args=() cc_cli_args+=( $(write_existing_args CC_AUTO_LOAD_PARAMS_FROM) ) cc_cli_args+=( $(write_existing_args CC_ENTERPRISE_URL) ) @@ -189,7 +194,13 @@ cc_du_args+=( $(write_existing_args CC_SWIFT_PROJECT) ) IFS=$OLDIFS unset NODE_OPTIONS # See https://github.com/codecov/uploader/issues/475 -chmod +x $cc_filename +if [ -z "$CC_USE_PYTHON" ]; +then + chmod +x $cc_filename + bin="./$cc_filename" +else + bin="codecov-cli" +fi if [ -n "$CC_TOKEN_VAR" ]; then token="$(eval echo \$$CC_TOKEN_VAR)" @@ -205,8 +216,8 @@ then 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 \ +say " $b$bin $(echo "${cc_cli_args[@]}") create-commit$token_str $(echo "${cc_cc_args[@]}")$x" +if ! $bin \ ${cc_cli_args[*]} \ create-commit \ ${token_arg[*]} \ @@ -216,8 +227,8 @@ then 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 \ +say " $b$bin $(echo "${cc_cli_args[@]}") create-report$token_str $(echo "${cc_cr_args[@]}")$x" +if ! $bin \ ${cc_cli_args[*]} \ create-report \ ${token_arg[*]} \ @@ -227,8 +238,8 @@ then 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" -if ! ./$cc_filename \ +say " $b$bin $(echo "${cc_cli_args[@]}") do-upload$token_str $(echo "${cc_du_args[@]}")$x" +if ! $bin \ ${cc_cli_args[*]} \ do-upload \ ${token_arg[*]} \ diff --git a/env b/env index 9308138..909d602 100644 --- a/env +++ b/env @@ -39,6 +39,7 @@ CC_SLUG CC_SWIFT_PROJECT CC_TOKEN CC_TOKEN_VAR +CC_USE_PYTHON CC_VERBOSE CC_VERSION CC_WRAPPER_VERSION