Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using codecovcli as the uploader #152

Merged
merged 13 commits into from
Sep 21, 2023
31 changes: 18 additions & 13 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,36 @@ jobs:
- codecov/upload:
flags: backend
- codecov/upload:
cli_args: -v
file: coverage/coverage-final.json
flags: frontend
xtra_args: -v -Z
upload_args: -Z
- codecov/upload:
file: coverage/coverage-final.json
flags: alpine
version: v0.1.0_8880
version: v0.2.2
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
ENV_VAR_CONTAINING_FLAG: env_var_flag
test-linux:
docker:
- image: cimg/base:stable
- image: cimg/base:current
steps:
- checkout
- attach_workspace:
at: .
- codecov/upload:
flags: backend
- codecov/upload:
cli_args: -v
file: coverage/coverage-final.json
flags: frontend
xtra_args: -v -Z
upload_args: -Z
- codecov/upload:
file: coverage/coverage-final.json
flags: linux
version: v0.1.0_8880
version: v0.2.2
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
Expand All @@ -98,13 +100,14 @@ jobs:
- codecov/upload:
flags: backend
- codecov/upload:
cli_args: -v
file: coverage/coverage-final.json
flags: frontend
xtra_args: -v -Z
upload_args: -Z
- codecov/upload:
file: coverage/coverage-final.json
flags: macos
version: v0.1.0_8880
version: v0.2.2
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
Expand All @@ -120,13 +123,14 @@ jobs:
- codecov/upload:
flags: backend
- codecov/upload:
cli_args: -v
file: coverage/coverage-final.json
flags: frontend
xtra_args: -v -Z
upload_args: -Z
- codecov/upload:
file: coverage/coverage-final.json
flags: windows
version: v0.1.0_8880
version: v0.2.2
- codecov/upload:
flags: string_flag,ENV_VAR_CONTAINING_FLAG
environment:
Expand All @@ -139,9 +143,10 @@ workflows:
filters: *filters
- test-frontend:
filters: *filters
- test-alpine:
filters: *filters
requires: [test-backend, test-frontend]

# - test-alpine:
# filters: *filters
# requires: [test-backend, test-frontend]

- test-linux:
filters: *filters
Expand All @@ -157,7 +162,7 @@ workflows:

- orb-tools/pack:
filters: *filters
requires: [test-alpine, test-linux, test-macos, test-windows]
requires: [test-linux, test-macos, test-windows]

- orb-tools/publish:
enable-pr-comment: false
Expand Down
25 changes: 15 additions & 10 deletions src/commands/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ description: |
`gnupg` in order to validate.

parameters:
cli_args:
description: Any extra arguments provided to the CLI the CLI
(e.g. `-v`).
type: string
default: ""
file:
description: Path to the code coverage data file to upload.
type: string
Expand All @@ -26,24 +31,23 @@ parameters:
description: Custom defined name of the upload. Visible in Codecov UI
type: string
default: ""
upload_args:
description: Any extra flags as provided to the `do-upload` step of the CLI
type: string
default: ""
validate:
description: Validate the uploader before uploading the codecov result.
type: boolean
default: true
when:
description: When should this step run?
type: string
default: "always"
xtra_args:
description: Any extra flags as provided by the universal uploader
(e.g. `-v -Z`).
type: string
default: ""
version:
description: Which version of the Codecov Uploader to use (defaults to
'latest')
type: string
default: "latest"
when:
description: When should this step run?
type: string
default: "always"

steps:
- run:
Expand All @@ -64,8 +68,9 @@ steps:
name: Upload Coverage Results
command: <<include(scripts/upload.sh)>>
environment:
PARAM_CLI_ARGS: << parameters.cli_args >>
PARAM_FILE: << parameters.file >>
PARAM_FLAGS: << parameters.flags >>
PARAM_TOKEN: << parameters.token >>
PARAM_UPLOAD_ARGS: << parameters.upload_args >>
PARAM_UPLOAD_NAME: << parameters.upload_name >>
PARAM_XTRA_ARGS: << parameters.xtra_args >>
2 changes: 1 addition & 1 deletion src/scripts/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ codecov_filename="codecov"
echo "export codecov_filename=${codecov_filename}" >> $BASH_ENV
[[ $codecov_os == "macos" ]] && \
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
codecov_url="https://uploader.codecov.io"
codecov_url="https://cli.codecov.io"
codecov_url="$codecov_url/${PARAM_VERSION}"
codecov_url="$codecov_url/${codecov_os}/${codecov_filename}"
echo "Downloading ${codecov_url}"
Expand Down
18 changes: 15 additions & 3 deletions src/scripts/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ source $BASH_ENV
chmod +x $codecov_filename
[ -n "${PARAM_FILE}" ] && \
set - "${@}" "-f" "${PARAM_FILE}"
[ -n "${PARAM_XTRA_ARGS}" ] && \
set - "${@}" "${PARAM_XTRA_ARGS}"
[ -n "${PARAM_UPLOAD_ARGS}" ] && \
set - "${@}" "${PARAM_UPLOAD_ARGS}"
[ -n "${PARAM_UPLOAD_NAME}" ] && \
PARAM_UPLOAD_NAME="${CIRCLE_BUILD_NUM}"

Expand All @@ -26,9 +26,21 @@ for flag in $PARAM_FLAGS; do
done
IFS=$OLDIFS

#create commit
./"$codecov_filename" \
create-commit \
-t "$(eval echo \$$PARAM_TOKEN)" \

#create report
./"$codecov_filename" \
create-report \
-t "$(eval echo \$$PARAM_TOKEN)" \

#upload reports
# alpine doesn't allow for indirect expansion
./"$codecov_filename" \
-Q "codecov-circleci-orb-3.2.5" \
\$$PARAM_UPLOAD_ARGS \
do-upload \
-t "$(eval echo \$$PARAM_TOKEN)" \
-n "${PARAM_UPLOAD_NAME}" \
-F "${FLAGS}" \
Expand Down
20 changes: 10 additions & 10 deletions src/scripts/validate.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
source $BASH_ENV
source "$BASH_ENV"
echo "${CODECOV_PUBLIC_PGP_KEY}" | \
gpg --no-default-keyring --keyring trustedkeys.gpg --import
gpg --no-default-keyring --keyring trustedkeys.kbx --import
# One-time step
sha_url="https://uploader.codecov.io"
sha_url="$sha_url/${codecov_version}/${codecov_os}"
sha_url="$sha_url/${codecov_filename}.SHA256SUM"
sha_url="https://cli.codecov.io"
sha_url="${sha_url}/${codecov_version}/${codecov_os}"
sha_url="${sha_url}/${codecov_filename}.SHA256SUM"
echo "Downloading ${sha_url}"
curl -Os $sha_url
curl -Os $sha_url".sig"
gpgv $codecov_filename.SHA256SUM.sig $codecov_filename.SHA256SUM
shasum -a 256 -c $codecov_filename.SHA256SUM || \
sha256sum -c $codecov_filename.SHA256SUM
curl -Os "$sha_url"
curl -Os "${sha_url}.sig"
gpgv "${codecov_filename}.SHA256SUM.sig" "${codecov_filename}.SHA256SUM"
shasum -a 256 -c "${codecov_filename}.SHA256SUM" || \
sha256sum -c "${codecov_filename}.SHA256SUM"