如何在Travis CI的一个项目中运行Node.js和Ruby测试 [英] How to run Node.js and Ruby tests within one project on Travis CI

查看:95
本文介绍了如何在Travis CI的一个项目中运行Node.js和Ruby测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个组件的存储库,其中大多数使用JavaScript(Node.js),而另一个使用Ruby(Ruby on Rails)编写.我想拥有一个.travis.yml文件,该文件可以触发一个版本,该版本针对每个组件运行所有测试.根据此Travis CI Google Group线程,没有官方的现在对此提供支持.

I have a repo that contains multiple components, most of them in JavaScript (Node.js) and one written in Ruby (Ruby on Rails). I'd like to have one .travis.yml file that triggers one build that runs all the tests for each of the components. According to this Travis CI Google Group thread, there is no official support for this for now.

我的目录结构如下:

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

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

我希望能够运行特定版本的Ruby(2.2.2)和Node.js(0.12.2).我已经有一个make目标,所以make test在每个子目录中运行相应的测试套件.

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

推荐答案

事实证明,在Travis CI上运行隔离测试套件的每个VM都带有

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

我决定采用Node.js语言设置并安装适当的Ruby版本(但是本来可以做到相反,但效果相同).

I decided to go with Node.js language set-up and install appropriate Ruby version (but I could have done the opposite with the same effect).

这是我的.travis.yml配置文件:

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

这篇关于如何在Travis CI的一个项目中运行Node.js和Ruby测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆