Skip to content

Commit

Permalink
feat: use-python
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov committed Jan 22, 2025
1 parent fc1e2e7 commit 1709cb9
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 106 deletions.
113 changes: 60 additions & 53 deletions dist/codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ then
else
exit_if_error "Could not find binary file $CC_BINARY"
fi
elif [ "$CC_USE_PYPI" == "true" ];
then
if ! pip install codecov-cli; then
exit_if_error "Could not install via pypi."
exit
fi
cc_command="codecovcli"
else
if [ -n "$CC_OS" ];
then
Expand Down Expand Up @@ -89,9 +96,9 @@ else
say " Version: $b$version$x"
say " "
fi
if [ "$CC_SKIP_VALIDATION" = "true" ] || [ -n "$CC_BINARY" ];
if [ "$CC_SKIP_VALIDATION" == "true" ] || [ -n "$CC_BINARY" ] || [ "$CC_USE_PYPI" == "true" ];
then
say "$r==>$x Bypassing validation as requested by user"
say "$r==>$x Bypassing validation..."
else
CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
echo "${CC_PUBLIC_PGP_KEY}" | \
Expand Down Expand Up @@ -152,86 +159,86 @@ then
token_arg+=( " -t " "$token")
fi
if [ "$CC_RUN_COMMAND" == "upload-coverage" ]; then
cc_run_args=()
cc_args=()
# Args for create commit
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_run_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
cc_run_args+=( $(k_arg PR) $(v_arg PR))
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
cc_args+=( $(k_arg PR) $(v_arg PR))
cc_args+=( $(k_arg SHA) $(v_arg SHA))
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
# Args for create report
cc_run_args+=( $(k_arg CODE) $(v_arg CODE))
cc_args+=( $(k_arg CODE) $(v_arg CODE))
# Args for do upload
cc_run_args+=( $(k_arg ENV) $(v_arg ENV))
cc_args+=( $(k_arg ENV) $(v_arg ENV))
OLDIFS=$IFS;IFS=,
cc_run_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
cc_run_args+=( $(k_arg BUILD) $(v_arg BUILD))
cc_run_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
cc_run_args+=( $(k_arg DIR) $(v_arg DIR))
cc_run_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) )
cc_run_args+=( $(write_truthy_args CC_DISABLE_SEARCH) )
cc_run_args+=( $(write_truthy_args CC_DRY_RUN) )
cc_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
cc_args+=( $(k_arg BUILD) $(v_arg BUILD))
cc_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
cc_args+=( $(k_arg DIR) $(v_arg DIR))
cc_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) )
cc_args+=( $(write_truthy_args CC_DISABLE_SEARCH) )
cc_args+=( $(write_truthy_args CC_DRY_RUN) )
if [ -n "$CC_EXCLUDES" ];
then
for directory in $CC_EXCLUDES; do
cc_run_args+=( "--exclude" "$directory" )
cc_args+=( "--exclude" "$directory" )
done
fi
if [ -n "$CC_FILES" ];
then
for file in $CC_FILES; do
cc_run_args+=( "--file" "$file" )
cc_args+=( "--file" "$file" )
done
fi
if [ -n "$CC_FLAGS" ];
then
for flag in $CC_FLAGS; do
cc_run_args+=( "--flag" "$flag" )
cc_args+=( "--flag" "$flag" )
done
fi
cc_run_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
cc_run_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
cc_run_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
cc_run_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
cc_run_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
cc_run_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
cc_run_args+=( $(write_truthy_args CC_LEGACY) )
cc_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
cc_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
cc_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
cc_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
cc_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
cc_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
cc_args+=( $(write_truthy_args CC_LEGACY) )
if [ -n "$CC_NAME" ];
then
cc_run_args+=( "--name" "$CC_NAME" )
cc_args+=( "--name" "$CC_NAME" )
fi
cc_run_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
cc_run_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
cc_run_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
cc_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
cc_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
cc_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
if [ -n "$CC_PLUGINS" ];
then
for plugin in $CC_PLUGINS; do
cc_run_args+=( "--plugin" "$plugin" )
cc_args+=( "--plugin" "$plugin" )
done
fi
cc_run_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
cc_run_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
cc_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
cc_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
IFS=$OLDIFS
elif [ "$CC_RUN_COMMAND" == "empty-upload" ]; then
cc_run_args=()
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_run_args+=( $(write_truthy_args CC_FORCE) )
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
cc_args=()
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_args+=( $(write_truthy_args CC_FORCE) )
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_args+=( $(k_arg SHA) $(v_arg SHA))
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
elif [ "$CC_RUN_COMMAND" == "pr-base-picking" ]; then
cc_run_args=()
cc_run_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
cc_run_args+=( $(k_arg PR) $(v_arg PR))
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
cc_run_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
cc_args=()
cc_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
cc_args+=( $(k_arg PR) $(v_arg PR))
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
cc_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
elif [ "$CC_RUN_COMMAND" == "send-notifications" ]; then
cc_run_args=()
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
cc_args=()
cc_args+=( $(k_arg SHA) $(v_arg SHA))
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
else
exit_if_error "Invalid run command specified: $CC_RUN_COMMAND"
exit
Expand All @@ -240,12 +247,12 @@ unset NODE_OPTIONS
# See https://github.com/codecov/uploader/issues/475
chmod +x "$cc_command"
say "$g==>$x Running $CC_RUN_COMMAND"
say " $b$cc_command $(echo "${cc_cli_args[@]}")$CC_RUN_COMMAND$token_str $(echo "${cc_run_args[@]}")$x"
say " $b$cc_command $(echo "${cc_cli_args[@]}")$CC_RUN_COMMAND$token_str $(echo "${cc_args[@]}")$x"
if ! $cc_command \
${cc_cli_args[*]} \
${CC_RUN_COMMAND} \
${token_arg[*]} \
"${cc_run_args[@]}";
"${cc_args[@]}";
then
exit_if_error "Failed to run $CC_RUN_COMMAND"
fi
1 change: 1 addition & 0 deletions env
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CC_SLUG
CC_SWIFT_PROJECT
CC_TOKEN
CC_TOKEN_VAR
CC_USE_PYPI
CC_VERBOSE
CC_VERSION
CC_WRAPPER_VERSION
Expand Down
7 changes: 7 additions & 0 deletions scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ then
else
exit_if_error "Could not find binary file $CODECOV_BINARY"
fi
elif [ "$CODECOV_USE_PYPI" == "true" ];
then
if ! pip install codecov-cli; then
exit_if_error "Could not install via pypi."
exit
fi
codecov_command="codecovcli"
else
if [ -n "$CODECOV_OS" ];
then
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ unset NODE_OPTIONS
chmod +x "$codecov_command"

say "$g==>$x Running $CODECOV_RUN_COMMAND"
say " $b$codecov_command $(echo "${codecov_cli_args[@]}")$CODECOV_RUN_COMMAND$token_str $(echo "${codecov_run_args[@]}")$x"
say " $b$codecov_command $(echo "${codecov_cli_args[@]}")$CODECOV_RUN_COMMAND$token_str $(echo "${codecov_args[@]}")$x"
if ! $codecov_command \
${codecov_cli_args[*]} \
${CODECOV_RUN_COMMAND} \
${token_arg[*]} \
"${codecov_run_args[@]}";
"${codecov_args[@]}";
then
exit_if_error "Failed to run $CODECOV_RUN_COMMAND"
fi
12 changes: 6 additions & 6 deletions scripts/set_empty_upload_args.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

codecov_run_args=()
codecov_args=()

codecov_run_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_run_args+=( $(write_truthy_args CODECOV_FORCE) )
codecov_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_run_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
codecov_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_args+=( $(write_truthy_args CODECOV_FORCE) )
codecov_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_args+=( $(k_arg SLUG) $(v_arg SLUG))
10 changes: 5 additions & 5 deletions scripts/set_pr_base_picking_args.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

codecov_run_args=()
codecov_args=()

codecov_run_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
codecov_run_args+=( $(k_arg PR) $(v_arg PR))
codecov_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
codecov_run_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
codecov_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
codecov_args+=( $(k_arg PR) $(v_arg PR))
codecov_args+=( $(k_arg SLUG) $(v_arg SLUG))
codecov_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
10 changes: 5 additions & 5 deletions scripts/set_send_notifications_args.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

codecov_run_args=()
codecov_args=()

codecov_run_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_run_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
codecov_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_args+=( $(k_arg SLUG) $(v_arg SLUG))
66 changes: 33 additions & 33 deletions scripts/set_upload_coverage_args.sh
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
#!/usr/bin/env bash

codecov_run_args=()
codecov_args=()

# Args for create commit
codecov_run_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_run_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
codecov_run_args+=( $(k_arg PR) $(v_arg PR))
codecov_run_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
codecov_args+=( $(write_truthy_args CODECOV_FAIL_ON_ERROR) )
codecov_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
codecov_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
codecov_args+=( $(k_arg PR) $(v_arg PR))
codecov_args+=( $(k_arg SHA) $(v_arg SHA))
codecov_args+=( $(k_arg SLUG) $(v_arg SLUG))

# Args for create report
codecov_run_args+=( $(k_arg CODE) $(v_arg CODE))
codecov_args+=( $(k_arg CODE) $(v_arg CODE))

# Args for do upload
codecov_run_args+=( $(k_arg ENV) $(v_arg ENV))
codecov_args+=( $(k_arg ENV) $(v_arg ENV))

OLDIFS=$IFS;IFS=,

codecov_run_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
codecov_run_args+=( $(k_arg BUILD) $(v_arg BUILD))
codecov_run_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
codecov_run_args+=( $(k_arg DIR) $(v_arg DIR))
codecov_run_args+=( $(write_truthy_args CODECOV_DISABLE_FILE_FIXES) )
codecov_run_args+=( $(write_truthy_args CODECOV_DISABLE_SEARCH) )
codecov_run_args+=( $(write_truthy_args CODECOV_DRY_RUN) )
codecov_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
codecov_args+=( $(k_arg BUILD) $(v_arg BUILD))
codecov_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
codecov_args+=( $(k_arg DIR) $(v_arg DIR))
codecov_args+=( $(write_truthy_args CODECOV_DISABLE_FILE_FIXES) )
codecov_args+=( $(write_truthy_args CODECOV_DISABLE_SEARCH) )
codecov_args+=( $(write_truthy_args CODECOV_DRY_RUN) )

if [ -n "$CODECOV_EXCLUDES" ];
then
for directory in $CODECOV_EXCLUDES; do
codecov_run_args+=( "--exclude" "$directory" )
codecov_args+=( "--exclude" "$directory" )
done
fi

if [ -n "$CODECOV_FILES" ];
then
for file in $CODECOV_FILES; do
codecov_run_args+=( "--file" "$file" )
codecov_args+=( "--file" "$file" )
done
fi

if [ -n "$CODECOV_FLAGS" ];
then
for flag in $CODECOV_FLAGS; do
codecov_run_args+=( "--flag" "$flag" )
codecov_args+=( "--flag" "$flag" )
done
fi

codecov_run_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
codecov_run_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
codecov_run_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
codecov_run_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
codecov_run_args+=( $(write_truthy_args CODECOV_HANDLE_NO_REPORTS_FOUND) )
codecov_run_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
codecov_run_args+=( $(write_truthy_args CODECOV_LEGACY) )
codecov_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
codecov_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
codecov_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
codecov_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
codecov_args+=( $(write_truthy_args CODECOV_HANDLE_NO_REPORTS_FOUND) )
codecov_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
codecov_args+=( $(write_truthy_args CODECOV_LEGACY) )
if [ -n "$CODECOV_NAME" ];
then
codecov_run_args+=( "--name" "$CODECOV_NAME" )
codecov_args+=( "--name" "$CODECOV_NAME" )
fi
codecov_run_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
codecov_run_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
codecov_run_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
codecov_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
codecov_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
codecov_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))

if [ -n "$CODECOV_PLUGINS" ];
then
for plugin in $CODECOV_PLUGINS; do
codecov_run_args+=( "--plugin" "$plugin" )
codecov_args+=( "--plugin" "$plugin" )
done
fi

codecov_run_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
codecov_run_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
codecov_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
codecov_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))

IFS=$OLDIFS
4 changes: 2 additions & 2 deletions scripts/validate.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

if [ "$CODECOV_SKIP_VALIDATION" = "true" ] || [ -n "$CODECOV_BINARY" ];
if [ "$CODECOV_SKIP_VALIDATION" == "true" ] || [ -n "$CODECOV_BINARY" ] || [ "$CODECOV_USE_PYPI" == "true" ];
then
say "$r==>$x Bypassing validation as requested by user"
say "$r==>$x Bypassing validation..."
else
. ./set_validation_key.sh
echo "${CODECOV_PUBLIC_PGP_KEY}" | \
Expand Down

0 comments on commit 1709cb9

Please sign in to comment.