Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@

[![codecov.io](https://codecov.io/github/codecov/codecov-circleci-orb/coverage.svg?branch=main)](https://codecov.io/github/codecov/codecov-circleci-orb)
[![Circle CI](https://circleci.com/gh/codecov/codecov-circleci-orb.png?style=badge)](https://circleci.com/gh/codecov/codecov-circleci-orb)

CircleCI orb for uploading coverage reports to [Codecov](https://codecov.io).

This orb embeds the [Codecov Wrapper](https://github.com/codecov/wrapper) (`0.3.0`).

## Parameters

See [`src/commands/upload.yml`](./src/commands/upload.yml) for the full parameter list. Notable options:

- `cleanup` — when `true`, download the CLI into a temporary directory and remove it after the run (off by default)
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codecov-circleci-orb",
"version": "6.0.0",
"version": "6.1.0",
"description": "Codecov CircleCI Orb",
"main": "index.js",
"devDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions src/commands/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ parameters:
description: The URL of the build where this is running
type: string
default: ""
cleanup:
description: If true, download the CLI into a temporary directory and clean it up after the run. Off by default to preserve legacy behavior of downloading into the current working directory.
type: boolean
default: false
code:
description: The code of the report if using local upload. If unsure, leave default. Read more here https://docs.codecov.com/docs/the-codecov-cli#how-to-use-local-upload
type: string
Expand Down Expand Up @@ -185,6 +189,7 @@ steps:
CODECOV_BRANCH: << parameters.branch >>
CODECOV_BUILD: << parameters.build >>
CODECOV_BUILD_URL: << parameters.build_url >>
CODECOV_CLEANUP: <<#parameters.cleanup>>true<</parameters.cleanup>><<^parameters.cleanup>>false<</parameters.cleanup>>
CODECOV_CLI_TYPE: codecov-cli
CODECOV_CODE: << parameters.code >>
CODECOV_DIR: << parameters.dir >>
Expand Down
15 changes: 12 additions & 3 deletions src/dist/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ then
else
exit_if_error "Could not find binary file $CODECOV_BINARY"
fi
elif [ "$CODECOV_USE_PYPI" == "true" ];
elif [ "$CODECOV_USE_PYPI" == "true" ] || [ "$CODECOV_USE_PYPI" == "1" ];
then
if ! pip install "${CODECOV_CLI_TYPE}$([ "$CODECOV_VERSION" == "latest" ] && echo "" || echo "==$CODECOV_VERSION")"; then
exit_if_error "Could not install via pypi."
Expand All @@ -69,6 +69,15 @@ then
CODECOV_COMMAND="${CODECOV_CLI_TYPE}"
fi
else
CODECOV_DOWNLOAD_DIR="."
if [ "$CODECOV_CLEANUP" == "true" ]; then
CODECOV_DOWNLOAD_DIR=$(mktemp -d)
cleanup_downloads() {
rm -rf "$CODECOV_DOWNLOAD_DIR"
}
trap cleanup_downloads EXIT
fi

if [ -n "$CODECOV_OS" ];
then
say "$g==>$x Overridden OS: $b${CODECOV_OS}$x"
Expand All @@ -86,15 +95,15 @@ else

CODECOV_FILENAME="${CODECOV_CLI_TYPE%-cli}"
[[ $CODECOV_OS == "windows" ]] && CODECOV_FILENAME+=".exe"
CODECOV_COMMAND="./$CODECOV_FILENAME"
CODECOV_COMMAND="$CODECOV_DOWNLOAD_DIR/$CODECOV_FILENAME"
[[ $CODECOV_OS == "macos" ]] && \
! command -v gpg 2>&1 >/dev/null && \
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
CODECOV_URL="${CODECOV_CLI_URL:-https://cli.codecov.io}"
CODECOV_URL="$CODECOV_URL/${CODECOV_VERSION}"
CODECOV_URL="$CODECOV_URL/${CODECOV_OS}/${CODECOV_FILENAME}"
say "$g ->$x Downloading $b${CODECOV_URL}$x"
curl -O $retry "$CODECOV_URL"
curl -o "$CODECOV_COMMAND" $retry "$CODECOV_URL"
say "$g==>$x Finishing downloading $b${CODECOV_OS}:${CODECOV_VERSION}$x"

v_url="https://cli.codecov.io/api/${CODECOV_OS}/${CODECOV_VERSION}"
Expand Down
3 changes: 2 additions & 1 deletion src/dist/set_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ r="\033[0;31m" # errors
x="\033[0m"
retry="--retry 5 --retry-delay 2"

CODECOV_WRAPPER_VERSION="0.2.9"
CODECOV_WRAPPER_VERSION="0.3.0"
CODECOV_VERSION="${CODECOV_VERSION:-latest}"
CODECOV_FAIL_ON_ERROR="${CODECOV_FAIL_ON_ERROR:-false}"
CODECOV_RUN_CMD="${CODECOV_RUN_CMD:-upload-coverage}"
CODECOV_CLI_TYPE=${CODECOV_CLI_TYPE:-"codecov-cli"}
CODECOV_CLEANUP="${CODECOV_CLEANUP:-false}"

say " _____ _
/ ____| | |
Expand Down
40 changes: 29 additions & 11 deletions src/dist/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,30 @@ r="\033[0;31m" # errors
x="\033[0m"
retry="--retry 5 --retry-delay 2"

if [ "$CODECOV_SKIP_VALIDATION" == "true" ] || [ -n "$CODECOV_BINARY" ] || [ "$CODECOV_USE_PYPI" == "true" ];
if [ "$CODECOV_SKIP_VALIDATION" == "true" ] || [ "$CODECOV_SKIP_VALIDATION" == "1" ] || [ -n "$CODECOV_BINARY" ] || [ "$CODECOV_USE_PYPI" == "true" ] || [ "$CODECOV_USE_PYPI" == "1" ];
then
say "$r==>$x Bypassing validation..."
if [ "$CODECOV_SKIP_VALIDATION" == "true" ];
if [ "$CODECOV_SKIP_VALIDATION" == "true" ] || [ "$CODECOV_SKIP_VALIDATION" == "1" ];
then
chmod +x "$CODECOV_COMMAND"
fi
else
echo "$(curl -s https://keybase.io/codecovsecops/pgp_keys.asc)" | \
gpg --no-default-keyring --import
# One-time step
gpg_key_url="https://keybase.io/codecovsecops/pgp_keys.asc"
gpg_import_ok=false
for gpg_attempt in 1 2 3; do
if curl -sf $retry "$gpg_key_url" | gpg --no-default-keyring --import; then
gpg_import_ok=true
break
fi
if [ "$gpg_attempt" -lt 3 ]; then
say "$r ->$x GPG key import attempt $gpg_attempt failed, retrying..."
sleep 2
fi
done
if [ "$gpg_import_ok" != "true" ]; then
exit_if_error "Could not import GPG verification key after 3 attempts. Please contact Codecov if problem continues"
fi

say "$g==>$x Verifying GPG signature integrity"
sha_url="https://cli.codecov.io"
sha_url="${sha_url}/${CODECOV_VERSION}/${CODECOV_OS}"
Expand All @@ -65,16 +78,16 @@ else
say "$g ->$x Downloading $b${sha_url}.sig$x"
say " "

curl -Os $retry --connect-timeout 2 "$sha_url"
curl -Os $retry --connect-timeout 2 "${sha_url}.sig"
curl -o "$CODECOV_DOWNLOAD_DIR/${CODECOV_FILENAME}.SHA256SUM" -s $retry --connect-timeout 2 "$sha_url"
curl -o "$CODECOV_DOWNLOAD_DIR/${CODECOV_FILENAME}.SHA256SUM.sig" -s $retry --connect-timeout 2 "${sha_url}.sig"

if ! gpg --verify "${CODECOV_FILENAME}.SHA256SUM.sig" "${CODECOV_FILENAME}.SHA256SUM";
if ! gpg --verify "$CODECOV_DOWNLOAD_DIR/${CODECOV_FILENAME}.SHA256SUM.sig" "$CODECOV_DOWNLOAD_DIR/${CODECOV_FILENAME}.SHA256SUM";
then
exit_if_error "Could not verify signature. Please contact Codecov if problem continues"
fi

if ! (shasum -a 256 -c "${CODECOV_FILENAME}.SHA256SUM" 2>/dev/null || \
sha256sum -c "${CODECOV_FILENAME}.SHA256SUM");
if ! (cd "$CODECOV_DOWNLOAD_DIR" && (shasum -a 256 -c "${CODECOV_FILENAME}.SHA256SUM" 2>/dev/null || \
sha256sum -c "${CODECOV_FILENAME}.SHA256SUM"));
then
exit_if_error "Could not verify SHASUM. Please contact Codecov if problem continues"
fi
Expand All @@ -85,12 +98,17 @@ fi

if [ -n "$CODECOV_BINARY_LOCATION" ];
then
mkdir -p "$CODECOV_BINARY_LOCATION" && mv "$CODECOV_FILENAME" $_
mkdir -p "$CODECOV_BINARY_LOCATION" && mv "$CODECOV_COMMAND" "$CODECOV_BINARY_LOCATION/$CODECOV_FILENAME"
CODECOV_COMMAND="$CODECOV_BINARY_LOCATION/$CODECOV_FILENAME"
say "$g==>$x ${CODECOV_CLI_TYPE} binary moved to ${CODECOV_BINARY_LOCATION}"
fi

if [ "$CODECOV_DOWNLOAD_ONLY" = "true" ];
then
if [ "$CODECOV_CLEANUP" == "true" ] && [ -z "$CODECOV_BINARY_LOCATION" ]; then
cp "$CODECOV_COMMAND" "./$CODECOV_FILENAME"
CODECOV_COMMAND="./$CODECOV_FILENAME"
fi
say "$g==>$x ${CODECOV_CLI_TYPE} download only called. Exiting..."
exit
fi
Expand Down
2 changes: 1 addition & 1 deletion src/scripts