update contributing.md

- fix ./make.sh watch
- rename .jade -> .pug
This commit is contained in:
Matej Kramny 2017-02-22 03:51:23 -08:00
parent d6f12251c6
commit 80538908a8
33 changed files with 32 additions and 85 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ build/
public/js/bundle.js
public/css/semaphore.css
config.json
.DS_Store
.DS_Store
node_modules

View File

@ -6,111 +6,55 @@ 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 (`api-docs.yml`)
# Installation in a development environment
# Installing dependencies
- [Install Go](https://golang.org/doc/install)
- Install MySQL / MariaDB
- Install node.js
First of all you'll need the Go Language and Node.js installed. If you dont have them installed, you can follow these steps:
1) Create a directory called 'bin' in home that will receive the lib files from GoLang and Node.js:
1) Set up the gopath
```
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
mkdir -p $GOPATH/src/github.com/ansible-semaphore && cd $GOPATH/src/github.com/ansible-semaphore
```
2) Create project path and clone the repository with --recursive:
2) Clone semaphore (with submodules)
```
mkdir ~/GoProjects/src/github.com/ansible-semaphore/
cd ~/GoProjects/src/github.com/ansible-semaphore/
git clone --recursive git@github.com:ansible-semaphore/semaphore.git
git clone --recursive git@github.com:ansible-semaphore/semaphore.git && cd semaphore
```
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):
3) Install dev dependencies
```
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 ./...
```
5) Install node.js dependencies:
```
cd ~/GoProjects/src/github.com/ansible-semaphore/
npm install -g less pug-cli nodemon
go get ./... github.com/cespare/reflex github.com/jteeuwen/go-bindata/...
npm install async
npm install -g nodemon pug-cli less
```
6) OPTIONAL: Create a MySQL Container to develop (or install and setup One):
4) Set up config, database & run migrations
```
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:
```
cd ~/GoProjects/src/github.com/ansible-semaphore/semaphore
cat <<EOT >> config.json
{
"mysql": {
"host": "127.0.0.1:3306",
"user": "semaphore",
"pass": "semaphore",
"user": "root",
"pass": "",
"name": "semaphore"
},
"session_db": "127.0.0.1:6379",
"port": ":8010"
"port": ":3000"
}
EOT
echo "create database semaphore;" | mysql -uroot -p
go run cli/main.go -config ./config.json -migrate
```
9) Start the Watch process:
Now it's ready to start.. Run `./make.sh watch`
```
cd ~/GoProjects/src/github.com/ansible-semaphore/semaphore
./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.
- Watches js files in `public/js/*` and compiles into a bundle
- Watches css files in `public/css/*` and compiles into css code
- Watches pug files in `public/html/*` and compiles them into html
- Watches go files and recompiles the binary
- Open [localhost:3000](http://localhost:3000)

View File

@ -49,10 +49,11 @@ 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" &
pug -w -P html/*.jade html/*/*.jade html/*/*/*.jade &
pug -w -P html/*.pug html/*/*.pug html/*/*/*.pug &
cd ../
reflex -r '\.go$' -s -d none -- sh -c 'go run cli/main.go'
cd -
reflex -r '\.go$' -R '^public/vendor/' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore cli/main.go && /tmp/semaphore'
exit 0
fi

View File

@ -55,6 +55,7 @@ html(lang="en" ng-app="semaphore")
title Ansible-Semaphore on GitHub
path(d="M0 0h250v250")
path.octo-arm(d="M127.4 110c-14.6-9.2-9.4-19.5-9.4-19.5 3-7 1.5-11 1.5-11-1-6.2 3-2 3-2 4 4.7 2 11 2 11-2.2 10.4 5 14.8 9 16.2" fill="currentColor")
path.octo-body(d="M113.2 114.3s3.6 1.6 4.7.6l15-13.7c3-2.4 6-3 8.2-2.7-8-11.2-14-25 3-41 4.7-4.4 10.6-6.4 16.2-6.4.6-1.6 3.6-7.3 11.8-10.7 0 0 4.5 2.7 6.8 16.5 4.3 2.7 8.3 6 12 9.8 3.3 3.5 6.7 8 8.6 12.3 14 3 16.8 8 16.8 8-3.4 8-9.4 11-11.4 11 0 5.8-2.3 11-7.5 15.5-16.4 16-30 9-40 .2 0 3-1 7-5.2 11l-13.3 11c-1 1 .5 5.3.8 5z" fill="currentColor")
//- https://github.com/pugjs/pug/issues/2741
//- path.octo-body(d="M113.2 114.3s3.6 1.6 4.7.6l15-13.7c3-2.4 6-3 8.2-2.7-8-11.2-14-25 3-41 4.7-4.4 10.6-6.4 16.2-6.4.6-1.6 3.6-7.3 11.8-10.7 0 0 4.5 2.7 6.8 16.5 4.3 2.7 8.3 6 12 9.8 3.3 3.5 6.7 8 8.6 12.3 14 3 16.8 8 16.8 8-3.4 8-9.4 11-11.4 11 0 5.8-2.3 11-7.5 15.5-16.4 16-30 9-40 .2 0 3-1 7-5.2 11l-13.3 11c-1 1 .5 5.3.8 5z" fill="currentColor")
script(src="/public/js/bundle.js")