Skip to content

Commit

Permalink
Adds tools to make local building easier.
Browse files Browse the repository at this point in the history
 - Added the Makefile and Sublime Text project file that I use.
 - Created a tool to symlink the tools and copy a working config.
 - Updated the README to use this setup exclusively.
  • Loading branch information
kellegous committed Jul 4, 2015
1 parent 52c13f5 commit 753b605
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 80 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.vagrant
.build
config.json*
.DS_Store
*.exe
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ We've used many similar tools in the past, and most of them are either too slow,
Which brings us to...
## Requirements
### Hard Requirements
* Go 1.3+
### Optional, Recommended Software
* Make (for building the binaries, not strictly required)
* nodejs (for the command line react-tools)
Yup, that's it. You can proxy requests to the Go service through Apache/nginx/etc., but that's not required.
## Docker
Expand Down Expand Up @@ -95,38 +89,37 @@ Currently the following editors have plugins that support Hound:
### Editing & Building
Hound uses the standard Go tools for development, so your favorite Go workflow should work. If you are looking for something that will work, here is one option:
#### Requirements:
* make
* Node.js ([Installation Instructions](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager))
* React-tools (install w/ `npm -g install react-tools`)
Hound includes tools to make building locally easy. It is recommended that you use these tools if you are working on Hound. To get setup and build, just run the following commands:
```
git clone https://github.com/etsy/Hound.git hound/src/github.com/etsy/hound
git clone https://github.com/etsy/Hound.git hound/src/github.com/etsy/Hound
cd hound
GOPATH=`pwd` go install github.com/etsy/hound/cmds/...
src/github.com/etsy/Hound/tools/setup
make
```
### Testing
There are an increasing number of tests in each of the packages in Hound. Please make sure these pass before uploading your Pull Request. You can run the tests with the following command.
```
GOPATH=`pwd` go test github.com/etsy/hound/...
make test
```
### Working on the web UI
Hound includes a web UI that is composed of several files (html, css, javascript, etc.). To make sure hound works seamlessly with the standard Go tools, these resources are all built inside of the `houndd` binary. This adds a small burden on developers to re-package the UI files after each change. If you make changes to the UI, please follow these steps:
Hound includes a web UI that is composed of several files (html, css, javascript, etc.). To make sure hound works seamlessly with the standard Go tools, these resources are all bundled inside of the `houndd` binary. Note that changes to the UI will result in local changes to the `ui/bindata.go` file. You must includes these changes in your Pull Request.
1. To make development easier, there is a flag that will read the files from the file system (allowing the much-loved edit/refresh cycle).
```
bin/houndd --dev
```
To make development easier, there is a flag that will read the files from the file system (allowing the much-loved edit/refresh cycle).
2. Before uploading a Pull Request, please run the following command. This should regenerate the file `ui/bindata.go` which should be included in your Pull Request.
```
cd src/github.com/etsy/hound
make
```
```
bin/houndd --dev
```
## Get in Touch
Expand Down
21 changes: 21 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ALL: commands

ASSETS=$(shell find src/github.com/etsy/Hound/ui/assets)

bin/go-bindata:
GOPATH=$(shell pwd) go get github.com/jteeuwen/go-bindata/...

src/github.com/etsy/Hound/ui/bindata.go: bin/go-bindata $(ASSETS)
mkdir -p build/ui
rsync -r --exclude '*.js' src/github.com/etsy/Hound/ui/assets/* build/ui
jsx --no-cache-dir src/github.com/etsy/Hound/ui/assets/js build/ui/js
$< -o $@ -pkg ui -prefix build/ui -nomemcopy build/ui/...

commands: src/github.com/etsy/Hound/ui/bindata.go
GOPATH=$(shell pwd) go install github.com/etsy/hound/cmds/...

clean:
rm -rf bin/hound bin/houndd build

test:
GOPATH=$(shell pwd) go test github.com/etsy/hound/...
8 changes: 8 additions & 0 deletions tools/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dbpath" : "data",
"repos" : {
"Hound" : {
"url" : "https://www.github.com/etsy/Hound.git"
}
}
}
2 changes: 1 addition & 1 deletion hound.sublime-project → tools/hound.sublime-project
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"follow_symlinks": true,
"path": ".",
"folder_exclude_patterns": ["data"]
"folder_exclude_patterns": ["data", "data-1k"]
}
],
"settings":
Expand Down
40 changes: 40 additions & 0 deletions tools/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python2.7

import os
import shutil
import sys

def get_tools_directory():
""" get the location of the Hound tools directory """
return os.path.realpath(os.path.dirname(__file__))

def has_valid_location(tools):
""" ensure that the repository is in the GOPATH """
parts = [x.lower() for x in tools.split(os.sep)]
return parts[-5:-1] == ['src', 'github.com', 'etsy', 'hound']

def process(src, dst, filenames, op):
""" process the filenames from source and use op to produce them in dst """
for filename in filenames:
target = os.path.join(dst, filename)
if os.path.exists(target):
continue
op(os.path.join(src, filename), target)

def main():
tools = get_tools_directory()
if not has_valid_location(tools):
print >> sys.stderr, "The Hound repository should be in a directory like:"
print >> sys.stderr, "src/github.com/etsy/Hound"
print >> sys.stderr, ""
print >> sys.stderr, "Follow the directions at https://github.com/etsy/Hound#editing--building"
return 1
work = os.path.join(tools, '..', '..', '..', '..', '..')

process(tools, work, ['Makefile', 'hound.sublime-project'], os.symlink)
process(tools, work, ['config.json'], shutil.copy)

return 0

if __name__ == '__main__':
sys.exit(main())
Loading

0 comments on commit 753b605

Please sign in to comment.