Skip to content

Retry code coverage upload 3 times and don't fail build #108

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

Merged
merged 8 commits into from
Aug 12, 2020
Merged
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _refs:
name: Upload coverage to codecov.io
command: |
./node_modules/nyc/bin/nyc.js report --reporter=lcov
curl -s https://codecov.io/bash | bash -s -- -f ./test-results/coverage/lcov.info
node ./scripts/uploadCodeCoverage.js
gus-prepare-environment-variables: &gus-prepare-environment-variables
name: 'Prepare environment variables for GUS Change Case Management'
command: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"local:install": "./scripts/localInstall.js install",
"local:link": "./scripts/localInstall.js link",
"local:unlink": "./scripts/localInstall.js unlink",
"test": "shx rm -rf ./test-results && nyc mocha && node ./scripts/verifyTestArtifacts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed verifyTestArtifacts script because this used to help guard against silent compile errors in the test job. Now that we removed ts-node and compile tests in the build phase, we have that protection "built in" now.

"test": "shx rm -rf ./test-results && nyc mocha",
"update:registry": "node ./scripts/metadata-registry/update.js"
},
"husky": {
Expand Down
32 changes: 32 additions & 0 deletions scripts/uploadCodeCoverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to change the perms on this file so it's executable, similar to the publish.js script (-rwxr-xr-x vs -rw-r--r--)


const { execSilent } = require('./util');
Copy link
Contributor

Choose a reason for hiding this comment

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

shebang and wait for @lcampos for license comment :)


/**
* Script for publishing code coverage results to Codecov.io. Intended to run
* during a CircleCI job.
*
* Not using path.join for the path to coverage report because in the Windows job,
* this script runs with bash.exe to allow running the codecov.io publish script.
* Hence using a Windows formatted path will confuse the process.
*/

const MAX_ATTEMPTS = 3;

let attempts = 0;

do {
try {
const result = execSilent('curl -s https://codecov.io/bash | bash -s -- -f test-results/coverage/lcov.info');
console.log(result.stdout);
break;
} catch (e) {
attempts += 1;
let message = `Failed to publish coverage results on attempt ${attempts}`;
if (attempts < MAX_ATTEMPTS) {
message += ' - trying again...';
}
console.log(message);
console.log(e.message);
}
} while (attempts < MAX_ATTEMPTS);
12 changes: 0 additions & 12 deletions scripts/verifyTestArtifacts.js

This file was deleted.