Slide 1

Slide 1 text

Code review - Phabricator introduce YuDeZhi 2016.01.20

Slide 2

Slide 2 text

Agenda Phabricator Summary pre-push code review tool —— Differential code repository browse tool — Diffusion post-push code review tool —— Audit Other Feature Summary Final

Slide 3

Slide 3 text

Phabricator Summary 今天我要向⼤家推荐⼀款⾮常棒的代码检视⼯具Phabricator。 Phabricator是Facebook保驾护航的11⼤IT技术之⼀。在 Phabricator的⽹站中,开发者给出了这样的描述:“Facebook的 ⼯程师们毫不掩饰⾃⼰对于Phabricator的喜爱之情,他们甚⾄将它 视为’顺利’与’严谨’的代名词”。下⾯我就将演示使⽤Phabricator进 ⾏代码检视的流程以及它的亮点 https:/ /secure.phabricator.com/book/phabricator/ article/introduction/ 1

Slide 4

Slide 4 text

Phabricator

Slide 5

Slide 5 text

Differential Differential是Phabricator核⼼功能之⼀,他是开 发者相互检视代码,互相讨论代码的主要平台。 ⾸先我先假设系统中除了系统管理员账户之外,还有其 他4个普通⽤户,他们分别是qj447,huangwei, eric.shao,autumnyuhe。他们都参与到⼀个 ios_union_cashier的项⽬中。 2

Slide 6

Slide 6 text

Arcanist Tool 此处⽣成diff需要⽤到Phabricator命令⾏⼯具 Arcanist,该⼯具是FB开发的,暂时还没有图形化 的⼯具 推荐⼀个很好的学习教程http:/ /sezina.github.io/blog/ 2013/07/16/phabricatorming-ling-xing-gong-ju- arcanistde-ji-ben-yong-fa/

Slide 7

Slide 7 text

Let’s do it git commit - (arc diff - accept)- pull - (arc diff - accept) -push

Slide 8

Slide 8 text

DownLoad Tool

Slide 9

Slide 9 text

Edit Path

Slide 10

Slide 10 text

install certificate

Slide 11

Slide 11 text

install certificate

Slide 12

Slide 12 text

creat diff

Slide 13

Slide 13 text

edit diff info

Slide 14

Slide 14 text

generate diff

Slide 15

Slide 15 text

pre-push code review

Slide 16

Slide 16 text

pre-push code review

Slide 17

Slide 17 text

pre-push code review

Slide 18

Slide 18 text

pre-push code review

Slide 19

Slide 19 text

pre-push code review

Slide 20

Slide 20 text

complete code review

Slide 21

Slide 21 text

Diffusion Phabricator提供⼀个类似于gitlab之类的 远程仓库浏览⼯具diffusion,开发⼈员可 以快速查看以下信息 3

Slide 22

Slide 22 text

VCS Repertory information

Slide 23

Slide 23 text

VCS commit history

Slide 24

Slide 24 text

Repertory directory structure

Slide 25

Slide 25 text

directory structure & commit information

Slide 26

Slide 26 text

Branches information

Slide 27

Slide 27 text

Audit 我们有了Differential,那么现在为何还需 要⼀个Audit ? 4

Slide 28

Slide 28 text

Review vs Audit Phabricator supports two similar but separate code review workflows: Differential is used for pre-push code review, called "reviews" elsewhere in the documentation. You can learn more in Differential User Guide. Audit is used for post-push code reviews, called "audits" elsewhere in the documentation. You can learn more in Audit User Guide. (By "pre-push", this document means review which blocks deployment of changes, while "post-push" means review which happens after changes are deployed or en route to deployment.) Both are lightweight, asynchronous web-based workflows where reviewers/ auditors inspect code independently, from their own machines -- not synchronous review sessions where authors and reviewers meet in person to discuss changes.

Slide 29

Slide 29 text

Briefly Differential是代码提交VCS仓库前的代码 检视⼯具,但是有些情况下我们的代码由于 某些情况来不及做⾮常细致的pre- commit review,需要提前部署。那么有 什么办法在在代码提交VCS之后来进⾏代码 检视,保证我们的代码质量呢?答案是 Audit。这就是Audit的职责。

Slide 30

Slide 30 text

How Audit work ? audit request trigger Audit tool primarily keeps track of two things: Commits and their audit state (like "Not Audited", "Approved", or "Concern Raised"). Audit Requests which ask a user (or some other entity) to audit a commit. These can be triggered in a number of ways (see below).

Slide 31

Slide 31 text

audit homepage

Slide 32

Slide 32 text

audit & commit Required Audits are open audit requests that require you, a project you are a member of, or a package you own to audit a commit. An audit request is closed when you approve the associated commit. Problem Commits are commits you authored which someone has raised a concern about in audit. Problem commits go away when you satisfy all the auditors and get them to "Approve" the commit.

Slide 33

Slide 33 text

Audit Triggers Audit requests can be triggered in a number of ways: If you put Auditors: username1, username2 in your commit message, it will trigger an audit request to those users when you push it to a tracked branch. You can create rules in Herald that trigger audits based on properties of the commit -- like the files it touches, the text of the change, the author, etc. You can create an audit request for yourself by commenting on any commit. You can create an Owners package and select "Enable Auditing" (this is an advanced feature which is only likely to be useful for very large teams).

Slide 34

Slide 34 text

Audit Tips When viewing a commit, audit requests you are responsible for are highlighted. You are responsible for a request if it's a user request and you're that user, or if it's a project request and you're a member of the project, or if it's a package request and you're a package owner. Any action you take will update the state of all the requests you're responsible for. You can leave inline comments by clicking the line numbers in the diff. You can leave a comment across multiple lines by dragging across the line numbers. Inline comments are initially saved as drafts. They are not submitted until you submit a comment at the bottom of the page. Press "?" to view keyboard shortcuts.

Slide 35

Slide 35 text

Raise Concern

Slide 36

Slide 36 text

add comment

Slide 37

Slide 37 text

Other Feature Summary Maniphest:任务管理和缺陷追踪(霸道?) CountDown:定时提醒⼯具 Repository:远程VCS仓库管理 Herald Rule:创建⾃定义规则,当某些事 件触发了规则时提醒我们(IFTTT?) 5

Slide 38

Slide 38 text

Advantage of Phabricator phabricator 中也是通过提交request来展示diff做reivew.但是他的diff 不是⽂件的全部内容,只是diff的部分,所以不需要事先在⼯具⾥添加库,可 以直接提交diff,也可以粘贴diff的内容来提交。 不光只有代码review⼯具,还有bug跟踪,wiki等功能。可以直接做单元测 试,bug与代码review的关联。 按request状态分类清晰,搜索功能好⽤。 ⽀持svn 和 git。 所有检视⼯作只需要⼀个浏览器,不需要安装额外的插/软件。 操作界⾯和易⽤性⾮常棒。可⾃定义界⾯布局和主题,更加时尚和有活⼒

Slide 39

Slide 39 text

Q & A

Slide 40

Slide 40 text

–Grady Booch,One of the UML founders “The function of good software is to make the complex appear to be simple”

Slide 41

Slide 41 text

Thank you !