Bob the Builder

Given a Buildable object with the following public API:

  • buildable.kind

    Should return a Symbol with whatever kind of repository the buildable’s code is in (:git, :svn, etc).

  • buildable.uri

    Returns a string like “git://github.com/integrity/bob.git”, pointing to the code repository.

  • buildable.branch

    What branch of the repository should we build?

  • buildable.build_script

    Returns a string containing the build script to be run when “building”.

  • buildable.start_building(commit_id)

    ‘commit_id` is a String that contains whatever is appropriate for the repo type, so it would be a SHA1 hash for git repos, or a numeric id for svn, etc. This is a callback so the buildable can determine how long it takes to build. It doesn’t need to return anything.

  • buildable.finish_building(commit_id, build_status, build_output)

    Callback for when the build finishes. It doesn’t need to return anything. It will receive a string with the commit identifier, a boolean for the build exit status (true for successful builds, false fore failed ones) and a string with the build output (both STDOUT and STDERR).

    A successful build is one where the build script returns a zero status code.

Bob will, when called like:

Bob.build(buildable, commit_id)
  1. Checkout the buildable on the specified commit

  2. Call buildable.start_building

  3. Run the script provided in build_script in the buildable.

  4. When the build process finishes, it will call finish_building with the commit_id, the build status (true if the script returns a status code of 0, false otherwise), and a string with the build output (both STDOUT and STDERR).

Do I need this?

Probably not. Check out integrity for a full fledged automated CI server, which is what most people need.

Credits

Authors

Nicolas Sanguinetti (foca) and Simon Rozet (sr)

License

MIT (Check LICENSE for details)