Named after emblematic bart critic Brian Badonde.
Badonde is a command line tool that combines Git, GitHub, and JIRA, offering as a solution for GitHub projects to define an automatic PR creation workflow.
Installation
Homebrew
brew install davdroman/tap/badondeMake
git clone https://github.com/davdroman/Badonde.git
cd Badonde
make installUsage
Setup
First, in a terminal window, you want to navigate to your repo root and run:
$ badonde initThis will create all the required files for Badonde to work and prompt for GitHub and JIRA credentials.
Observe the .badonde folder is created to host Badonde's local user configuration (e.g. credentials). Such folder is also added to .gitignore because per-user configuration must not be commited.
Badondefile
Additionally, a Badondefile.swift file is created with a basic template.
Badondefile defines the rules by which Badonde derives data and outputs PR information, all through declarative Swift syntax.
In order to edit Badondefile with full autocompletion support, run:
$ badonde editThis will open an Xcode project where you can make any modifications to this file. When you're done, go back to the terminal and press the return key to save the file.
Consider a scenario where you want to generate a PR from a local branch named fix/IOS-1234-fix-all-the-things where IOS-1234 is a JIRA ticket id belonging to your organization myamazingiosapp.atlassian.net. Here's an example of a Badondefile that would generate a PR automatically adding things like a standarised PR title and a Bug label for bugfix branches:
import BadondeKit
// Reads the current Git context and derives a JIRA ticket number from the
// current branch's name.
let badonde = Badonde(ticketType: .jira(organization: "myamazingiosapp", derivationStrategy: .regex))
// If a ticket was successfully derived and fetched, its info is available
// through the `badonde.jira` property.
if let ticket = badonde.jira?.ticket {
// Sets the PR title to something like:
// [IOS-1234] Fix all the things
title("[\(ticket.key)] \(ticket.fields.summary)")
}
// If the current branch has the prefix 'fix/' it means we're dealing with a
// bugfix PR, so we attach the Bug label.
if badonde.git.currentBranch.name.hasPrefix("fix/") {
// Sets the "Bug" label defined in your GitHub repo.
label(named: "Bug")
}Here's a more advanced (but just as easily expressed) case of an automation where we match the JIRA ticket's epic to a label in your GitHub repo:
if let epicName = ticket.fields.epicSummary {
label(roughlyNamed: epicName)
} else {
label(named: "BAU")
}By default, Badonde generates draft PRs. To disable this, simply add this to your Badondefile:
draft(false)Here's a list of supported PR properties:
- base branch
- title
- body
- reviewers
- assignees
- labels
- milestone
- draft
Generating a PR
Finally, when you're ready to generate a PR, run:
$ badonde prOr perform a dry run first to see what the output would be:
$ badonde pr --dry-runConfiguration
As said above, Badonde stores its local user configuration in .badonde/config.json.
Badonde offers an interface similar to git config to modify this options. For instance:
$ badonde config git.remote originGlobal options are also available (and stored in ~/.config/badonde/config.json):
$ badonde config --global git.autopush trueTo list all available options, run:
$ badonde config --helpAnalytics
It's possible to report useful team-wide performance analytics to your own privately owned Firebase DB after each Badonde execution.
In order to do this, each team member should configure the required credentials as such:
$ badonde config firebase.projectId <YOUR_FIREBASE_DB_PROJECT_ID>
$ badonde config firebase.secretToken <YOUR_FIREBASE_DB_SECRET_TOKEN>You can add custom information to the report through your Badondefile:
analytics([
"author": badonde.github.me.login,
"labelCount": badonde.pullRequest.labels.count,
"hasMilestone": badonde.pullRequest.milestone != nil
])Special thanks
Badonde's architecture is heavily inspired by the concepts of the brilliant Danger Swift. Long live Swift scripting!