diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-28 14:46:36 +0200 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-29 13:04:06 +0200 |
commit | 98f99039e3cf0d3fc5c61cdf7ecf82e08be02629 (patch) | |
tree | 5a30b496396b6721e46ed2382098ea4263821ed5 | |
parent | 4e335d0b050c6d5b94ae0d28cb4fd36b939ad84b (diff) | |
download | qtlocation-mapboxgl-upstream/nagineni-core-code-coverage_test.tar.gz |
[scripts] Add retry timer for collecting codecov reportupstream/nagineni-core-code-coverage_test
-rw-r--r-- | circle.yml | 4 | ||||
-rwxr-xr-x | scripts/publish_core_codecoverage.js | 44 |
2 files changed, 31 insertions, 17 deletions
diff --git a/circle.yml b/circle.yml index 45b6f1413c..54c1a02d19 100644 --- a/circle.yml +++ b/circle.yml @@ -879,9 +879,7 @@ jobs: - run: name: Upload coverage metrics to s3 command: | - if [[ $CIRCLE_BRANCH == master ]]; then - scripts/publish_core_codecoverage.js -p Linux -s Core - fi + scripts/publish_core_codecoverage.js -p Linux -s Core # ------------------------------------------------------------------------------ linux-doxygen: diff --git a/scripts/publish_core_codecoverage.js b/scripts/publish_core_codecoverage.js index b490a2fee7..8c7623b5b0 100755 --- a/scripts/publish_core_codecoverage.js +++ b/scripts/publish_core_codecoverage.js @@ -121,7 +121,7 @@ function httpRequest() { reject(error); }).on('end', () => { if (res.statusCode < 200 || res.statusCode >= 300) { - return reject(new Error('Failed to fetch the results from codecov.io. StatusCode=' + res.statusCode)); + return reject(new Error('Failed to fetch results from codecov.io. StatusCode=' + res.statusCode)); } try { @@ -139,19 +139,35 @@ function httpRequest() { }); req.end(); - }, 30000); + }, 3000); }); } -httpRequest().then((body) => { - const dataSource = parseResponse(body); - if (dataSource) { - return uploadData(dataSource); - } else { - throw new Error('Failed to parse the results received from codecov.io.'); - } -}).then(data => { - console.log('Successfully uploaded code coverage metrics to S3'); -}).catch(err => { - console.error('Failed to upload code coverage metrics to S3: ' + err.message); -}); +var errResponse = false; +const publishWithRetry = (maxRetries) => { + httpRequest().then((body) => { + const dataSource = parseResponse(body); + if (dataSource) { + console.log(JSON.stringify(dataSource)); + //return uploadData(dataSource); + } else { + console.log("Failed to Parse", maxRetries); + errResponse = true; + throw new Error('Failed to parse results received from codecov.io.'); + } + }).then(data => { + console.log('Successfully uploaded code coverage metrics to S3'); + }).catch(err => { + if (maxRetries > 1 && errResponse) { + console.log('Failed to parse results. Trying again', maxRetries); + errResponse = false; + return publishWithRetry(maxRetries - 1); + } + + console.error('Failed to upload code coverage metrics to S3: ' + err.message); + }); +}; + +// Attempt to fetch and publish code coverage report +// with retry behavior. +publishWithRetry(15); |