Development

Go and environemt path

Please run these commands to confirm you have Go installed properly. If you can’t find the Go command, please check The Go Programming Language - Getting Started

$ go version
go version go1.9.4 darwin/amd64

Also, please make sure you have the correct GOPATH in your enviroment variables to prevent compilation issues.

$ env|grep GOPATH
GOPATH=/Users/charles/gowork

Note

You can find more detail in Setting GOPATH

Build Documentation

We use Sphinx to build this documentation, please make sure it is installed properly.

$ pip install sphinx
$ pip install sphinx_rtd_theme

$ make doc

You should be able to find this documentation under docs/build/html/.

Run Unit Tests

$ make test

### Check code coverage
$ go tool cover -html=coverage.gowf.out
$ go tool cover -html=coverage.dedup.out

Run CI tests

We use a .gitlab-ci.yml to help us run CI tests and build processes. Please run it and make sure it passes before submitting a patch upstream.

Gitlab runner

$ sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
$ sudo chmod +x /usr/local/bin/gitlab-runner

Note

You can find more details in Install Gitlab Runner on Mac

Docker

Please follow the instructions in Install Docker for Mac to install docker.

Trigger GitLab runner with Docker

The GitLab runner launches a docker image and runs scripts to install required packages, all test cases and builds binaries in the end.

$ make gitlab
gitlab-runner exec docker format
WARNING: Since GitLab Runner 10.0 this command is marked as DEPRECATED and will be removed in one of upcoming releases
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-runner 10.4.0 (857480b6)
on  ()
Using Docker executor with image golang:1.9.2 ...
Using docker image sha256:9427850b2591293a89c98ac80a9f8a67358998ea71d40fb2064c16ed7228c96d for predefined container...
Pulling docker image golang:1.9.2 ...
.
.
.
GOOS=linux GOARCH=amd64 go build -ldflags "-w -s -X main.Version=0.0.8-26-gd1389df -X main.UpgradeServer=https://cloud.swiftstack.com/v1/AUTH_gowfdev/" -o /builds/project-0/build/gowf.linux cmd/gowf.go
Running after script...
Job succeeded