config.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. version: 2
  2. jobs:
  3. codespell:
  4. docker:
  5. - image: circleci/python
  6. steps:
  7. - checkout
  8. - run:
  9. name: install codespell
  10. command: 'sudo pip install codespell'
  11. - run:
  12. # Important: all words have to be in lowercase, and separated by "\n".
  13. name: exclude known exceptions
  14. command: 'echo -e "unknwon" > words_to_ignore.txt'
  15. - run:
  16. name: check documentation spelling errors
  17. command: 'codespell -I ./words_to_ignore.txt docs/'
  18. gometalinter:
  19. docker:
  20. - image: circleci/golang:1.10
  21. environment:
  22. # we need CGO because of go-sqlite3
  23. CGO_ENABLED: 1
  24. working_directory: /go/src/github.com/grafana/grafana
  25. steps:
  26. - checkout
  27. - run: 'go get -u gopkg.in/alecthomas/gometalinter.v2'
  28. - run: 'go get -u github.com/tsenart/deadcode'
  29. - run: 'go get -u github.com/gordonklaus/ineffassign'
  30. - run: 'go get -u github.com/opennota/check/cmd/structcheck'
  31. - run: 'go get -u github.com/mdempsky/unconvert'
  32. - run: 'go get -u github.com/opennota/check/cmd/varcheck'
  33. - run:
  34. name: run linters
  35. command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
  36. test-frontend:
  37. docker:
  38. - image: circleci/node:6.11.4
  39. steps:
  40. - checkout
  41. - run:
  42. name: install yarn
  43. command: 'sudo npm install -g yarn --quiet'
  44. - restore_cache:
  45. key: dependency-cache-{{ checksum "yarn.lock" }}
  46. # Could we skip this step if the cache has been restored? `[ -d node_modules ] || yarn install ...` should be able to apply to build step as well
  47. - run:
  48. name: yarn install
  49. command: 'yarn install --pure-lockfile --no-progress'
  50. - save_cache:
  51. key: dependency-cache-{{ checksum "yarn.lock" }}
  52. paths:
  53. - node_modules
  54. - run:
  55. name: frontend tests
  56. command: './scripts/circle-test-frontend.sh'
  57. test-backend:
  58. docker:
  59. - image: circleci/golang:1.10
  60. working_directory: /go/src/github.com/grafana/grafana
  61. steps:
  62. - checkout
  63. - run:
  64. name: build backend and run go tests
  65. command: './scripts/circle-test-backend.sh'
  66. build:
  67. docker:
  68. - image: grafana/build-container:crosscompile
  69. working_directory: /go/src/github.com/grafana/grafana
  70. steps:
  71. - checkout
  72. - run:
  73. name: prepare build tools
  74. command: '/tmp/bootstrap.sh'
  75. - run:
  76. name: build and package grafana
  77. command: './scripts/build/build.sh'
  78. - run:
  79. name: sign packages
  80. command: './scripts/build/sign_packages.sh'
  81. - run:
  82. name: sha-sum packages
  83. command: 'go run build.go sha-dist'
  84. - run:
  85. name: Build Grafana.com publisher
  86. command: 'go build -o scripts/publish scripts/build/publish.go'
  87. - persist_to_workspace:
  88. root: .
  89. paths:
  90. - dist/grafana*
  91. - scripts/*.sh
  92. - scripts/publish
  93. build-enterprise:
  94. docker:
  95. - image: grafana/build-container:v0.1
  96. working_directory: /go/src/github.com/grafana/grafana
  97. steps:
  98. - checkout
  99. - run:
  100. name: build and package grafana
  101. command: './scripts/build/build_enterprise.sh'
  102. - run:
  103. name: sign packages
  104. command: './scripts/build/sign_packages.sh'
  105. - run:
  106. name: sha-sum packages
  107. command: 'go run build.go sha-dist'
  108. deploy-master:
  109. docker:
  110. - image: circleci/python:2.7-stretch
  111. steps:
  112. - attach_workspace:
  113. at: .
  114. - run:
  115. name: install awscli
  116. command: 'sudo pip install awscli'
  117. - run:
  118. name: deploy to s3
  119. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/master'
  120. - run:
  121. name: Trigger Windows build
  122. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  123. - run:
  124. name: Trigger Docker build
  125. command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN}'
  126. - run:
  127. name: Publish to Grafana.com
  128. command: './scripts/publish -apiKey ${GRAFANA_COM_API_KEY}'
  129. deploy-release:
  130. docker:
  131. - image: circleci/python:2.7-stretch
  132. steps:
  133. - attach_workspace:
  134. at: .
  135. - run:
  136. name: install awscli
  137. command: 'sudo pip install awscli'
  138. - run:
  139. name: deploy to s3
  140. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  141. - run:
  142. name: Trigger Windows build
  143. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} release'
  144. - run:
  145. name: Trigger Docker build
  146. command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} ${CIRCLE_TAG}'
  147. workflows:
  148. version: 2
  149. test-and-build:
  150. jobs:
  151. - codespell:
  152. filters:
  153. tags:
  154. only: /.*/
  155. - gometalinter:
  156. filters:
  157. tags:
  158. only: /.*/
  159. - build:
  160. filters:
  161. tags:
  162. only: /.*/
  163. - test-frontend:
  164. filters:
  165. tags:
  166. only: /.*/
  167. - test-backend:
  168. filters:
  169. tags:
  170. only: /.*/
  171. - deploy-master:
  172. requires:
  173. - test-backend
  174. - test-frontend
  175. - build
  176. filters:
  177. branches:
  178. only: master
  179. - deploy-release:
  180. requires:
  181. - test-backend
  182. - test-frontend
  183. - build
  184. filters:
  185. branches:
  186. ignore: /.*/
  187. tags:
  188. only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
  189. # - build-enterprise:
  190. # filters:
  191. # tags:
  192. # only: /.*/