Git Product home page Git Product logo

buildkite-phabricator-dev's Introduction

buildkite-phabricator-dev

A Dockerized environment for developing and testing our buildkite-patches branch of Phabricator.

Get Started

# Clone this repo
git clone https://github.com/buildkite/buildkite-phabricator-dev.git
cd buildkite-phabricator-dev

# Inside, clone our patches branch and other phabricator libs
git clone -b buildkite-patches https://github.com/buildkite/phabricator.git
git clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.git

# Start it all up (it will automatically bootstrap the DB)
docker-compose up

# Setup up Pow, or somesuch localhost proxy
echo '8081' > '~/.pow/phabricator'

# Give it a go (don't create a user! Read the next step)
open http://phabricator.dev/

Next we've got to setup and configure Phabricator with a user, repository, build plan and herald rule.

1. Setup a user

2. Create a Repository

3. Clone, commit and push

Next step is to clone the repository to test inside this repository's checkout path (don't worry, test is gitignore'd):

$ git clone http://phabricator.dev/diffusion/1/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
$ cd test
$ touch Readme.md
$ git commit -am "Initial commit"
[master (root-commit) 7341547] Initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Readme.md
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 841 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://phabricator.dev/diffusion/1/test.git
 * [new branch]      master -> master

4. Setup Arcanist

The arc command line tool is used to create a Diff for code review.

./arcanist/bin/arc help

Add it to your $PATH if you want to make it easier to use:

export PATH="$PATH:~/Codez/buildkite-phabricator-dev/arcanist/bin"

You'll need to authenticate it:

$ arc install-certificate http://phabricator.dev/
 CONNECT  Connecting to "http://phabricator.dev/api/"...
LOGIN TO PHABRICATOR
Open this page in your browser and login to Phabricator if necessary:

http://phabricator.dev/conduit/login/

Then paste the API Token on that page below.

    Paste API Token from that page: xxx
Writing ~/.arcrc...
 SUCCESS!  API Token installed.

Now you can create your first diff! Going back into the test repository:

cd test
echo '{"phabricator.uri": "http://phabricator.dev/"}' > .arcconfig
git add .
git commit -m "First diff commit"
arc diff
# Note: be sure to add some words to the "Test Plan" section

You'll now have your first diff: http://phabricator.dev/D1

5. Setup a Harbormaster Build Plan

This is what triggers a Buildkite build.

Now you add a build step:

6. Create a Herald Rule

Herald is used to trigger build plans automatically when new diff revisions are submitted:

  • Create a new herald rule: http://phabricator.dev/herald for "Differential Revisions" as "Global"
  • Name: 'Trigger a Buildkite diff build'
  • Conditions: when 'Repository' 'is any of' 'R1 Test'
  • Action: 'Run build plans' 'Plan 1 Buildkite'

Next we create one for when commits are pushed:

  • Create a new herald rule: http://phabricator.dev/herald for "Commits" as "Global"
  • Name: 'Trigger a Buildkite commit build'
  • Conditions: when 'Repository' 'is any of' 'R1 Test'
  • Action: 'Run build plans' 'Plan 1 Buildkite'

Now you can create another arc diff, or push a build, and see it trigger harbourmaster builds.

7. View and restart builds

In Harbormaster you'll be able to see the builds triggered. You can restart them to resend the payloads to Buildkite.

http://phabricator.dev/harbormaster

Helpful development snippets

If you want to send the Buildkite webhooks to https://requestb.in/, modify the HarbormasterBuildkiteBuildStepImplementation.php like so, and then hit "Restart Build" in Phabricator:

     $organization = $this->getSetting('organization');
     $pipeline = $this->getSetting('pipeline');
 
-    $uri = urisprintf(
-      'https://api.buildkite.com/v2/organizations/%s/pipelines/%s/builds',
-      $organization,
-      $pipeline);
+    $uri = urisprintf('https://requestb.in/xxx');
 
     $data_structure = array(
       'commit' => $object->getBuildkiteCommit(),

Getting a bash prompt to run phabricator commands:

docker-compose run --rm phabricator bash

Tailing the phd worker logs:

docker-compose exec phabricator tail -f /var/tmp/phd/log/daemons.log

License

MIT (see LICENSE)

buildkite-phabricator-dev's People

Contributors

toolmantim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.