Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

travis-ci ruby build with node 5

I've tried many things, but have ultimately failed to get the build for gulp-pipeline-rails running. The script runs locally, no problem.

The last problem I've narrowed down is that I have a ruby language project that utilizes node, but I need node 5. I found one snippet:

#------------------------------
# Update the node version
env:
  - TRAVIS_NODE_VERSION="5"

install:
  - pwd
  - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
  - npm install

While this seems to get node updated, it does something to my ruby env where it fails to execute rspec:

$ pwd && bundle exec rake
/home/travis/build/alienfast/gulp-pipeline-rails
Could not find gem 'rspec' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.

Question With all that said, how do I simply use Node 5 with this .travis.yml?

language: ruby
rvm:
  - 2.2.2
  - ruby-head

matrix:
  allow_failures:
    - rvm: ruby-head

cache: bundler

#------------------------------
# Setup
before_script:
  - node -v
  # update npm
  - npm install npm -g

  # install Gulp 4 CLI tools globally from 4.0 GitHub branch
  - npm install https://github.com/gulpjs/gulp-cli/tarball/4.0 -g

#------------------------------
# Build
script: bundle exec rake
like image 414
kross Avatar asked Mar 25 '16 16:03

kross


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 file is used to configure the Travis CI?

3) To set up a build environment and prepare the build, Travis CI's system fetches and processes the . travis. yml config file from the repository and the branch explicitly specified in the build request, triggered by GitHub.


2 Answers

Try using a before_install stage for adding a second language on Travis, maybe something like:

before_install:
  - nvm install node

nvm should be installed by default on the Travis build image (depending on which one you're using), and this command will install the latest version of Node.

After that, maybe just have npm install -g [email protected] as the first step in your before_script stage (i.e. don't worry about updating npm), hopefully that should mean that bundler still runs fine and installs all your gems.

like image 146
ocean Avatar answered Nov 14 '22 05:11

ocean


I found this article that helped me out quite a bit.

Relevant information from article:

You can use nvm to manage you node versions in travis, however you have to enable it first:

 install:
  - . $HOME/.nvm/nvm.sh
  - nvm install stable
  - nvm use stable
like image 2
xno Avatar answered Nov 14 '22 05:11

xno