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条)

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况