You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jackspirou 618f60fd11 updating READMD.md 9 years ago
.drone.yml removing ./... 9 years ago
.gitignore init 9 years ago
README.md updating READMD.md 9 years ago
main.go init 9 years ago
main_test.go updating READMD.md 9 years ago

README.md

drone-with-go Build Status Build Status

An example of how to test Go code with Drone.

Basic Testing

To run basic CI tests use the following in your .drone.yml file.

build:
  image: golang:1.5.3
  commands:
    - go test ./...

In this config image: golang:1.5.3 references the official Golang Docker image hosted on the Docker Hub registry at https://hub.docker.com/r/_/golang/. Go tests are execute with the go test ./... command.

Advanced Testing

Environment Variables

Using environment variables to configure Go testing is easy. Configure environment variables by setting the build section's environment.

build:
  image: golang:1.5.3
  environment:
    - GO15VENDOREXPERIMENT=1
    - GOOS=linux
    - GOARCH=amd64
    - CGO_ENABLED=0
  commands:
    - go test ./...

Coverage

Drone tests work best with the coverage plugin and the aircover.co service. We only want to send a coverage report when all tests pass, so the coverage plugin uses publish. Also, we should specify a particular branch so that coverage reports are consistent.

build:
  image: golang:1.5.3
  environment:
    - GO15VENDOREXPERIMENT=1
    - GOOS=linux
    - GOARCH=amd64
    - CGO_ENABLED=0
  commands:
    - go test -cover -coverprofile coverage.out

publish:
  coverage:
    when:
      branch: master

Plugins

Notification plugins use notify for integrations like HipChat. You can find a list of plugins at readme.drone.io/plugins.

build:
  image: golang:1.5.3
  environment:
    - GO15VENDOREXPERIMENT=1
    - GOOS=linux
    - GOARCH=amd64
    - CGO_ENABLED=0
  commands:
    - go test -cover -coverprofile coverage.out

publish:
  coverage:
    when:
      branch: master

notify:
  hipchat:
    from: Your_Project
    notify: true
    room_id_or_name: Your_Room
    auth_token: $$HIPCHAT_DRONE_TOKEN