有什么方法可以让Phabricator推送差异到存储库吗? [英] Is there any way to get Phabricator to push diffs to a repository?

查看:156
本文介绍了有什么方法可以让Phabricator推送差异到存储库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了Phabricator,我们还有一个测试系统,可以自动构建和测试推送到我们主要的git回购的一个特定的分支。有没有办法让 arc diff 自动将差异推送到特定分支?测试通常需要几个小时,而且我更希望人们可以在测试代码时查看代码。它可以以某种方式集成为一个单元测试,在差异发送之前不必完成审查?

解决方案

目的 arc diff 是它允许在没有将代码登陆到分支上的情况下执行测试/代码审查。我们通过先驱规则,Harbormaster构建计划和Jenkins来完成这项工作。



创建/更新差异时,正在观察Repo的Herald规则会触发Harbormaster构建计划通过HTTP post请求触发Jenkins。我会尽力详细介绍基本知识,但是,如果您选择走此路线,我建议您在构建此过程时查看一些其他材料。

注意 - Harbormaster被列为原型。意思是,对它的支持有限。但是,除了编写自己的自定义代码之外,没有其他方法可以做我在这里提出的建议。



我希望在这里有足够的资源帮助您开始。根据您的具体需求制定需要更多细节。这就是我们所做的,对我们来说,它的效果很好。我希望它适合您。

设置测试工作



测试工作必须是参数化,所以你可以传递你的Diff和构建ID作为参数。

在你的测试中,你可以这样做,从diff中取出代码:

 #!/ bin / bash 
#清理分支
git fetch --all
git checkout master
git reset --hard origin / master
git pull

#删除arcpatch分支(如果分支不存在则忽略错误)
git分支-D arcpatch -D $ DIFF | | true

#应用修补程序
arc patch D $ DIFF

#更新依赖项
git子模块更新
作曲者安装

然后触发您通常的测试。测试结束后,您将需要一些类似的代码来查看更新Phabricator的构建结果:

 #!/ bin / bash 
#让Phabricator知道如果[-n$ PHID];构建成功
;然后
export PATH = $ PATH:〜/ bin / arcanist / bin
if [{{{Code to determine Failure}}}];然后
jsonResult ={\buildTargetPHID \:\$ PHID \,\type \:\fail \};
else
jsonResult ={\buildTargetPHID \:\$ PHID \,\type \:\pass \};
fi
echo $ jsonResult | arc call-conduit harbourmaster.sendmessage;
fi



查看代码



<与此同时,开发人员可以引用该差异(http:// {Phabricator.url} / D ####),查看代码,甚至可以按照与上述测试工作类似的过程运行任何测试。 / p>

先驱规则



先驱规则将触发差异修订。它会查找任何表明您想要测试的更改(通常是特定回购中的任何内容)并运行构建计划(请参阅关于如何创建与Jenkins链接的构建计划的其他参考,如果这是您使用的)。

其他参考资料:



http://www.guywarner.com/2014/05/integrating-jenkins-and-phabricator.html
http://www.guywarner.com/2014/06/part-2-integrating-phabricator-and。 HTML


Our team has recently started experimenting with using Phabricator for code reviews.

Apart from Phabricator, we have a test-system that automatically builds and tests any code pushed to a specific branch on our main git repo. Is there any way to get arc diff to automatically push the diff to that specific branch? The tests usually take a couple of hours, and I would prefer if it would be possible for people to review the code while it is being tested. Could it somehow be integrated as a unit test that does not have to complete before the diff is sent fo review?

解决方案

The purpose of arc diff is that it will allow tests/Code Review to be performed without landing the code on a branch. We do this here through Herald rules, Harbormaster build plans, and Jenkins.

When a diff is created/updated, the Herald rule that is watching that Repo triggers the Harbormaster build plan that triggers Jenkins via an HTTP post request. I will try to detail out the basics but, I recommend looking at some additional materials as you build this process, if you choose to go this route.

PLEASE NOTE - Harbormaster is listed as a "Prototype". Meaning, there is limited support for it. But, aside from writing your own custom code, there is no other way to do what I'm suggesting here.

I hope to have enough here to get you started. Crafting to your specific needs will require much more detail from your side. This is what we do, and it works well for us. I hope it works well for you.

Setting up the test Job

The Test Job will have to be parameterized so you can pass your Diff and build ID in as a parameter.
Inside your test, you would do something like this to pull code in from the diff:

#!/bin/bash
# Clean the branch
git fetch --all
git checkout master
git reset --hard origin/master
git pull

# Delete the arcpatch branch (ignoring error if the branch doesn't exist)
git branch -D arcpatch-D$DIFF || true

# Apply the patch
arc patch D$DIFF

# Update dependencies
git submodule update
composer install

Then trigger your usual tests. After the tests, you will need some code like this to see update Phabricator with the build results:

#!/bin/bash
# Let Phabricator know if the build succeeded
if [ -n "$PHID" ]; then
   export PATH=$PATH:~/bin/arcanist/bin
   if [ {{{Code to determine Failure}}} ]; then
      jsonResult="{\"buildTargetPHID\":\"$PHID\",\"type\":\"fail\"}";
   else
      jsonResult="{\"buildTargetPHID\":\"$PHID\",\"type\":\"pass\"}";
   fi
   echo $jsonResult | arc call-conduit harbormaster.sendmessage;
fi

Review the Code

Meanwhile, developers can reference that diff (http://{Phabricator.url}/D####), review the code, and can even run any tests by following a similar process as the test job is doing above.

Herald Rule

The Herald Rule will trigger on Differential Revisions. It will be looking for whatever indicates a change you are wanting to test (usually anything in a particular repo) and will Run the build plan (please see additional references on how to create a build plan that links to Jenkins if that is what you use).

Additional references:

http://www.guywarner.com/2014/05/integrating-jenkins-and-phabricator.html http://www.guywarner.com/2014/06/part-2-integrating-phabricator-and.html

这篇关于有什么方法可以让Phabricator推送差异到存储库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆