Below is a sample .travis.yml
which:
- Uses
dist: trusty
+sudo: false
to enable fast Docker containers - Uses
npm ci
to install quickly before testing - Builds from modules in
devDependencies
- Includes the build in the deployment
- Omits
node_modules
(smaller tarball & no Heroku warning)
language: node_js
node_js:
- node # uses most recent stable node version
services:
- postgresql # starts up postgres
addons:
postgresql: '9.6' # highest available postgres version on Travis
dist: trusty # uses trusty environment
sudo: false # when on trusty, uses Docker containers for speed
install:
- npm i -g npm@5.7.1 # delete once 5.7.X is out of "pre-release"
- npm ci # faster, goes only from package-lock
before_script:
- psql -c 'create database "coolproject-test";' -U postgres
before_deploy:
- webpack # make the bundle
- rm -rf node_modules # omit from the tarball, since we skip cleanup
deploy:
skip_cleanup: true # prevents travis from deleting the build
provider: heroku
app: YOUR-HEROKU-APP-NAME-HERE
api_key:
secure: YOUR-***ENCRYPTED***-API-KEY-HERE