Building Tools with GitHub
by Chris Dawson and Ben Straub
Copyright 2016 Chris Dawson, Ben Straub. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editors: Brian MacDonald and Meghan Blanchette
- Production Editor: Nicholas Adams
- Copyeditor: Christina Edwards
- Proofreader: Kim Cofer
- Indexer: WordCo Indexing Services, Inc.
- Interior Designer: David Futato
- Cover Designer: Randy Comer
- Illustrator: Rebecca Demarest
- February 2016: First Edition
Revision History for the First Edition
- 2016-02-05: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491933503 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Building Tools with GitHub, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-93350-3
[LSI]
Preface
This book contains stories about building software tools.
If you write software on a daily basis, you realize the act ofwriting software is the craft of creating tools. Software is nothingmore than a tool. A spreadsheet is fundamentally a tool toadd and subtract numbers. A video game is fundamentally a tool toalleviate boredom. Almost immediately after people started writingsoftware tools we then discovered we needed more tools to permit us towrite the tools we set out to build in the first place. Letscall these tools that are strictly to support writing software (ratherthan software tools for the general population) meta-tools.
One of the most important meta-tools in the software development worldis Git. Git is a meta-tool that helps software developersmanage the complexity that comes from writing software. Git allowssoftware developers to store snapshots of their programs (and theneasily restore those snapshots if necessary) and to easily collaboratewith other programmers (a surprisingly complicated problem). Git iscalled a source code management (SCM) tool and though there were many otherSCMs before Git, Git has taken the software world by storm like noother before it and now dominates the SCM landscape.
GitHub is a company that saw the immense potential of Git early on andbuilt a layer of web services on top of the existing features foundin Git. Not surprisingly, one of the factors behind its success was thatGitHub employees embraced the ethos of writing meta-tools from thebeginning. Building meta-tools requires the courage to take a littleextra time to build a meta-tool rather thantaking the easy route to get the public-facing software out thedoor. GitHub employees are proud of this prioritization and havewritten extensively about the benefits, which include easy on-boardingof new hires and a transparent workflow visible to all employees.
This book looks at the tools GitHub uses internally. TheGitHub.com website is itself a meta-tool, and we discuss the manyfacets of the GitHub service. Specifically these technologies are theGitHub API and related GitHub technologies, Gollum wiki, Jekyllstatic page generator, and the chat robot called Hubot (if you arenot familiar with any of these, well explain them fully in theirrespective chapters).
To reiterate, this book is not a reference of those technologies. Thisbook is a story-book, a book that relates the process of buildingsoftware meta-tools, explaining not only the technology specifics, butalso the compromises, the realities of refactoring, and the challengesinherent to writing meta-tools in long narrative storyform.
Meta-tools require a different mindset than what comes frombuilding software available to the general population. Meta-tools aregenerally open source, which requires adifferent level of responsibility and usage. One could argue thatsoftware engineers are more demanding of quality than general usersbecause software developers know they can take action to improve orfork software that does not work for them. Meta-tools enforce a higherlevel of contributory involvement, which makes automated testsalmost a requirement. All of these concepts constitute the backgroundstory behind meta-tools, and we show you how they play out whenbuilding your own.
Why APIs and Why the GitHub API?
Using an API to back an application is a common practice today: thisis the future of application development. APIs provide a great patternfor making data accessible to the multiscreen world. If yourapplication is backed by a remote service API, thefirst application could be a mobile app running on Apples iOSoperating system. Critically, if that business model does not turn outto be correct, you can respond quickly to changing requirements anditerate to build another application for an Android wearable. Or,perhaps youll build an integrated car application, or any otherconsole (or even nonconsole) application. As long as your applicationscan send and receive data using calls to a remote API you are free tobuild whatever user interface you want on whatever platform you want.
As an author, you could write and host your own API. Many frameworksfor popular languages like Ruby, Go, or Java support building APIsusing standard architectural styles like REST. Or, you could use athird-party API. In this book well focus on a third-party API: theGitHub API.
Why the GitHub API? The GitHub API is exceedingly relevant if you arebuilding software because you are probably using GitHub to manage yoursoftware code. For those that arent, you might be using Git withoutGitHub, and the GitHub API is useful to know there as well, as itlayers the functionality of Git into a networked programming interface.
The GitHub API is perhaps the best designed API Ive ever used. It isa Hypermedia API, which is an arguably successful attempt to makeAPI clients resilient to API changesa tricky problem. The API is wellversioned. It is comprehensive, mapping closely to most features ofGit. It is consistent across sections and well organized. The GitHubAPI is a great API on which to build applications, serving as acase study for a well-designed API.
Structure of This Book
The GitHub API is extremely comprehensive, permitting access andmodification of almost all data and metadata stored or associated witha Git repository. Here is a grouped summary of the sections of the API orderedalphabetically as they are on the GitHub API documentation site:
Activity: notifications of interesting events in your developer life
Gists: programmatically create and share code snippets
Git Data: raw access to Git data over a remote API
Issues: add and modify issues
Miscellaneous: whatever does not fit into the general APIcategorization