Customizing arcanist workflows

Hi,

We would like to extend arc so that at the end of arc diff process, once revision is created or updated, a custom script would be executed, that would automatically retrieve and assign projects to the revision (just as an example).

The only way I can see this achievable is through:

  1. Event Listeners: https://secure.phabricator.com/book/phabricator/article/events/ However, there’s a menacing notification at the top.
  2. Write a custom workflow diff2 and call arc diff2
  3. Write a custom linter/unit engine that does that, but it feels weird.

Is there anything I’m missing and is #2 the only sensible option here.

Thank you in advance for anyone who can provide input.

Julius

You can use Herald for that - you can either express your rules in Herald directly, or write a custom Herald action and apply it to all revisions.
See https://secure.phabricator.com/book/phabricator/article/herald/ for docs.

Thank you for the reply @avivey

There are two the things we’d like to do:

  1. Attach projects to a revision based on the Maniphest task(s) linked to revision;
  2. Attach a single milestone to a revision based on time (think - assigning currently active milestone in a project).

First one is not covered by Herald; second one actually depends on the week. I had a go at trying to write a Herald rule, but examples are sparse, documentation does not even cover the API, so our next best guess was to try and use arc and retrieve all of this through Conduit.

My main struggle with writing custom Herald rules was working out how to retrieve the attached tasks and revisions (as they’re not stored in a field). The existing Herald action implementations seem to operate on readily available fields of tasks/revisions, a.k.a. what I need seemed to be based on xactionengine and I just couldn’t work out how to use it from the existing code and there was not a lot of documentation either.

Any pointers would be greatly appreciated, if there are any.

Thanks again for swiftly reply.

There are a couple of examples of custom Herald actions in https://phurl.io/u/community

There’s not much of documentation on these things, but there is a lot of existing code examples - i.e., the bulk of Phabricator code. xactionengine is for modifying stuff (normal HeraldActions are for modifying things, and HeraldRules are for reading; but HeraldRules are not easily extensible right now, AFAIK).
For reading, you’ll mostly be using the SearchEngine/SearchQuery constructs, and add needX for having it load the piece of information you need.

Thank you for the pointers @avivey I’ll have a look!