Skip to content
Open
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
28 changes: 28 additions & 0 deletions scripts/openshiftci-presubmit-unittests.sh
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the token is not mounted, is this expected?

+ set +e
+ CODECOV_TOKEN_FILE=/var/run/codecov-token/CODECOV_TOKEN
+ [[ ! -f /var/run/codecov-token/CODECOV_TOKEN ]]
+ echo 'Codecov token not found at /var/run/codecov-token/CODECOV_TOKEN, skipping upload'
Codecov token not found at /var/run/codecov-token/CODECOV_TOKEN, skipping upload
+ exit 0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,31 @@ cd ../..

# Run unit
make test

# Upload coverage to codecov.io - failures here should not fail the build
(
set +e
CODECOV_TOKEN_FILE="/var/run/codecov-token/CODECOV_TOKEN"
if [[ ! -f "${CODECOV_TOKEN_FILE}" ]]; then
echo "Codecov token not found at ${CODECOV_TOKEN_FILE}, skipping upload"
exit 0
fi
CODECOV_TOKEN="$(cat "${CODECOV_TOKEN_FILE}")"
COMMIT="$(git rev-parse HEAD)"
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
QUERY="token=${CODECOV_TOKEN}&commit=${COMMIT}&branch=${BRANCH}&flags=unit-tests"

# Step 1: request an upload slot; response is two lines: report URL, S3 URL.
RESPONSE=$(curl -sX POST -H 'Accept: text/plain' "https://codecov.io/upload/v4?${QUERY}")
S3_URL=$(echo "${RESPONSE}" | sed -n 2p)
if [[ -z "${S3_URL}" ]]; then
echo "Codecov did not return an upload URL, aborting"
exit 1
fi

# Step 2: PUT the coverage file to GCS (Codecov uses GCS, not AWS S3;
# x-amz-storage-class is not supported and causes a 400).
curl -fiX PUT --data-binary @cover.out \
-H 'Content-Type: text/plain' \
"${S3_URL}"
) || echo "Coverage upload to codecov.io failed, continuing"
Loading