Skip to content

Commit

Permalink
Merge pull request #167 from codecov/joseph/circle-build-num-and-env-…
Browse files Browse the repository at this point in the history
…var-flags

Fix CIRCLE_BUILD_NUM bug and allows users to specify env vars as flags
  • Loading branch information
joseph-sentry committed Jul 26, 2023
2 parents 8c5bec2 + 91dbc64 commit 85246e6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ jobs:
file: coverage/coverage-final.json
flags: alpine
version: v0.1.0_8880
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
ENV_VAR_CONTAINING_FLAG: env_var_flag
test-linux:
docker:
- image: cimg/base:stable
Expand All @@ -80,6 +84,10 @@ jobs:
file: coverage/coverage-final.json
flags: linux
version: v0.1.0_8880
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
ENV_VAR_CONTAINING_FLAG: env_var_flag
test-macos:
macos:
xcode: 14.1
Expand All @@ -97,6 +105,10 @@ jobs:
file: coverage/coverage-final.json
flags: macos
version: v0.1.0_8880
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
ENV_VAR_CONTAINING_FLAG: env_var_flag
test-windows:
executor:
name: win/default
Expand All @@ -115,6 +127,10 @@ jobs:
file: coverage/coverage-final.json
flags: windows
version: v0.1.0_8880
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
ENV_VAR_CONTAINING_FLAG: env_var_flag

workflows:
integration-tests_deploy:
Expand Down
5 changes: 3 additions & 2 deletions src/commands/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ parameters:
default: ""
flags:
description: Flag the upload to group coverage metrics (e.g. unittests
| integration | ui,chrome)
| integration | ui,chrome). Flags can be input as strings or
environment variables.
type: string
default: ""
token:
Expand All @@ -24,7 +25,7 @@ parameters:
upload_name:
description: Custom defined name of the upload. Visible in Codecov UI
type: string
default: ${CIRCLE_BUILD_NUM}
default: ""
validate:
description: Validate the uploader before uploading the codecov result.
type: boolean
Expand Down
22 changes: 21 additions & 1 deletion src/scripts/upload.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,30 @@ chmod +x $codecov_filename
set - "${@}" "-f" "${PARAM_FILE}"
[ -n "${PARAM_XTRA_ARGS}" ] && \
set - "${@}" "${PARAM_XTRA_ARGS}"
[ -n "${PARAM_UPLOAD_NAME}" ] && \
PARAM_UPLOAD_NAME="${CIRCLE_BUILD_NUM}"

FLAGS=""
OLDIFS=$IFS;IFS=,
for flag in $PARAM_FLAGS; do
eval e="\$$flag"
for param in "${e}" "${flag}"; do
if [ -n "${param}" ]; then
if [ -n "${FLAGS}" ]; then
FLAGS="${FLAGS},${param}"
else
FLAGS="${param}"
fi
break
fi
done
done
IFS=$OLDIFS

# alpine doesn't allow for indirect expansion
./"$codecov_filename" \
-Q "codecov-circleci-orb-3.2.5" \
-t "$(eval echo \$$PARAM_TOKEN)" \
-n "${PARAM_UPLOAD_NAME}" \
-F "${PARAM_FLAGS}" \
-F "${FLAGS}" \
${@}

0 comments on commit 85246e6

Please sign in to comment.