只能从Travis发送数据给Coveralls,而不是在本地testing
我有一个应用程序( https://github.com/idmillington/dendry )使用Travis CI来监视构build状态。 我使用伊斯坦布尔来提供一个覆盖报告,我想把这个发给Coveralls,为README生成一个覆盖button。
所有这一切,我可以工作。 但…
当我在本地运行npm test
,我不想发送工作服的覆盖数据。 我通常每次提交运行npm test
几十次。 但是当我推,特拉维斯做它的事情,我想特拉维斯更新我的报道。
我可以在我的package.json中有这样的东西:
"scripts": { "test": "./node_modules/.bin/istanbul test ./node_modules/.bin/_mocha", }
这对本地来说是很好的,而且不会更新工作服,但是Travis也不会更新工作服。 或者我可以这样做:
"scripts": { "test": "./node_modules/.bin/istanbul test ./node_modules/.bin/_mocha && ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info", }
这对于Travis来说是完美的,但是每次我在本地运行npm test
都会尝试将数据推送到Coveralls。
据我所知,我不能要求特拉维斯运行npm test
以外的东西。
我不想问任何潜在的用户或贡献者记得testing使用
$ npm run-script test-local
或者一些这样的,尤其是运行npm test
会产生一个上传错误,没有正确的私钥工作服。
有没有办法在这里得到正确的行为?
事实certificate,答案非常简单。 特拉维斯允许你在运行时调用你喜欢的任何脚本,所以我把它添加到我的.travis.yml
文件中:
script: npm run-script test-on-travis
所以在package.json
我可以定义:
"scripts": { "test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha", "test-on-travis": "./node_modules/.bin/istanbul cover --report lcovonly ./node_modules/.bin/_mocha && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" }
一切正常。