简体   繁体   English

如何将工作服集成到开源项目中?

[英]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:当我拥有该项目时,过程很简单:

  • Configure build/test system with .travis.yml and language specific tools使用.travis.yml和语言特定工具配置构建/测试系统
  • Take repoToken from CoverallsrepoToken获取repoToken
  • Add repoToken as environment variable to project's Travis systemrepoToken作为环境变量添加到项目的 Travis 系统中
  • Add language specific configuration to .travis.yml 's after_success cycle.将特定于语言的配置添加到.travis.ymlafter_success循环。

However, I've got problems with that when I do not own the repository.但是,当我不拥有存储库时,我遇到了问题。

  • Since I do not own the repository, I only can add project on Coveralls with my fork copy.由于我不拥有存储库,因此我只能使用我的 fork 副本在 Coveralls 上添加项目。 What I mean is, my fork's coverage URL will be /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 .我的意思是,我的 fork 的覆盖 URL 将是/github/myusername/forkedrepo中的/github/myusername/forkedrepo ,当我将该 PR 发送给存储库所有者时,它将是相同的,而它必须是/github/ownersusername/originalrepo
  • I cannot add environment variable repoToken to owner's Travis build system since I do not own it.我无法将环境变量repoToken添加到所有者的 Travis 构建系统,因为我不拥有它。

So my questions are:所以我的问题是:

  • Is it possible to automatize this process?是否可以自动化此过程? Like merging my forked Travis system to owner's original system for repoToken environment variable and/or creating a Coveralls system for owner?就像将我的分叉 Travis 系统合并到所有者的原始系统以获取repoToken环境变量和/或为所有者创建repoToken系统?
  • Or should I simply contact the owner, create separate Travis/Coveralls for my forked project by myself and leave some to-dos in codebase so that he can find these and change later?或者我应该直接联系所有者,自己为我的分叉项目创建单独的 Travis/Coveralls,并在代码库中留下一些待办事项,以便他可以找到这些并在以后进行更改?

Thanks in advance.提前致谢。


Environment环境

  • Java爪哇
  • Maven马文
  • Covertura Maven Plugin for coverage Covertura Maven 插件覆盖
  • Coveralls Maven Plugin for sending coverage results to Coveralls Coveralls Maven 插件,用于将覆盖结果发送到 Coveralls

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM