Skip to content

Commit

Permalink
implement retry functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Schmidt committed Jul 10, 2018
1 parent 3eb2d32 commit 56104a2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions scripts/publish-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then

cd website
npm install
npm run gatherDocs
GIT_USER=$GIT_USER CURRENT_BRANCH=master npm run publish-gh-pages
else
echo 'Not deploying the website'
Expand Down
32 changes: 28 additions & 4 deletions website/gatherDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@ async function generateDocumentation(versions, tempDir) {
}
}

async function generate(versions, currentAttempt = 1) {
const maxAttempts = 3;
let success;
const tempDir = fs.mkdtempSync('detox-documentation-generation');
try {
await generateDocumentation(versions, tempDir);
success = true;
} catch (e) {
console.log('Error while generating documentation', e);
success = false;
} finally {
await cleanUp(tempDir);
}

if (success) {
return;
}

if (currentAttempt < maxAttempts) {
await generate(versions, currentAttempt + 1);
} else {
console.error(`Generation failed ${maxAttempts} times, there seems to be a real problem, please file an issue`);
process.exit(1);
}
}

async function cleanUp(tempDir) {
console.log('Cleanup temporary clone');
await fs.remove(tempDir);
Expand All @@ -115,9 +141,7 @@ async function cleanUp(tempDir) {
(async function() {
const versions = await getVersions();
await cleanupExistingVersions();

fs.writeFileSync('./versions.json', JSON.stringify(versions), 'utf8');
const tempDir = fs.mkdtempSync('detox-documentation-generation');
await generateDocumentation(versions, tempDir)
await cleanUp(tempDir);

await generate(versions);
})();

0 comments on commit 56104a2

Please sign in to comment.