Fixes #213. A set of information about development added to guide.

Pug is now used in the place of jade.
This commit is contained in:
gcavalcante8808 2016-11-15 13:02:39 -02:00
parent fd89143467
commit 709b3e8ac6
2 changed files with 92 additions and 24 deletions

View File

@ -6,39 +6,107 @@ When creating a pull-request you should:
- __gofmt and vet the code:__ Use `gofmt`, `golint`, `govet` and `goimports` to clean up your code.
- __Update api documentation:__ If your pull-request adding/modifying an API request, make sure you update the swagger documentation (`swagger.yml`)
# Installing dependencies
Clone the project to `$GOPATH/src/github.com/ansible-semaphore/semaphore` (more on GOPATHS below)
First of all you'll need the Go Language and Node.js installed. If you dont have them installed, you can follow these steps:
> note: You should clone semaphore with all submodules
> - you should have latest go installed and node with ES6 (used to be a special `harmony` flag) capability
1) Create a directory called 'bin' in home that will receive the lib files from GoLang and Node.js:
```
mkdir ~/bin
cd ~/bin
wget https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz
wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.xz
tar xvf go1.7.3.linux-amd64.tar.gz
tar xvf node-v6.9.1-linux-x64.tar.xz
mv go golang
mv node-v6.9.1-linux-x64 node-js
ln -s ~/bin/golang/bin/go ./go
ln -s ~/bin/golang/bin/godoc ./godoc
ln -s ~/bin/golang/bin/gofmt ./gofmt
ln -s ~/bin/node-js/bin/node ./node
ln -s ~/bin/node-js/bin/npm ./npm
```
2) Create project path and clone the repository with --recursive:
```
mkdir ~/GoProjects/src/github.com/ansible-semaphore/
cd ~/GoProjects/src/github.com/ansible-semaphore/
git clone --recursive git@github.com:ansible-semaphore/semaphore.git
```
3) Add environment variables to .profile (or .bashrc) need by go and npm (Don't forget to use source on file or reopen the terminal after):
```
PATH=/~/bin:/~/GoProjects/bin:/~/.npm-global/bin:$PATH
GOPATH=~/GoProjects
GOROOT=~/bin/golang
NPM_CONFIG_PREFIX=~/.npm-global
export PATH GOPATH GOROOT NPM_CONFIG_PREFIX
```
4) Clone project and Install go dependencies:
cd ~/GoProjects/src/github.com/ansible-semaphore/
git clone --recursive https://github.com/ansible-semaphore/semaphore.git
go get github.com/jteeuwen/go-bindata/...
go get github.com/mitchellh/gox
go get github.com/cespare/reflex
go get -u ./...
npm i -g nodemon less jade
npm i async
```
## Gopaths
To develop in Go, you need to setup a gopath where go code, libraries & executables live.
Follow either of these ([go wiki](https://github.com/golang/go/wiki/GOPATH), [tutorial](http://www.ryanday.net/2012/10/01/installing-go-and-gopath/), [SO question](https://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit)).
1. `mkdir -p $GOPATH/src/github.com/ansible-semaphore`
2. `cd $GOPATH/src/github.com/ansible-semaphore`
3. `git clone --recursive git@github.com:ansible-semaphore/semaphore.git`
4. Now install dependencies above
# Running in development
You will need to have a local `config.json` file because it is linked to. It should contain your local configuration.
5) Install node.js dependencies:
```
cd ~/GoProjects/src/github.com/ansible-semaphore/
npm install -g less pug
npm install async
```
6) OPTIONAL: Create a MySQL Container to develop (or install and setup One):
```
docker run -d --name semaphore-db -v semaphore-data:/var/lib/mysql -p 3306:3306 -e MYSQL_USER=semaphore -e MYSQL_DATABASE=semaphore -e MYSQL_PASSWORD=semaphore -e MYSQL_ROOT_PASSWORD=semaphore mysql
```
7) Download the 2.0.4 version into main directory and run the setup to trigger the db migration:
```
wget https://github.com/ansible-semaphore/semaphore/releases/download/v2.0.4/semaphore_linux_amd64
chmod +x semaphore_linux_amd64
./semaphore_linux_amd64 -setup
```
8) Created a config.json which have the Database information to start the development:
```
cat <<EOT >> config.json
{
"mysql": {
"host": "127.0.0.1:3306",
"user": "semaphore",
"pass": "semaphore",
"name": "semaphore"
},
"session_db": "127.0.0.1:6379",
"port": ":8010"
}
EOT
```
9) Start the Watch process:
```
$EDITOR config.json
./make.sh watch
```
10) Point your browser to localhost:8010. Enjoy.
# Other Informations
For more information about GoPaths take a look at ([go wiki](https://github.com/golang/go/wiki/GOPATH), [tutorial](http://www.ryanday.net/2012/10/01/installing-go-and-gopath/), [SO question](https://stackoverflow.com/questions/21001387/how-do-i-set-the-gopath-environment-variable-on-ubuntu-what-file-must-i-edit)).
You will need to have a local `config.json` file because it is linked to. It should contain your local configuration.

View File

@ -28,7 +28,7 @@ EOF
cd public
lessc css/semaphore.less > css/semaphore.css
jade html/*.jade html/*/*.jade html/*/*/*.jade &
pug html/*.jade html/*/*.jade html/*/*/*.jade &
cd -
fi
@ -49,7 +49,7 @@ if [ "$1" == "watch" ]; then
nodemon -w js -i bundle.js -e js bundler.js &
nodemon -w css -e less --exec "lessc css/semaphore.less > css/semaphore.css" &
jade -w -P html/*.jade html/*/*.jade html/*/*/*.jade &
pug -w -P html/*.jade html/*/*.jade html/*/*/*.jade &
cd ../
reflex -r '\.go$' -s -d none -- sh -c 'go run cli/main.go'