Semaphore/CONTRIBUTING.md
莫源 ef77120c0e Update CONTRIBUTING.md
change pug to pug-cli
2016-11-25 16:38:30 +08:00

3.5 KiB

Pull Requests

When creating a pull-request you should:

  • Open an issue first: Confirm that the change or feature will be accepted
  • 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

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:
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
  1. 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
  1. 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
  1. 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 ./...
  1. Install node.js dependencies:
cd ~/GoProjects/src/github.com/ansible-semaphore/
npm install -g less pug-cli
npm install async
  1. 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
  1. 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
  1. 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
  1. Start the Watch process:
./make.sh watch
  1. Point your browser to localhost:8010. Enjoy.

Other Informations

For more information about GoPaths take a look at (go wiki, tutorial, SO question).

You will need to have a local config.json file because it is linked to. It should contain your local configuration.