diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..24bfe64 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,9 @@ +build: + image: golang:1.5.3 + environment: + - GO15VENDOREXPERIMENT=1 + - GOOS=linux + - GOARCH=amd64 + - CGO_ENABLED=0 + commands: + - go test -cover ./... diff --git a/.gitignore b/.gitignore index daf913b..9a51cfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Drone Files +.secrets.yml + # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a diff --git a/README.md b/README.md index 5868837..19e766f 100644 --- a/README.md +++ b/README.md @@ -1 +1,53 @@ -# drone-with-go \ No newline at end of file +# drone-with-go [![Build Status](http://beta.drone.io/api/badges/drone-demos/drone-with-go/status.svg)](http://beta.drone.io/drone-demos/drone-with-go) + +An example of how to test Go code. + +# Basic Testing +To run basic CI tests use the following in your `.drone.yml` file. + +```yaml +build: + image: golang:1.5.3 + commands: + - go test ./... +``` + +# Advanced Testing +Using environment variables to configure Go testing is easy. +Configure environment variables by setting the `build` section's `environment`. + +`.drone.yml`: +```yaml +build: + image: golang:1.5.3 + environment: + - GO15VENDOREXPERIMENT=1 + - GOOS=linux + - GOARCH=amd64 + - CGO_ENABLED=0 + commands: + - go test ./... +``` + +Below is a more advanced `.drone.yml` for need things like HipChat integration. + +```yaml + +build: + image: golang:1.5.3 + environment: + - GO15VENDOREXPERIMENT=1 + - GOOS=linux + - GOARCH=amd64 + - CGO_ENABLED=0 + - COVERALLS_TOKEN=$$COVERALLS_TOKEN + commands: + - go test -cover ./... + +notify: + hipchat: + from: Your_Project + notify: true + room_id_or_name: Your_Room + auth_token: $$HIPCHAT_DRONE_TOKEN +``` diff --git a/main.go b/main.go new file mode 100644 index 0000000..4d35264 --- /dev/null +++ b/main.go @@ -0,0 +1,12 @@ +package main + +import "fmt" + +func main() { + fmt.Println(HelloWorld()) +} + +// HelloWorld is a function that returns a string containing "hello world". +func HelloWorld() string { + return "hello world" +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..d844446 --- /dev/null +++ b/main_test.go @@ -0,0 +1,9 @@ +package main + +import "testing" + +func TestHelloWorld(t *testing.T) { + if HelloWorld() != "hello world" { + t.Errorf("got %s expected %s", HelloWorld(), "hello world") + } +}