<commit_before># Developing Quilt

## Developer Setup

### Install Go

The project is written in Go and supports Go version 1.8 or later. Install
Go using your package manager (Go is commonly referred to as "golang" in
package managers and elsewhere) or via the
[Go website](https://golang.org/doc/install).

If you've never used Go before, we recommend reading the overview to Go
workspaces [here](https://golang.org/doc/code.html#Workspaces). In short,
you'll need to configure the `GOPATH` environment variable to be the location
where you'll keep all Go code. For example, if you'd like your Go workspace
to be `$HOME/gowork`:

```console
export GOPATH="$HOME/gowork"
export PATH="$GOPATH/bin:$PATH"
```

Add these commands to your `.bashrc` so that they'll be run automatically each
time you open a new shell.

### Download Quilt

Clone the Quilt repository into your Go workspace using `go get`:

```console
$ go get github.com/quilt/quilt
```

This will install Quilt in your Go workspace at
`$GOPATH/src/github.com/quilt/quilt`, and compile Quilt. After running
installing Quilt, the `quilt` command should execute successfully in your shell.

<aside class="notice">If you use git to clone the Quilt repository, make sure
that you clone it to the directory
<code class="prettyprint">$GOPATH/src/github.com/quilt/quilt</code>.
The Go language is opinionated about the directory structure of code, and if
you don't put Quilt in the expected location, you'll run into errors when you
use Go to compile Quilt.</aside>

Note that if you've previously installed Quilt with npm, there will be
another Quilt binary installed on your machine (that was downloaded during the
npm installation).  If you want to develop Quilt,
you probably want to make sure that when you run `quilt`, the version you're
developing (that was compiled from the Go code) gets run, and not the Quilt
release that was downloaded from npm. Check that this is the case:

```console
$ which quilt
/Users/kay/gowork/bin/quilt
```

If running `which quilt` results in a path that includes your `$GOPATH$`, like
the one above, you're all set.  If it instead returns someplace else, e.g.,
`/usr/local/bin/quilt`, you'll need to fix your `$PATH` variable so that
`$GOPATH/bin` comes first.

### Building Quilt

To build Quilt, run `go install` in the Quilt directory. To do things beyond
basic build and install, several additional build tools are required.  These
can be installed with the `make go-get` target.

If you're developing the the @quilt/quilt package, you must also tell Node.js
to use your local development copy of the Quilt JavaScript bindings by running:

```console
$ npm link .
```
in the directory that contains your local Quilt source files. For each blueprint
that uses the Quilt JavaScript bindings, you must also run:

```console
$ npm link @quilt/quilt
```

in the directory that contains the blueprint JavaScript files.

### Protobufs
If you change any of the proto files, you'll need to regenerate the protobuf
code. We currently use protoc v3. On a Mac with homebrew, you can install protoc v3
using:

```console
$ brew install protobuf
```

On other operating systems you can directly download the protoc binary
[here](https://github.com/google/protobuf/releases), and then add it to your `$PATH`.

To generate the protobufs simply call:

```console
$ make generate
```

### Dependencies
We use [govendor](https://github.com/kardianos/govendor) for dependency
management. If you are using Go 1.5 make sure `GO15VENDOREXPERIMENT` is set to 1.

To add a new dependency:

1. Run `go get foo/bar`
2. Edit your code to import `foo/bar`
3. Run `govendor add +external`

To update a dependency:

```console
$ govendor update +vendor
```
<commit_msg>docs: Update build and test instructions<commit_after># Developing Quilt

## Setup

### Install Go

The project is written in Go and supports Go version 1.8 or later. Install
Go using your package manager (Go is commonly referred to as "golang" in
package managers and elsewhere) or via the
[Go website](https://golang.org/doc/install).

If you've never used Go before, we recommend reading the overview to Go
workspaces [here](https://golang.org/doc/code.html#Workspaces). In short,
you'll need to configure the `GOPATH` environment variable to be the location
where you'll keep all Go code. For example, if you'd like your Go workspace
to be `$HOME/gowork`:

```console
export GOPATH="$HOME/gowork"
export PATH="$GOPATH/bin:$PATH"
```

Add these commands to your `.bashrc` so that they'll be run automatically each
time you open a new shell.

### Download Quilt

Clone the Quilt repository into your Go workspace using `go get`:

```console
$ go get github.com/quilt/quilt
```

This will install Quilt in your Go workspace at
`$GOPATH/src/github.com/quilt/quilt`, and compile Quilt. After running
installing Quilt, the `quilt` command should execute successfully in your shell.

<aside class="notice">If you use git to clone the Quilt repository, make sure
that you clone it to the directory
<code class="prettyprint">$GOPATH/src/github.com/quilt/quilt</code>.
The Go language is opinionated about the directory structure of code, and if
you don't put Quilt in the expected location, you'll run into errors when you
use Go to compile Quilt.</aside>

### Protobufs
If you change any of the proto files, you'll need to regenerate the protobuf
code. We currently use protoc v3. On a Mac with homebrew, you can install protoc v3
using:

```console
$ brew install protobuf
```

On other operating systems you can directly download the protoc binary
[here](https://github.com/google/protobuf/releases), and then add it to your `$PATH`.

To generate the protobufs simply call:

```console
$ make generate
```

### Dependencies
We use [govendor](https://github.com/kardianos/govendor) for dependency
management. If you are using Go 1.5 make sure `GO15VENDOREXPERIMENT` is set to 1.

To add a new dependency:

1. Run `go get foo/bar`
2. Edit your code to import `foo/bar`
3. Run `govendor add +external`

To update a dependency:

```console
$ govendor update +vendor
```

## Building and Testing

### Building and Testing the Go Code

To build Quilt, run `go install` in the Quilt directory.  To do things beyond
basic build and install, several additional build tools are required.  These
can be installed with the `make go-get` target.

Note that if you've previously installed Quilt with npm, there will be
another Quilt binary installed on your machine (that was downloaded during the
npm installation).  If you want to develop Quilt,
you probably want to make sure that when you run `quilt`, the version you're
developing (that was compiled from the Go code) gets run, and not the Quilt
release that was downloaded from npm. Check that this is the case:

```console
$ which quilt
/Users/kay/gowork/bin/quilt
```

If running `which quilt` results in a path that includes your `$GOPATH$`, like
the one above, you're all set.  If it instead returns someplace else, e.g.,
`/usr/local/bin/quilt`, you'll need to fix your `$PATH` variable so that
`$GOPATH/bin` comes first.

To run the `go` tests, use the `gocheck` Make target in the root directory:

```console
$ make gocheck
```

If you'd like to run the tests in just one package, e.g., the tests in the
`engine` package, use `go test` with the package name:

```console
$ go test github.com/quilt/quilt/engine
```

### Building and Testing the JavaScript Code

To run the JavaScript code, you'll need to use `npm` to install Quilt's
dependencies:

```console
$ npm install .
```

If you're developing the @quilt/quilt package, you must also tell Node.js
to use your local development copy of the Quilt JavaScript bindings (when you
use Quilt to run blueprints) by running:

```console
$ npm link .
```

in the directory that contains your local Quilt source files. For each blueprint
that uses the Quilt JavaScript bindings, you must also run:

```console
$ npm link @quilt/quilt
```

in the directory that contains the blueprint JavaScript files.

To run the JavaScript tests for `bindings.js`, use the `jscheck` build target:

```console
$ make jscheck
```

{'fraction_non_alphanumeric': 0.0855844793713163, 'fraction_numerical': 0.0029469548133595285, 'mean_word_length': 4.455458807769592, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2070869', 'n_tokens_mistral': 2451, 'n_tokens_neox': 2297, 'n_words': 1175}