config.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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-or-master
  9. tags:
  10. ignore: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
  11. branches:
  12. ignore: master
  13. - &filter-only-master
  14. branches:
  15. only: master
  16. version: 2
  17. jobs:
  18. mysql-integration-test:
  19. docker:
  20. - image: circleci/golang:1.11
  21. - image: circleci/mysql:5.6-ram
  22. environment:
  23. MYSQL_ROOT_PASSWORD: rootpass
  24. MYSQL_DATABASE: grafana_tests
  25. MYSQL_USER: grafana
  26. MYSQL_PASSWORD: password
  27. working_directory: /go/src/github.com/grafana/grafana
  28. steps:
  29. - checkout
  30. - run: sudo apt update
  31. - run: sudo apt install -y mysql-client
  32. - run: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
  33. - run: cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h 127.0.0.1 -P 3306 -u root -prootpass
  34. - run:
  35. name: mysql integration tests
  36. command: 'GRAFANA_TEST_DB=mysql go test ./pkg/services/sqlstore/... ./pkg/tsdb/mysql/... '
  37. postgres-integration-test:
  38. docker:
  39. - image: circleci/golang:1.11
  40. - image: circleci/postgres:9.3-ram
  41. environment:
  42. POSTGRES_USER: grafanatest
  43. POSTGRES_PASSWORD: grafanatest
  44. POSTGRES_DB: grafanatest
  45. working_directory: /go/src/github.com/grafana/grafana
  46. steps:
  47. - checkout
  48. - run: sudo apt update
  49. - run: sudo apt install -y postgresql-client
  50. - run: dockerize -wait tcp://127.0.0.1:5432 -timeout 120s
  51. - run: 'PGPASSWORD=grafanatest psql -p 5432 -h 127.0.0.1 -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql'
  52. - run:
  53. name: postgres integration tests
  54. command: 'GRAFANA_TEST_DB=postgres go test ./pkg/services/sqlstore/... ./pkg/tsdb/postgres/...'
  55. codespell:
  56. docker:
  57. - image: circleci/python
  58. steps:
  59. - checkout
  60. - run:
  61. name: install codespell
  62. command: 'sudo pip install codespell'
  63. - run:
  64. # Important: all words have to be in lowercase, and separated by "\n".
  65. name: exclude known exceptions
  66. command: 'echo -e "unknwon" > words_to_ignore.txt'
  67. - run:
  68. name: check documentation spelling errors
  69. command: 'codespell -I ./words_to_ignore.txt docs/'
  70. gometalinter:
  71. docker:
  72. - image: circleci/golang:1.11
  73. environment:
  74. # we need CGO because of go-sqlite3
  75. CGO_ENABLED: 1
  76. working_directory: /go/src/github.com/grafana/grafana
  77. steps:
  78. - checkout
  79. - run: 'go get -u github.com/alecthomas/gometalinter'
  80. - run: 'go get -u github.com/tsenart/deadcode'
  81. - run: 'go get -u github.com/jgautheron/goconst/cmd/goconst'
  82. - run: 'go get -u github.com/gordonklaus/ineffassign'
  83. - run: 'go get -u github.com/opennota/check/cmd/structcheck'
  84. - run: 'go get -u github.com/mdempsky/unconvert'
  85. - run: 'go get -u github.com/opennota/check/cmd/varcheck'
  86. - run:
  87. name: run linters
  88. command: 'gometalinter --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=goconst --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
  89. - run:
  90. name: run go vet
  91. command: 'go vet ./pkg/...'
  92. test-frontend:
  93. docker:
  94. - image: circleci/node:8
  95. steps:
  96. - checkout
  97. - restore_cache:
  98. key: dependency-cache-{{ checksum "yarn.lock" }}
  99. - run:
  100. name: yarn install
  101. command: 'yarn install --pure-lockfile --no-progress'
  102. no_output_timeout: 15m
  103. - save_cache:
  104. key: dependency-cache-{{ checksum "yarn.lock" }}
  105. paths:
  106. - node_modules
  107. - run:
  108. name: frontend tests
  109. command: './scripts/circle-test-frontend.sh'
  110. test-backend:
  111. docker:
  112. - image: circleci/golang:1.11
  113. working_directory: /go/src/github.com/grafana/grafana
  114. steps:
  115. - checkout
  116. - run:
  117. name: build backend and run go tests
  118. command: './scripts/circle-test-backend.sh'
  119. build-all:
  120. docker:
  121. - image: grafana/build-container:1.2.0
  122. working_directory: /go/src/github.com/grafana/grafana
  123. steps:
  124. - checkout
  125. - run:
  126. name: prepare build tools
  127. command: '/tmp/bootstrap.sh'
  128. - restore_cache:
  129. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  130. - run:
  131. name: download phantomjs binaries
  132. command: './scripts/build/download-phantomjs.sh'
  133. - save_cache:
  134. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  135. paths:
  136. - /tmp/phantomjs
  137. - run:
  138. name: build and package grafana
  139. command: './scripts/build/build-all.sh'
  140. - run:
  141. name: sign packages
  142. command: './scripts/build/sign_packages.sh'
  143. - run:
  144. name: verify signed packages
  145. command: |
  146. mkdir -p ~/.rpmdb/pubkeys
  147. curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
  148. ./scripts/build/verify_signed_packages.sh dist/*.rpm
  149. - run:
  150. name: sha-sum packages
  151. command: 'go run build.go sha-dist'
  152. - run:
  153. name: Build Grafana.com master publisher
  154. command: 'go build -o scripts/publish scripts/build/publish.go'
  155. - run:
  156. name: Build Grafana.com release publisher
  157. command: 'cd scripts/build/release_publisher && go build -o release_publisher .'
  158. - persist_to_workspace:
  159. root: .
  160. paths:
  161. - dist/grafana*
  162. - scripts/*.sh
  163. - scripts/publish
  164. - scripts/build/release_publisher/release_publisher
  165. - scripts/build/publish.sh
  166. build:
  167. docker:
  168. - image: grafana/build-container:1.2.0
  169. working_directory: /go/src/github.com/grafana/grafana
  170. steps:
  171. - checkout
  172. - run:
  173. name: prepare build tools
  174. command: '/tmp/bootstrap.sh'
  175. - run:
  176. name: build and package grafana
  177. command: './scripts/build/build.sh'
  178. - run:
  179. name: sign packages
  180. command: './scripts/build/sign_packages.sh'
  181. - run:
  182. name: sha-sum packages
  183. command: 'go run build.go sha-dist'
  184. - persist_to_workspace:
  185. root: .
  186. paths:
  187. - dist/grafana*
  188. grafana-docker-master:
  189. docker:
  190. - image: docker:stable-git
  191. steps:
  192. - checkout
  193. - attach_workspace:
  194. at: .
  195. - setup_remote_docker
  196. - run: docker info
  197. - run: cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  198. - run: cd packaging/docker && ./build-deploy.sh "master-${CIRCLE_SHA1}"
  199. grafana-docker-pr:
  200. docker:
  201. - image: docker:stable-git
  202. steps:
  203. - checkout
  204. - attach_workspace:
  205. at: .
  206. - setup_remote_docker
  207. - run: docker info
  208. - run: cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  209. - run: cd packaging/docker && ./build.sh "${CIRCLE_SHA1}"
  210. grafana-docker-release:
  211. docker:
  212. - image: docker:stable-git
  213. steps:
  214. - checkout
  215. - attach_workspace:
  216. at: .
  217. - setup_remote_docker
  218. - run: docker info
  219. - run: cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  220. - run: cd packaging/docker && ./build-deploy.sh "${CIRCLE_TAG}"
  221. build-enterprise:
  222. docker:
  223. - image: grafana/build-container:1.2.0
  224. working_directory: /go/src/github.com/grafana/grafana
  225. steps:
  226. - checkout
  227. - run:
  228. name: prepare build tools
  229. command: '/tmp/bootstrap.sh'
  230. - run:
  231. name: checkout enterprise
  232. command: './scripts/build/prepare-enterprise.sh'
  233. - run:
  234. name: test enterprise
  235. command: 'go test ./pkg/extensions/...'
  236. - run:
  237. name: build and package enterprise
  238. command: './scripts/build/build.sh -enterprise'
  239. - run:
  240. name: sign packages
  241. command: './scripts/build/sign_packages.sh'
  242. - run:
  243. name: sha-sum packages
  244. command: 'go run build.go sha-dist'
  245. - run:
  246. name: move enterprise packages into their own folder
  247. command: 'mv dist enterprise-dist'
  248. - persist_to_workspace:
  249. root: .
  250. paths:
  251. - enterprise-dist/grafana-enterprise*
  252. build-all-enterprise:
  253. docker:
  254. - image: grafana/build-container:1.2.0
  255. working_directory: /go/src/github.com/grafana/grafana
  256. steps:
  257. - checkout
  258. - run:
  259. name: prepare build tools
  260. command: '/tmp/bootstrap.sh'
  261. - run:
  262. name: checkout enterprise
  263. command: './scripts/build/prepare-enterprise.sh'
  264. - restore_cache:
  265. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  266. - run:
  267. name: download phantomjs binaries
  268. command: './scripts/build/download-phantomjs.sh'
  269. - save_cache:
  270. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  271. paths:
  272. - /tmp/phantomjs
  273. - run:
  274. name: test enterprise
  275. command: 'go test ./pkg/extensions/...'
  276. - run:
  277. name: build and package grafana
  278. command: './scripts/build/build-all.sh -enterprise'
  279. - run:
  280. name: sign packages
  281. command: './scripts/build/sign_packages.sh'
  282. - run:
  283. name: verify signed packages
  284. command: |
  285. mkdir -p ~/.rpmdb/pubkeys
  286. curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
  287. ./scripts/build/verify_signed_packages.sh dist/*.rpm
  288. - run:
  289. name: sha-sum packages
  290. command: 'go run build.go sha-dist'
  291. - run:
  292. name: move enterprise packages into their own folder
  293. command: 'mv dist enterprise-dist'
  294. - persist_to_workspace:
  295. root: .
  296. paths:
  297. - enterprise-dist/grafana-enterprise*
  298. deploy-enterprise-master:
  299. docker:
  300. - image: circleci/python:2.7-stretch
  301. steps:
  302. - attach_workspace:
  303. at: .
  304. - run:
  305. name: install awscli
  306. command: 'sudo pip install awscli'
  307. - run:
  308. name: deploy to s3
  309. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/master'
  310. deploy-enterprise-release:
  311. docker:
  312. - image: circleci/python:2.7-stretch
  313. steps:
  314. - attach_workspace:
  315. at: .
  316. - run:
  317. name: install awscli
  318. command: 'sudo pip install awscli'
  319. - run:
  320. name: deploy to s3
  321. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/release'
  322. deploy-master:
  323. docker:
  324. - image: circleci/python:2.7-stretch
  325. steps:
  326. - attach_workspace:
  327. at: .
  328. - run:
  329. name: install awscli
  330. command: 'sudo pip install awscli'
  331. - run:
  332. name: deploy to s3
  333. command: |
  334. # Also
  335. cp dist/grafana-latest.linux-x64.tar.gz dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  336. aws s3 sync ./dist s3://$BUCKET_NAME/master
  337. - run:
  338. name: Trigger Windows build
  339. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  340. - run:
  341. name: Publish to Grafana.com
  342. command: |
  343. rm dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  344. ./scripts/publish -apiKey ${GRAFANA_COM_API_KEY}
  345. deploy-release:
  346. docker:
  347. - image: circleci/python:2.7-stretch
  348. steps:
  349. - attach_workspace:
  350. at: .
  351. - run:
  352. name: install awscli
  353. command: 'sudo pip install awscli'
  354. - run:
  355. name: deploy to s3
  356. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  357. - run:
  358. name: Deploy to Grafana.com
  359. command: './scripts/build/publish.sh'
  360. workflows:
  361. version: 2
  362. build-master:
  363. jobs:
  364. - build-all:
  365. filters: *filter-only-master
  366. - build-all-enterprise:
  367. filters: *filter-only-master
  368. - codespell:
  369. filters: *filter-only-master
  370. - gometalinter:
  371. filters: *filter-only-master
  372. - test-frontend:
  373. filters: *filter-only-master
  374. - test-backend:
  375. filters: *filter-only-master
  376. - mysql-integration-test:
  377. filters: *filter-only-master
  378. - postgres-integration-test:
  379. filters: *filter-only-master
  380. - deploy-master:
  381. requires:
  382. - build-all
  383. - test-backend
  384. - test-frontend
  385. - codespell
  386. - gometalinter
  387. - mysql-integration-test
  388. - postgres-integration-test
  389. filters: *filter-only-master
  390. - grafana-docker-master:
  391. requires:
  392. - build-all
  393. - test-backend
  394. - test-frontend
  395. - codespell
  396. - gometalinter
  397. - mysql-integration-test
  398. - postgres-integration-test
  399. filters: *filter-only-master
  400. - deploy-enterprise-master:
  401. requires:
  402. - build-all
  403. - test-backend
  404. - test-frontend
  405. - codespell
  406. - gometalinter
  407. - mysql-integration-test
  408. - postgres-integration-test
  409. - build-all-enterprise
  410. filters: *filter-only-master
  411. release:
  412. jobs:
  413. - build-all:
  414. filters: *filter-only-release
  415. - build-all-enterprise:
  416. filters: *filter-only-release
  417. - codespell:
  418. filters: *filter-only-release
  419. - gometalinter:
  420. filters: *filter-only-release
  421. - test-frontend:
  422. filters: *filter-only-release
  423. - test-backend:
  424. filters: *filter-only-release
  425. - mysql-integration-test:
  426. filters: *filter-only-release
  427. - postgres-integration-test:
  428. filters: *filter-only-release
  429. - deploy-release:
  430. requires:
  431. - build-all
  432. - test-backend
  433. - test-frontend
  434. - codespell
  435. - gometalinter
  436. - mysql-integration-test
  437. - postgres-integration-test
  438. filters: *filter-only-release
  439. - deploy-enterprise-release:
  440. requires:
  441. - build-all
  442. - build-all-enterprise
  443. - test-backend
  444. - test-frontend
  445. - codespell
  446. - gometalinter
  447. - mysql-integration-test
  448. - postgres-integration-test
  449. filters: *filter-only-release
  450. - grafana-docker-release:
  451. requires:
  452. - build-all
  453. - test-backend
  454. - test-frontend
  455. - codespell
  456. - gometalinter
  457. - mysql-integration-test
  458. - postgres-integration-test
  459. filters: *filter-only-release
  460. build-branches-and-prs:
  461. jobs:
  462. - build:
  463. filters: *filter-not-release-or-master
  464. - codespell:
  465. filters: *filter-not-release-or-master
  466. - gometalinter:
  467. filters: *filter-not-release-or-master
  468. - test-frontend:
  469. filters: *filter-not-release-or-master
  470. - test-backend:
  471. filters: *filter-not-release-or-master
  472. - mysql-integration-test:
  473. filters: *filter-not-release-or-master
  474. - postgres-integration-test:
  475. filters: *filter-not-release-or-master
  476. - grafana-docker-pr:
  477. requires:
  478. - build
  479. - test-backend
  480. - test-frontend
  481. - codespell
  482. - gometalinter
  483. - mysql-integration-test
  484. - postgres-integration-test
  485. filters: *filter-not-release-or-master