Skip to content

Latest commit

 

History

History
97 lines (71 loc) · 2.76 KB

hacking.md

File metadata and controls

97 lines (71 loc) · 2.76 KB

Hacking on Draft

This guide is for developers who want to improve Draft. These instructions will help you set up a development environment for working on the Draft source code.

Prerequisites

To compile and test Draft binaries and to build Docker images, you will need:

In most cases, install the prerequisite according to its instructions. See the next section for a note about Go cross-compiling support.

Configuring Go

Draft's binary executables are built on your machine and then copied into a Docker image. This requires your Go compiler to support the linux/amd64 target architecture. If you develop on a machine that isn't AMD64 Linux, make sure that go has support for cross-compiling.

On macOS, a cross-compiling Go can be installed with Homebrew:

$ brew install go --with-cc-common

It is also straightforward to build Go from source:

$ sudo su
$ curl -sSL https://storage.googleapis.com/golang/go1.10.src.tar.gz | tar -C /usr/local -xz
$ cd /usr/local/go/src
$ # compile Go for the default platform first, then add cross-compile support
$ ./make.bash --no-clean
$ GOOS=linux GOARCH=amd64 ./make.bash --no-clean

Fork the Repository

Begin at Github by forking Draft, then clone your fork locally. Since Draft is a Go package, it should be located at $GOPATH/src/github.com/Azure/draft.

$ mkdir -p $GOPATH/src/github.com/Azure
$ cd $GOPATH/src/github.com/Azure
$ git clone [email protected]:<username>/draft.git
$ cd draft

Add the conventional upstream git remote in order to fetch changes from Draft's main master branch and to create pull requests:

$ git remote add upstream https://github.com/Azure/draft.git

Build Your Changes

With the prerequisites installed and your fork of Draft cloned, you can make changes to local Draft source code.

Run make to build draft:

$ make bootstrap
$ make

Test Your Changes

Draft includes a suite of tests.

  • make test-lint: runs linter/style checks
  • make test-unit: runs basic unit tests
  • make test: runs all of the above

Cleaning Up

$ make clean