英文:
How to run Golang and Karma tests within one project on Travis CI
问题
我认为我的问题与这些问题有关,但解决方案在我的情况下不起作用:https://stackoverflow.com/questions/31235146/how-to-run-node-js-and-ruby-tests-within-one-project-on-travis-ci和https://stackoverflow.com/questions/18456611/is-it-possible-to-set-up-travis-to-run-tests-for-several-languages?rq=1
我有一个包含一个小的Golang应用程序和一个微小的Angularjs前端的GitHub存储库。我想同时运行go-tests和Karma-tests。
我看到两个选项:
-
为一个存储库运行两个travis-ci构建(我无法弄清楚如何做到这一点)
-
在一个构建中运行两个测试(由于travis-ci中的node版本太旧(0.10),所以无法工作。
构建运行了60多分钟,然后停止并显示“FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory”。构建显示了大量警告,例如: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
英文:
I think my question is related to these ones but the solution did not work in my case: https://stackoverflow.com/questions/31235146/how-to-run-node-js-and-ruby-tests-within-one-project-on-travis-ci and https://stackoverflow.com/questions/18456611/is-it-possible-to-set-up-travis-to-run-tests-for-several-languages?rq=1
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:
-
Run two travis-ci builds for one repo (I could not figure out how to
do that) -
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
答案1
得分: 1
有时问题就坐在机器前面...我找到了一个很好的解决方法,想与你分享。
我在https://drone.io/上创建了一个账户,在设置选项卡中选择了一个适用于"Go1"的构建,并添加了以下命令:
# 安装gogrinder的依赖
go get ./...
# 安装测试的依赖
go get golang.org/x/tools/cmd/cover
go get -v github.com/axw/gocov
go install github.com/axw/gocov/gocov
# 安装nodejs的要求
npm -d install
./node_modules/bower/bin/bower install
# 运行Go代码的测试
gocov test | gocov report
# 运行Angularjs前端的测试
npm test
现在我又回到了正轨,有一个同时运行Golang和Karma测试的CI服务器。
英文:
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.
答案2
得分: 1
我在很久以前的http://entulho.fiatjaf.alhur.es/guias/how-to-use-node-along-with-other-language-on-travis-ci/上提供了一个解决方案,但今天仍然有效:
基本上,你只需要在你的.travis.yml
文件中添加以下内容:
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
这个文件必须设置为不同的语言,它将安装node
和npm
。
英文:
I gave a solution to this on http://entulho.fiatjaf.alhur.es/guias/how-to-use-node-along-with-other-language-on-travis-ci/ a long time ago, but it still works today:
Basically you just add
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
to your .travis.yml
, which must be set to a different language, and it will install node
and npm
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论