25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DOCS.md 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # 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) [![Build Status](https://aircover.co/badges/drone-demos/drone-with-go/coverage.svg)](https://aircover.co/drone-demos/drone-with-go)
  2. An example of how to test Go code with Drone.
  3. # Basic Testing
  4. To run basic CI tests use the following in your `.drone.yml` file.
  5. ```yaml
  6. build:
  7. image: golang:1.5.3
  8. commands:
  9. - go test ./...
  10. ```
  11. In this config `image: golang:1.5.3` references the official Golang Docker image hosted at https://hub.docker.com/r/_/golang/ and Go tests are execute with the `go test ./...` command.
  12. # Advanced Testing
  13. ## Environment Variables
  14. Use environment variables to configure Go testing.
  15. Set environment variables with the `build` section's `environment`.
  16. ```yaml
  17. build:
  18. image: golang:1.5.3
  19. environment:
  20. - GO15VENDOREXPERIMENT=1
  21. - GOOS=linux
  22. - GOARCH=amd64
  23. - CGO_ENABLED=0
  24. commands:
  25. - go test ./...
  26. ```
  27. ## Coverage
  28. Drone tests work best with the [Coverage plugin](http://readme.drone.io/plugins/coverage/) and the [aircover.co](https://aircover.co/docs/overview/) service.
  29. We only want to send a coverage report when all tests pass, so the Coverage plugin uses `publish`.
  30. Also, we should specify a particular branch so that coverage reports are consistent.
  31. ```yaml
  32. build:
  33. image: golang:1.5.3
  34. environment:
  35. - GO15VENDOREXPERIMENT=1
  36. - GOOS=linux
  37. - GOARCH=amd64
  38. - CGO_ENABLED=0
  39. commands:
  40. - go test -cover -coverprofile coverage.out
  41. publish:
  42. coverage:
  43. when:
  44. branch: master
  45. ```
  46. ## Plugins
  47. Notification plugins use `notify` for integrations like HipChat.
  48. `publish` is used for publishing GitHub Releases, Coverage reports, and more.
  49. `deploy` is used for deployments to systems like AWS and Rancher.
  50. You can find a list of plugins at [readme.drone.io/plugins](http://readme.drone.io/plugins/).
  51. ```yaml
  52. build:
  53. image: golang:1.5.3
  54. environment:
  55. - GO15VENDOREXPERIMENT=1
  56. - GOOS=linux
  57. - GOARCH=amd64
  58. - CGO_ENABLED=0
  59. commands:
  60. - go test -cover -coverprofile coverage.out
  61. publish:
  62. coverage:
  63. when:
  64. branch: master
  65. notify:
  66. hipchat:
  67. from: Your_Project
  68. notify: true
  69. room_id_or_name: Your_Room
  70. auth_token: $$HIPCHAT_DRONE_TOKEN
  71. ```

Powered by TurnKey Linux.