2016-04-29 15:58:17 +02:00
# 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.
2018-03-11 15:22:50 +01:00
- __vendor dependencies with dep:__ Use `dep ensure --update` if you have added to or updated dependencies, so that they get added to the dependency manifest.
2017-01-11 01:33:07 +01:00
- __Update api documentation:__ If your pull-request adding/modifying an API request, make sure you update the swagger documentation (`api-docs.yml`)
2018-04-11 20:05:38 +02:00
- __Run Api Tests:__ If your pull request modifies the API make sure you run the integration tests using dredd.
2016-04-29 15:58:17 +02:00
2017-02-22 12:51:23 +01:00
# Installation in a development environment
2016-11-15 16:02:39 +01:00
2017-05-20 16:32:03 +02:00
- Check out the `develop` branch
2018-03-14 20:26:52 +01:00
- [Install Go ](https://golang.org/doc/install ). Go must be >= v1.10 for all the tools we use to work
2021-07-12 10:04:56 +02:00
- Install MySQL / MariaDB (OPTIONAL!!!)
2017-02-22 12:51:23 +01:00
- Install node.js
2016-04-29 15:58:17 +02:00
2018-03-07 23:09:25 +01:00
1) Set up GOPATH, GOBIN and Workspace.
2016-11-15 16:02:39 +01:00
```
2017-03-08 16:28:55 +01:00
cd {WORKING_DIRECTORY}
2018-03-07 23:09:25 +01:00
# Exports only needed pre Go 1.8 or for custom GOPATH location
2017-03-08 16:28:55 +01:00
export GOPATH=`pwd`
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
2017-02-22 12:51:23 +01:00
mkdir -p $GOPATH/src/github.com/ansible-semaphore & & cd $GOPATH/src/github.com/ansible-semaphore
2016-11-15 16:02:39 +01:00
```
2017-02-22 12:51:23 +01:00
2) Clone semaphore (with submodules)
2016-11-15 16:02:39 +01:00
2016-11-15 16:05:18 +01:00
```
2017-02-22 12:51:23 +01:00
git clone --recursive git@github.com:ansible-semaphore/semaphore.git & & cd semaphore
2016-11-15 16:05:18 +01:00
```
2016-04-30 09:52:33 +02:00
2017-02-22 12:51:23 +01:00
3) Install dev dependencies
2016-11-15 16:02:39 +01:00
```
2021-07-12 09:53:33 +02:00
go install github.com/go-task/task/v3/cmd/task@latest
2018-03-07 23:09:25 +01:00
task deps
2016-04-29 15:58:17 +02:00
```
2018-03-20 23:40:54 +01:00
Windows users will additionally need to manually install goreleaser from https://github.com/goreleaser/goreleaser/releases
2021-07-12 10:22:08 +02:00
4) Create database if you want to use MySQL (Semaphore also supports [bbolt ](https://github.com/etcd-io/bbolt ), it doesn't require additional action)
2016-04-29 15:58:17 +02:00
2016-11-15 16:02:39 +01:00
```
2017-02-22 12:51:23 +01:00
echo "create database semaphore;" | mysql -uroot -p
2021-07-12 10:02:42 +02:00
```
2021-07-12 10:22:08 +02:00
5) Compile, set up & run
2021-07-12 10:02:42 +02:00
```
2018-03-07 23:09:25 +01:00
task compile
2021-08-25 22:36:04 +02:00
go run cli/main.go setup
2022-01-24 13:02:16 +01:00
go run cli/main.go service --config ./config.json
2016-05-21 00:07:27 +02:00
```
2016-11-15 16:02:39 +01:00
2021-07-12 09:58:36 +02:00
Open [localhost:3000 ](http://localhost:3000 )
2017-06-01 18:52:06 +02:00
2018-03-07 23:09:25 +01:00
Note: for Windows, you may need [Cygwin ](https://www.cygwin.com/ ) to run certain commands because the [reflex ](github.com/cespare/reflex ) package probably doesn't work on Windows.
You may encounter issues when running `task watch` , but running `task build` etc... will still be OK.
2018-04-11 20:05:38 +02:00
## Integration Tests
Dredd is used for API integration tests, if you alter the API in any way you must make sure that the information in the api docs
matches the responses.
As Dredd and the application database config may differ it expects it's own config.json in the .dredd folder.
The most basic configuration for this using a local docker container to run the database would be
```json
{
"mysql": {
"host": "0.0.0.0:3306",
"user": "semaphore",
"pass": "semaphore",
"name": "semaphore"
}
}
```
It is strongly advised to run these tests inside docker containers, as dredd will write a lot of test information and will __NOT__ clear it up.
This means that you should never run these tests against your productive database!
The best practice to run these tests is to use docker and the task commands.
```bash
2018-10-22 05:56:53 +02:00
context=dev task dc:build #build fresh semaphore images
context=dev task dc:up #up semaphore and mysql
task dc:build:dredd #build fresh dredd image
task dc:up:dredd #run dredd over docker-compose stack
2020-10-01 10:01:04 +02:00
```