Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update node.js and install grunt/bower in a python project in Travis CI?

I need to use grunt during the installation of my project. I need node.js >= 0.8 for that. but the version included in a python VM in Travis CI is the 0.6.

I tried downloading the last binaries and inserting it into the PATH but I couldn't export the variable correctly, and if I changed it using the env: parameter of travis it would not have had the rest of the PATH.

If I use directly the binaries (./node-v0.10.22-linux-x64/bin/npm install ...), it will install them in ./node-v0.10.22-linux-x64/bin/ and when I want to use grunt, it will call bower (one of the task) but it will fail. (Fatal error: Failed to execute git checkout e6f8a58dbce5858586564a1ba4543f122ef63225, exit code of #128).

So, what is the best solution to update node.js and install binaries I need to use them in Travis CI?

like image 891
Gagaro Avatar asked Nov 21 '13 16:11

Gagaro


People also ask

What is Travis node?

Travis CI is a Continuous Integration service used to build and test software projects hosted at GitHub. Or in simple terms, when you push a commit to the master branch of your project hosted at GitHub, Travis CI will run tests and build the latest commit of your master branch. It's that simple.

Which of the following option is the default build script for Node JS?

npm precisely when npm ci is the default script command. (See above.) In all other cases, this will cache node_modules .


2 Answers

Here is a modified version of the Travis config that I have been using. The steps to get node installed are adapted from node's install docs. This method will install the latest stable version of node.

language: python
python:
  - "2.7"
  - "3.3"

install:
  # Python test requirements
  - pip install -r requirements.txt
  - pip install nose coverage selenium

  # JavaScript test requirements
  - sudo add-apt-repository -y ppa:chris-lea/node.js
  - sudo apt-get -y update
  - sudo apt-get -y install nodejs
  - sudo npm install -g grunt-cli
  - sudo npm install -g bower
  - sudo npm install

before_script:
  - bower install

script:
  # Run Python tests and generate coverage statistics
  - nosetests --with-coverage

  # Run tests for JavaScript
  - grunt test

# etc., etc.
like image 171
mjumbewu Avatar answered Sep 30 '22 20:09

mjumbewu


Travis CI's Trusty beta comes with "A mega image which will contains almost all of (soon to be all) our commonly supported runtimes and services."

To use it, add this to your .travis.yml:

sudo: required
dist: trusty

For example:

sudo: required
dist: trusty

language: python

python:
- 'pypy'
- 'pypy3'
- '2.6'
- '2.7'
- '3.2'
- '3.3'
- '3.4'
- '3.5'

script:
  - python --version
  - node --version

At the time of writing, this contains Node v4.1.2 instead of v0.10.36.

like image 44
Hugo Avatar answered Sep 30 '22 18:09

Hugo