如何在Travis CI的一个项目中运行Node.js和Rubytesting

我有一个包含多个组件的报表,其中大多数在JavaScript(Node.js)和一个用Ruby(Ruby on Rails)编写的组件。 我想有一个.travis.yml文件触发一个构build,运行每个组件的所有testing。 根据Travis CI Google Group主题 ,目前还没有官方的支持。

我的目录结构如下所示:

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

我想能够运行特定版本的Ruby(2.2.2)和Node.js(0.12.2)。 我已经有了一个make目标,所以make test在每个子目录下运行适当的testing套件。

事实certificate,每个在Travis CI上运行独立testing套件的虚拟机,都预装了Node.js和Ruby 。 默认情况下,你会得到Ruby 1.9.3和Node.js 0.12.2(但是可能会随着Travis团队更新他们的环境而改变),所以即使你只能在你的.travis.yml文件中指定一种语言(比如language: Ruby ) ,你仍然可以在Travis CI VM上运行Ruby和Node.js程序。

我决定去Node.js语言设置,并安装适当的Ruby版本(但我可以做相反的效果)。

这是我的.travis.ymlconfiguration文件:

 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