Setting up Travis CI

In notebook:
FrontEndMasters Creating an Open Source JavaScript Library on Github
Created at:
2017-07-19
Updated:
2017-07-19
Tags:
libraries JavaScript

commits $ git commit -am 'adding all the names'

Now his GitHub names repo has all the names of people he follows.

###Create the Travis CI yaml file.

.travis.yml

  // .travis.yml

sudo: false
language: node_js
cache:
  directories:
    - node_modules
node_js: 6
branches:
  only:
    - master
notifications:
  email: false
script:
  - npm run validate

###First set up Travis CI.

You can connect with your GitHub account. Then, you can add a new repo (from your GitHub repos.). You may have to sync your account. https://travis-ci.org/profile/[your username]

Once you turn on your repo with the switch on the UI, you have the gear icon to adjust the settings.

He likes to have the option ON: Build only if .travis.yml is present.

The other options are as default (Build pushes and Build pull requests ON).

We will have to set up the environment variable to turn on automation.

Now, once we do a push, Travis CI will launch a build. Let's just update the readme to kick of a build.

Now, on Travis CI you can go to Current or Build History and see if the build is launched and finished.

###Need do add the .travis.yml first

Otherwise Travis CI will not launch. Once he adds, Travis CI works.

##Walkthrough the .travis.yml file

  # // .travis.yml

# // we don't need it ↴
# // in fact you very rarely need this on
sudo: false
# // NodeJS  ↴
language: node_js
# // we can cache the node dirs..
# // if needed, we can delete the cache
# // from the Travis CI UI
cache:
  directories:
    - node_modules
# // you can also specifiy a list of 
# // target NodeJS versions
# // in the YAML format
# node_js:
#   - 0.12.0
#   - 4
#   - 6
# // we just use 6 ↴
node_js: 6
branches:
# // we only care about the master branch
# // this also includes pull requests
  only:
    - master
# // you will still be notified
#  if the build fails
notifications:
  email: false
script:
# then the npm script
  - npm run validate

You can see the result of $ npm run validate on the Travis CI UI console.

##The badge

Then you can put your badge on the readme.md of your project! 😎


###Solve concurrent builds when adding releases

When you add relaeses they will all try to run a build on Travis CI. He will show later how to solve this.