config.yml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. aliases:
  2. # Workflow filters
  3. - &filter-only-release
  4. branches:
  5. ignore: /.*/
  6. tags:
  7. only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
  8. - &filter-not-release
  9. tags:
  10. ignore: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
  11. version: 2
  12. jobs:
  13. mysql-integration-test:
  14. docker:
  15. - image: circleci/golang:1.10
  16. - image: circleci/mysql:5.6-ram
  17. environment:
  18. MYSQL_ROOT_PASSWORD: rootpass
  19. MYSQL_DATABASE: grafana_tests
  20. MYSQL_USER: grafana
  21. MYSQL_PASSWORD: password
  22. working_directory: /go/src/github.com/grafana/grafana
  23. steps:
  24. - checkout
  25. - run: sudo apt update
  26. - run: sudo apt install -y mysql-client
  27. - run: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
  28. - run: cat docker/blocks/mysql_tests/setup.sql | mysql -h 127.0.0.1 -P 3306 -u root -prootpass
  29. - run:
  30. name: mysql integration tests
  31. command: 'GRAFANA_TEST_DB=mysql go test ./pkg/services/sqlstore/... ./pkg/tsdb/mysql/... '
  32. postgres-integration-test:
  33. docker:
  34. - image: circleci/golang:1.10
  35. - image: circleci/postgres:9.3-ram
  36. environment:
  37. POSTGRES_USER: grafanatest
  38. POSTGRES_PASSWORD: grafanatest
  39. POSTGRES_DB: grafanatest
  40. working_directory: /go/src/github.com/grafana/grafana
  41. steps:
  42. - checkout
  43. - run: sudo apt update
  44. - run: sudo apt install -y postgresql-client
  45. - run: dockerize -wait tcp://127.0.0.1:5432 -timeout 120s
  46. - run: 'PGPASSWORD=grafanatest psql -p 5432 -h 127.0.0.1 -U grafanatest -d grafanatest -f docker/blocks/postgres_tests/setup.sql'
  47. - run:
  48. name: postgres integration tests
  49. command: 'GRAFANA_TEST_DB=postgres go test ./pkg/services/sqlstore/... ./pkg/tsdb/postgres/...'
  50. codespell:
  51. docker:
  52. - image: circleci/python
  53. steps:
  54. - checkout
  55. - run:
  56. name: install codespell
  57. command: 'sudo pip install codespell'
  58. - run:
  59. # Important: all words have to be in lowercase, and separated by "\n".
  60. name: exclude known exceptions
  61. command: 'echo -e "unknwon" > words_to_ignore.txt'
  62. - run:
  63. name: check documentation spelling errors
  64. command: 'codespell -I ./words_to_ignore.txt docs/'
  65. gometalinter:
  66. docker:
  67. - image: circleci/golang:1.10
  68. environment:
  69. # we need CGO because of go-sqlite3
  70. CGO_ENABLED: 1
  71. working_directory: /go/src/github.com/grafana/grafana
  72. steps:
  73. - checkout
  74. - run: 'go get -u gopkg.in/alecthomas/gometalinter.v2'
  75. - run: 'go get -u github.com/tsenart/deadcode'
  76. - run: 'go get -u github.com/gordonklaus/ineffassign'
  77. - run: 'go get -u github.com/opennota/check/cmd/structcheck'
  78. - run: 'go get -u github.com/mdempsky/unconvert'
  79. - run: 'go get -u github.com/opennota/check/cmd/varcheck'
  80. - run:
  81. name: run linters
  82. command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
  83. test-frontend:
  84. docker:
  85. - image: circleci/node:8
  86. steps:
  87. - checkout
  88. - run:
  89. name: install yarn
  90. command: 'sudo npm install -g yarn --quiet'
  91. - restore_cache:
  92. key: dependency-cache-{{ checksum "yarn.lock" }}
  93. - run:
  94. name: yarn install
  95. command: 'yarn install --pure-lockfile --no-progress'
  96. - save_cache:
  97. key: dependency-cache-{{ checksum "yarn.lock" }}
  98. paths:
  99. - node_modules
  100. - run:
  101. name: frontend tests
  102. command: './scripts/circle-test-frontend.sh'
  103. test-backend:
  104. docker:
  105. - image: circleci/golang:1.10
  106. working_directory: /go/src/github.com/grafana/grafana
  107. steps:
  108. - checkout
  109. - run:
  110. name: build backend and run go tests
  111. command: './scripts/circle-test-backend.sh'
  112. build-all:
  113. docker:
  114. - image: grafana/build-container:1.0.0
  115. working_directory: /go/src/github.com/grafana/grafana
  116. steps:
  117. - checkout
  118. - run:
  119. name: prepare build tools
  120. command: '/tmp/bootstrap.sh'
  121. - restore_cache:
  122. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  123. - run:
  124. name: download phantomjs binaries
  125. command: './scripts/build/download-phantomjs.sh'
  126. - save_cache:
  127. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  128. paths:
  129. - /tmp/phantomjs
  130. - run:
  131. name: build and package grafana
  132. command: './scripts/build/build-all.sh'
  133. - run:
  134. name: sign packages
  135. command: './scripts/build/sign_packages.sh'
  136. - run:
  137. name: sha-sum packages
  138. command: 'go run build.go sha-dist'
  139. - run:
  140. name: Build Grafana.com publisher
  141. command: 'go build -o scripts/publish scripts/build/publish.go'
  142. - persist_to_workspace:
  143. root: .
  144. paths:
  145. - dist/grafana*
  146. - scripts/*.sh
  147. - scripts/publish
  148. - store_artifacts:
  149. path: dist
  150. build-enterprise:
  151. docker:
  152. - image: grafana/build-container:v0.1
  153. working_directory: /go/src/github.com/grafana/grafana
  154. steps:
  155. - checkout
  156. - run:
  157. name: build and package grafana
  158. command: './scripts/build/build_enterprise.sh'
  159. - run:
  160. name: sign packages
  161. command: './scripts/build/sign_packages.sh'
  162. - run:
  163. name: sha-sum packages
  164. command: 'go run build.go sha-dist'
  165. deploy-master:
  166. docker:
  167. - image: circleci/python:2.7-stretch
  168. steps:
  169. - attach_workspace:
  170. at: .
  171. - run:
  172. name: install awscli
  173. command: 'sudo pip install awscli'
  174. - run:
  175. name: deploy to s3
  176. command: |
  177. # Also
  178. cp dist/grafana-latest.linux-x64.tar.gz dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  179. aws s3 sync ./dist s3://$BUCKET_NAME/master
  180. - run:
  181. name: Trigger Windows build
  182. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  183. - run:
  184. name: Trigger Docker build
  185. command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} master-$(echo "${CIRCLE_SHA1}" | cut -b1-7)'
  186. - run:
  187. name: Publish to Grafana.com
  188. command: |
  189. rm dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  190. ./scripts/publish -apiKey ${GRAFANA_COM_API_KEY}
  191. deploy-release:
  192. docker:
  193. - image: circleci/python:2.7-stretch
  194. steps:
  195. - attach_workspace:
  196. at: .
  197. - run:
  198. name: install awscli
  199. command: 'sudo pip install awscli'
  200. - run:
  201. name: deploy to s3
  202. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  203. - run:
  204. name: Trigger Windows build
  205. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} release'
  206. - run:
  207. name: Trigger Docker build
  208. command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} ${CIRCLE_TAG}'
  209. workflows:
  210. version: 2
  211. test-and-build:
  212. jobs:
  213. - build-all:
  214. filters: *filter-not-release
  215. - codespell:
  216. filters: *filter-not-release
  217. - gometalinter:
  218. filters: *filter-not-release
  219. - test-frontend:
  220. filters: *filter-not-release
  221. - test-backend:
  222. filters: *filter-not-release
  223. - mysql-integration-test:
  224. filters: *filter-not-release
  225. - postgres-integration-test:
  226. filters: *filter-not-release
  227. - deploy-master:
  228. requires:
  229. - build-all
  230. - test-backend
  231. - test-frontend
  232. - codespell
  233. - gometalinter
  234. - mysql-integration-test
  235. - postgres-integration-test
  236. filters:
  237. branches:
  238. only: master
  239. release:
  240. jobs:
  241. - build-all:
  242. filters: *filter-only-release
  243. - codespell:
  244. filters: *filter-only-release
  245. - gometalinter:
  246. filters: *filter-only-release
  247. - test-frontend:
  248. filters: *filter-only-release
  249. - test-backend:
  250. filters: *filter-only-release
  251. - mysql-integration-test:
  252. filters: *filter-only-release
  253. - postgres-integration-test:
  254. filters: *filter-only-release
  255. - deploy-release:
  256. requires:
  257. - build-all
  258. - test-backend
  259. - test-frontend
  260. - codespell
  261. - gometalinter
  262. - mysql-integration-test
  263. - postgres-integration-test
  264. filters: *filter-only-release