[英]How do I Integrate Coveralls to An Open-Source Project?
I want to contribute to an open-source project (specifically, this one ) where the project owner has already set up Travis.我想为项目所有者已经设置 Travis 的开源项目(特别是这个项目)做出贡献。 I want to integrate Coveralls to this project and send a pull-request.
我想将 Coveralls 集成到这个项目并发送请求请求。 When I own the project, the process is simple:
当我拥有该项目时,过程很简单:
.travis.yml
and language specific tools.travis.yml
和语言特定工具配置构建/测试系统repoToken
from CoverallsrepoToken
获取repoToken
repoToken
as environment variable to project's Travis systemrepoToken
作为环境变量添加到项目的 Travis 系统中.travis.yml
's after_success
cycle..travis.yml
的after_success
循环。 However, I've got problems with that when I do not own the repository.但是,当我不拥有存储库时,我遇到了问题。
/github/myusername/forkedrepo
in Coveralls and when I sent that PR to repository owner, it will be the same whereas it must be /github/ownersusername/originalrepo
./github/myusername/forkedrepo
中的/github/myusername/forkedrepo
,当我将该 PR 发送给存储库所有者时,它将是相同的,而它必须是/github/ownersusername/originalrepo
。repoToken
to owner's Travis build system since I do not own it.repoToken
添加到所有者的 Travis 构建系统,因为我不拥有它。 So my questions are:所以我的问题是:
repoToken
environment variable and/or creating a Coveralls system for owner?repoToken
环境变量和/或为所有者创建repoToken
系统? Thanks in advance.提前致谢。
You might want to modify your own pom.xml according to the coverage tool you'd like to use see https://github.com/trautonen/coveralls-maven-plugin for some explanation.您可能希望根据您想要使用的覆盖工具修改您自己的 pom.xml,请参阅https://github.com/trautonen/coveralls-maven-plugin以获取一些解释。
You can avoid to put the repo token in the pom.xml file that you publish on github!你可以避免把repo token放在你在github上发布的pom.xml文件中!
Instead you can run the coverage report from the command line.相反,您可以从命令行运行覆盖率报告。
Here is a small helper script that will allow to run converalls from the command line.这是一个小的帮助脚本,允许从命令行运行 converalls。 Just put your token in a place like $HOME/.coveralls or any similar location.
只需将您的令牌放在 $HOME/.coveralls 或任何类似位置之类的地方。
#!/bin/bash
# WF 2019-06-26
# create test coverage report for coveralls
tokenpath=$HOME/.coveralls/coveralls.token
if [ ! -f $tokenpath ]
then
echo "Script needs coveralls token in $tokenpath to work" 1>&2
echo "Script can only be run successfully by project admins" 1>&2
echo "see https://github.com/trautonen/coveralls-maven-plugin" 1>&2
exit 1
else
token=$(cat $tokenpath)
# comment out to use jacoco
#mvn clean test jacoco:report coveralls:report -D jacoco=true -DrepoToken=$token
# comment out to use cobertura
mvn cobertura:cobertura coveralls:report -DrepoToken=$token
fi
Update Here is a version using the COVERALLS_TOKEN environment variable:更新这是一个使用 COVERALLS_TOKEN 环境变量的版本:
#!/bin/bash
# WF 2019-06-26
# create test coverage report for coveralls
# is the environment variable not set?
if [ "$COVERALLS_TOKEN" = "" ]
then
tokenpath=$HOME/.dukes/coveralls.token
if [ ! -f $tokenpath ]
then
echo "Script needs coveralls token in $tokenpath to or COVERALLS_TOKEN environment variable to work" 1>&2
echo "Script can only be run successfully by project admins" 1>&2
echo "see https://github.com/trautonen/coveralls-maven-plugin" 1>&2
echo "see https://stackoverflow.com/a/56815300/1497139" 1>&2
exit 1
fi
else
export COVERALLS_TOKEN=$(cat $tokenpath)
fi
# the jacoco variable tries triggering a profile - check your pom.xml
# for any profile being in use
mvn clean test jacoco:report coveralls:report -D jacoco=true
#mvn clean test jacoco:report coveralls:report -D jacoco=true -DrepoToken=$token
#mvn cobertura:cobertura coveralls:report
#mvn cobertura:cobertura coveralls:report -DrepoToken=$COVERALLS_TOKEN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.