Skip to content
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

ci: Travis build speed improvements #504

Merged
merged 18 commits into from
Mar 11, 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
25 changes: 12 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ addons:
packages:
- libgconf-2-4

# cache both yarn and Cypress binar
# also cache TypeScript builds, this only rebuilds when code changes
# cache both yarn and Cypress binary
cache:
yarn: true
npm: false # Caching npm makes yarn install faster but downloading and packaging up the cache makes this slower when enabled
directories:
- ~/.cache

Expand All @@ -35,23 +34,23 @@ before_install:
- export PATH="$HOME/.yarn/bin:$PATH"

install:
- yarn install --production=false
- yarn install

jobs:
include:
- stage: pull_request
script:
- >-
yarn concurrently
"yarn lint"
"yarn depcheck"
"yarn test"
yarn run-p -l
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, concurrently is about 40mb and npm-run-all/run-p pretty much do the same thing at a fraction of the size.

lint
depcheck
test
- >- # Chromatic and Cypress rely on Storybook being built, this will exit early if build-storybook fails
yarn build-storybook &&
yarn http-server docs -p 9001 & yarn wait-on http://localhost:9001 &&
yarn concurrently
"yarn chromatic --quiet --exit-zero-on-changes --storybook-build-dir docs"
"yarn cypress run --record" &&
yarn http-server docs -p 9001 & npx wait-on http://localhost:9001 &&
yarn run-p -l
"chromatic -- --quiet --exit-zero-on-changes --exit-once-uploaded --storybook-build-dir docs"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the work is done on Chromatic's side so this allows us to make our Chromatic build command exit after we've uploaded the Storybook source. This also ensures that we don't incur CI build time increases in Travis as we add more visual testing stories.

Copy link
Member

Choose a reason for hiding this comment

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

--exit-once-uploaded

Genius. I didn't matter much when we only had Chrome and it took like 15s for 300 stories. IE11 is much slower. We already have a status check that is reported by Chromatic. We don't need to wait for it here. 👍

"cypress:run -- --record" &&
kill $(jobs -p) || true
env:
# Travis doesn't support encryption on forks: https://docs.travis-ci.com/user/pull-requests#pull-requests-and-security-restrictions
Expand All @@ -74,7 +73,7 @@ jobs:
script:
- >- # Chromatic relies on a built Storybook, so exit early if build-storybook fails
yarn build-storybook &&
yarn chromatic --quiet --auto-accept-changes --storybook-build-dir docs
yarn chromatic --quiet --auto-accept-changes --exit-once-uploaded --storybook-build-dir docs
Copy link
Member

Choose a reason for hiding this comment

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

👍

- yarn build
env:
- CHROMATIC_APP_CODE="dlpro96xybh"
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"colors": "^1.4.0",
"commitizen": "^3.1.1",
"concurrently": "^5.1.0",
"core-js": "^3.5.0",
"css-loader": "^3.2.0",
"css-mqpacker": "^7.0.0",
Expand Down Expand Up @@ -123,8 +122,7 @@
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.14.0",
"tslint-react": "^3.6.0",
"typescript": "^3.5.1",
"wait-on": "^4.0.1"
"typescript": "^3.5.1"
},
"scripts": {
"start": "node --max-old-space-size=2048 node_modules/.bin/start-storybook -p 9001 -c .storybook",
Expand All @@ -137,6 +135,7 @@
"create-module": "./utils/create-component/createComponent.js",
"create-component": "./utils/create-component/createComponent.js",
"precommit": "lint-staged",
"chromatic": "chromatic",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need this to run chromatic via run-p in Travis

"commit": "git-cz",
"commitmsg": "commitlint --edit $HUSKY_GIT_PARAMS",
"build-storybook": "build-storybook -c .storybook -o docs",
Expand Down
Loading