How to run Node.js and Ruby tests in one project on Travis CI

I have a repo that contains several components, most of them in JavaScript (Node.js) and one written in Ruby (Ruby on Rails). I would like to have one .travis.yml file that runs one assembly, which runs all the tests for each component. According to the Travis CI Google Group topic , there is no official support for this yet.

My directory structure looks like this:

. ├── buildserver ├── core ├── extensions ├── webapp ├── Vagrantfile ├── package.json ├── .travis.yml └── Makefile

I want to be able to run certain versions of Ruby (2.2.2) and Node.js (0.12.2). I already have a make target, so make test runs the appropriate test suite in each subdirectory.

+5
source share
1 answer

It turns out that every VM that runs your isolated test suite on Travis CI comes with Node.js and the previously installed Ruby . By default, you get Ruby 1.9.3 and Node.js 0.12.2 (but this can change as the Travis team updates its environment), so although you can only specify one language (e.g. language: Ruby ) in .travis.yml file, you can run both Ruby and Node.js programs on Travis CI VM.

I decided to go with the Node.js language setting and install the appropriate version of Ruby (but I could do the opposite with the same effect).

Here is my .travis.yml configuration file:

 language: node_js node_js: - 0.12.2 addons: postgresql: "9.4" before_install: - rvm install 2.2.2 install: # run whatever you have to do here. I have a Makefile that lets you install # all Node.js-related or Ruby-related dependencies as one step. - make npm - make bundler before_script: # My Rails app lives in a subdirectory. I want to make sure that # my database is ready before I start running RSpec tests - psql -c 'create database test_db;' -U postgres # I use separate database.yml config for Travis CI - cp webapp/config/database.travis.yml webapp/config/database.yml script: # `test` target executes `bundle exec rspec spec` and `npm run test` # in all appropriate subdirectories - make test 
+15
source

All Articles