dta38159 2016-01-13 13:11
浏览 47
已采纳

如何在Travis CI的一个项目中运行Golang和Karma测试

I think my question is related to these ones but the solution did not work in my case: How to run Node.js and Ruby tests within one project on Travis CI and Is it possible to set up travis to run tests for several languages?

I have a github repo that contains a little Golang application with a tiny Angularjs frontend. I want to run both go-tests and Karma-tests. I see two options:

  1. Run two travis-ci builds for one repo (I could not figure out how to do that)

  2. Run both tests in one build (did not work since the node version in travis-ci is too old (0.10).

The build runs for 60+ minutes and then stops with "FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory". The build shows tons of warnings like this one: npm WARN engine escodegen@1.8.0: wanted: {"node":">=0.12.0"} (current: {"node":"0.10.36","npm":"1.4.28"})

I tried to run the build as node_js but then the "go get xyz" does not work.

my .travis.yml file:

language: go

go:
  - 1.5

env:
  - TRAVIS_NODE_VERSION="0.12"

install:
  - export PATH=$HOME/gopath/bin:$PATH
  - go get golang.org/x/tools/cmd/cover
  - go get -v github.com/axw/gocov
  - go install github.com/axw/gocov/gocov
  - go get github.com/GeertJohan/go.rice
  # we do not need the rice tool!
  - go get github.com/xeipuuv/gojsonschema
  - go get github.com/finklabs/ttime
  - go get github.com/finklabs/graceful
  - go get github.com/gorilla/mux

before_script:
  - npm install bower
  - npm install --dev
  - bower install

script:
  - gocov test | gocov report
  - npm test
  • 写回答

2条回答 默认 最新

  • dongqiao1888 2016-01-13 17:59
    关注

    sometimes the problem sits in front of the machine... I found a great workaround and I want to share it with you.

    I created an account on https://drone.io/ in the settings tab I selected a build for "Go1" and added the following commands:

    # install gogrinder dependencies
    go get ./...
    
    # install test dependencies
    go get golang.org/x/tools/cmd/cover
    go get -v github.com/axw/gocov
    go install github.com/axw/gocov/gocov
    
    # install nodejs requirements
    npm -d install
    ./node_modules/bower/bin/bower install
    
    # run the tests on the go code
    gocov test | gocov report
    
    # run the tests on the Angularjs frontend
    npm test
    

    Now I am back on track with a CI server that runs both Golang and Karma tests.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失