Skip to content
Open
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/coverage

# production
/build
/dist

# misc
Expand Down
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ node_js:
- 7
cache:
yarn: true
directories:
- node_modules

before_install:
- pip install --user awscli
- export PATH=$PATH:$HOME/.local/bin

script:
- yarn run coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- yarn run build
- yarn run build-storybook
- node ./build/aws-deploy.js

after_script:
# TODO comment on PR with link to PR storybook on S3 and notify slack room
- echo "PR storybook can be found at:"
- echo "http://react-audio-vis-prs.s3-ap-southeast-2.amazonaws.com/$TRAVIS_PULL_REQUEST_BRANCH/index.html"
24 changes: 24 additions & 0 deletions build/aws-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const execSync = require('child_process').execSync;

const isPrBuild = (prBranch) => {
return prBranch && prBranch !== "master";
};

const staticSizeNotTooLarge = (staticBookSize) => {
const tenMB = 10 * (2 << 9);
return !isNaN(staticBookSize) && staticBookSize < tenMB;
};

const {TRAVIS_PULL_REQUEST_BRANCH: prBranch} = process.env;
console.log(prBranch);
if (isPrBuild(prBranch)) {
const result = execSync(`du -sk storybook-static | sed 's/[^0-9]*//g'`);
const staticBookSize = Number.parseInt(result.toString());

if (staticSizeNotTooLarge(staticBookSize)) {
const result = execSync(
`aws s3 cp ${__dirname}/../storybook-static s3://react-audio-vis-prs/${prBranch} --recursive`,
{stdio: [0, 1, 2]}
);
}
}