Skip to content

Commit

Permalink
further build improvements (#3315)
Browse files Browse the repository at this point in the history
- cache npm itself
- use `npm ci`
- cache the npm cache
- ignore scripts when installing unless necessary
- cache `node_modules` for `npm install`-using smoke tests
- prefer flags over env vars

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
  • Loading branch information
boneskull authored Apr 7, 2018
1 parent 88b9882 commit 7544bd3
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ stages:
# defaults
language: node_js
node_js: '9'
env: PATH=~/npm/node_modules/.bin:$PATH
# `nvm install` happens before the cache is restored, which means
# we must install our own npm elsewhere (`~/npm`)
before_install: |
[[ ! -x ~/npm/node_modules/.bin/npm ]] && {
# caching feature creates `~/npm` for us
cd ~/npm && npm install npm
cd -
} || true
# this avoids compilation in most cases (where we don't need it)
install: npm ci --ignore-scripts
cache:
directories:
- ~/.npm
- node_modules
- ~/.npm # cache npm's cache
- ~/npm # cache latest npm

jobs:
include:
Expand All @@ -24,18 +35,12 @@ jobs:

- <<: *node
node_js: '6'
cache:
directories:
- node_modules

- <<: *node
node_js: '4'
cache:
directories:
- node_modules

- script: npm start test.bundle test.browser
before_script: mkdir -p .karma
install: npm ci # we need the native modules here
addons:
artifacts:
paths:
Expand All @@ -47,11 +52,18 @@ jobs:
- stage: lint
script: npm start lint

# smoke tests use default npm.
- &smoke
stage: smoke
env: NPM_CONFIG_PRODUCTION=1
env: null
before_install: true
install: npm install --production
# `--opts /dev/null` means "ignore test/mocha.opts"
script: ./bin/mocha --opts /dev/null --reporter spec test/sanity/sanity.spec.js
cache: false
cache:
directories:
- ~/.npm
- node_modules # npm install, unlike npm ci, doesn't wipe node_modules

- <<: *smoke
node_js: '8'
Expand Down

0 comments on commit 7544bd3

Please sign in to comment.