node.js - 如何在 Travis CI 上的一个项目中运行 Golang 和 Karma 测试

标签 node.js go karma-runner travis-ci drone.io

我认为我的问题与这些问题有关,但解决方案在我的案例中不起作用:How to run Node.js and Ruby tests within one project on Travis CIIs it possible to set up travis to run tests for several languages?

我有一个 github 存储库,其中包含一个带有微型 Angularjs 前端的小型 Golang 应用程序。我想同时运行 go-tests 和 Karma-tests。 我看到两个选项:

  1. 为一个 repo 运行两个 travis-ci 构建(我不知道如何 这样做)

  2. 在一个构建中运行两个测试(因为 travis-ci 中的 Node 版本太旧 (0.10),所以没有成功)。

构建运行了 60 多分钟,然后停止并显示“ fatal error :CALL_AND_RETRY_2 分配失败 - 进程内存不足”。构建显示了大量这样的警告:npm WARN engine escodegen@1.8.0: wanted: {"node":">=0.12.0"} (current: {"node":"0.10.36","npm ":"1.4.28"})

我尝试将构建作为 node_js 运行,但随后“go get xyz”不起作用。

我的 .travis.yml 文件:

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

最佳答案

有时问题出在机器前面...我找到了一个很好的解决方法,我想与您分享。

我在 https://drone.io/ 上创建了一个帐户在设置选项卡中,我为“Go1”选择了一个构建并添加了以下命令:

# 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

现在我又回到了运行 Golang 和 Karma 测试的 CI 服务器的轨道上。

关于node.js - 如何在 Travis CI 上的一个项目中运行 Golang 和 Karma 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34767628/

相关文章:

node.js - 无法创建cordova项目,代理问题?

node.js - NodeJS 文件显示为不存在,但路径正确

go - 是什么导致了这种 go​​lang os.Exec 行为(转义双引号)?

docker - 来自 Docker 的 Golang 编译缓存

go - 就地更改二维 slice

javascript - Angular, Karma (SystemJS) XHR 错误 (404 Not Found) - [Separate Src/Build]

Node.js 错误处理保证与 net.createConnection

javascript - 请求正文已声明,但日志显示它在客户端和服务器端均未定义

angularjs - 无法以 Angular 启动 karma 服务器

javascript - Angular 单元测试 : Calling a method defined in another controller is throwing 'undefined' is not an error