config.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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. - run: rm packaging/docker/grafana-latest.linux-x64.tar.gz
  200. - run: cp enterprise-dist/grafana-enterprise-*.linux-amd64.tar.gz packaging/docker/grafana-latest.linux-x64.tar.gz
  201. - run: cd packaging/docker && ./build-enterprise.sh "master"
  202. grafana-docker-pr:
  203. docker:
  204. - image: docker:stable-git
  205. steps:
  206. - checkout
  207. - attach_workspace:
  208. at: .
  209. - setup_remote_docker
  210. - run: docker info
  211. - run: cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  212. - run: cd packaging/docker && ./build.sh "${CIRCLE_SHA1}"
  213. grafana-docker-release:
  214. docker:
  215. - image: docker:stable-git
  216. steps:
  217. - checkout
  218. - attach_workspace:
  219. at: .
  220. - setup_remote_docker
  221. - run: docker info
  222. - run: cp dist/grafana-latest.linux-x64.tar.gz packaging/docker
  223. - run: cd packaging/docker && ./build-deploy.sh "${CIRCLE_TAG}"
  224. - run: rm packaging/docker/grafana-latest.linux-x64.tar.gz
  225. - run: cp enterprise-dist/grafana-enterprise-*.linux-amd64.tar.gz packaging/docker/grafana-latest.linux-x64.tar.gz
  226. - run: cd packaging/docker && ./build-enterprise.sh "${CIRCLE_TAG}"
  227. build-enterprise:
  228. docker:
  229. - image: grafana/build-container:1.2.0
  230. working_directory: /go/src/github.com/grafana/grafana
  231. steps:
  232. - checkout
  233. - run:
  234. name: prepare build tools
  235. command: '/tmp/bootstrap.sh'
  236. - run:
  237. name: checkout enterprise
  238. command: './scripts/build/prepare-enterprise.sh'
  239. - run:
  240. name: test enterprise
  241. command: 'go test ./pkg/extensions/...'
  242. - run:
  243. name: build and package enterprise
  244. command: './scripts/build/build.sh -enterprise'
  245. - run:
  246. name: sign packages
  247. command: './scripts/build/sign_packages.sh'
  248. - run:
  249. name: sha-sum packages
  250. command: 'go run build.go sha-dist'
  251. - run:
  252. name: move enterprise packages into their own folder
  253. command: 'mv dist enterprise-dist'
  254. - persist_to_workspace:
  255. root: .
  256. paths:
  257. - enterprise-dist/grafana-enterprise*
  258. build-all-enterprise:
  259. docker:
  260. - image: grafana/build-container:1.2.0
  261. working_directory: /go/src/github.com/grafana/grafana
  262. steps:
  263. - checkout
  264. - run:
  265. name: prepare build tools
  266. command: '/tmp/bootstrap.sh'
  267. - run:
  268. name: checkout enterprise
  269. command: './scripts/build/prepare-enterprise.sh'
  270. - restore_cache:
  271. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  272. - run:
  273. name: download phantomjs binaries
  274. command: './scripts/build/download-phantomjs.sh'
  275. - save_cache:
  276. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  277. paths:
  278. - /tmp/phantomjs
  279. - run:
  280. name: test enterprise
  281. command: 'go test ./pkg/extensions/...'
  282. - run:
  283. name: build and package grafana
  284. command: './scripts/build/build-all.sh -enterprise'
  285. - run:
  286. name: sign packages
  287. command: './scripts/build/sign_packages.sh'
  288. - run:
  289. name: verify signed packages
  290. command: |
  291. mkdir -p ~/.rpmdb/pubkeys
  292. curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
  293. ./scripts/build/verify_signed_packages.sh dist/*.rpm
  294. - run:
  295. name: sha-sum packages
  296. command: 'go run build.go sha-dist'
  297. - run:
  298. name: move enterprise packages into their own folder
  299. command: 'mv dist enterprise-dist'
  300. - persist_to_workspace:
  301. root: .
  302. paths:
  303. - enterprise-dist/grafana-enterprise*
  304. deploy-enterprise-master:
  305. docker:
  306. - image: circleci/python:2.7-stretch
  307. steps:
  308. - attach_workspace:
  309. at: .
  310. - run:
  311. name: install awscli
  312. command: 'sudo pip install awscli'
  313. - run:
  314. name: deploy to s3
  315. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/master'
  316. deploy-enterprise-release:
  317. docker:
  318. - image: circleci/python:2.7-stretch
  319. steps:
  320. - attach_workspace:
  321. at: .
  322. - run:
  323. name: install awscli
  324. command: 'sudo pip install awscli'
  325. - run:
  326. name: deploy to s3
  327. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/release'
  328. deploy-master:
  329. docker:
  330. - image: circleci/python:2.7-stretch
  331. steps:
  332. - attach_workspace:
  333. at: .
  334. - run:
  335. name: install awscli
  336. command: 'sudo pip install awscli'
  337. - run:
  338. name: deploy to s3
  339. command: |
  340. # Also
  341. cp dist/grafana-latest.linux-x64.tar.gz dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  342. aws s3 sync ./dist s3://$BUCKET_NAME/master
  343. - run:
  344. name: Trigger Windows build
  345. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  346. - run:
  347. name: Publish to Grafana.com
  348. command: |
  349. rm dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  350. ./scripts/publish -apiKey ${GRAFANA_COM_API_KEY}
  351. deploy-release:
  352. docker:
  353. - image: circleci/python:2.7-stretch
  354. steps:
  355. - attach_workspace:
  356. at: .
  357. - run:
  358. name: install awscli
  359. command: 'sudo pip install awscli'
  360. - run:
  361. name: deploy to s3
  362. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  363. - run:
  364. name: Deploy to Grafana.com
  365. command: './scripts/build/publish.sh'
  366. workflows:
  367. version: 2
  368. build-master:
  369. jobs:
  370. - build-all:
  371. filters: *filter-only-master
  372. - build-all-enterprise:
  373. filters: *filter-only-master
  374. - codespell:
  375. filters: *filter-only-master
  376. - gometalinter:
  377. filters: *filter-only-master
  378. - test-frontend:
  379. filters: *filter-only-master
  380. - test-backend:
  381. filters: *filter-only-master
  382. - mysql-integration-test:
  383. filters: *filter-only-master
  384. - postgres-integration-test:
  385. filters: *filter-only-master
  386. - deploy-master:
  387. requires:
  388. - build-all
  389. - test-backend
  390. - test-frontend
  391. - codespell
  392. - gometalinter
  393. - mysql-integration-test
  394. - postgres-integration-test
  395. filters: *filter-only-master
  396. - grafana-docker-master:
  397. requires:
  398. - build-all
  399. - build-all-enterprise
  400. - test-backend
  401. - test-frontend
  402. - codespell
  403. - gometalinter
  404. - mysql-integration-test
  405. - postgres-integration-test
  406. filters: *filter-only-master
  407. - deploy-enterprise-master:
  408. requires:
  409. - build-all
  410. - test-backend
  411. - test-frontend
  412. - codespell
  413. - gometalinter
  414. - mysql-integration-test
  415. - postgres-integration-test
  416. - build-all-enterprise
  417. filters: *filter-only-master
  418. release:
  419. jobs:
  420. - build-all:
  421. filters: *filter-only-release
  422. - build-all-enterprise:
  423. filters: *filter-only-release
  424. - codespell:
  425. filters: *filter-only-release
  426. - gometalinter:
  427. filters: *filter-only-release
  428. - test-frontend:
  429. filters: *filter-only-release
  430. - test-backend:
  431. filters: *filter-only-release
  432. - mysql-integration-test:
  433. filters: *filter-only-release
  434. - postgres-integration-test:
  435. filters: *filter-only-release
  436. - deploy-release:
  437. requires:
  438. - build-all
  439. - test-backend
  440. - test-frontend
  441. - codespell
  442. - gometalinter
  443. - mysql-integration-test
  444. - postgres-integration-test
  445. filters: *filter-only-release
  446. - deploy-enterprise-release:
  447. requires:
  448. - build-all
  449. - build-all-enterprise
  450. - test-backend
  451. - test-frontend
  452. - codespell
  453. - gometalinter
  454. - mysql-integration-test
  455. - postgres-integration-test
  456. filters: *filter-only-release
  457. - grafana-docker-release:
  458. requires:
  459. - build-all
  460. - test-backend
  461. - test-frontend
  462. - codespell
  463. - gometalinter
  464. - mysql-integration-test
  465. - postgres-integration-test
  466. filters: *filter-only-release
  467. build-branches-and-prs:
  468. jobs:
  469. - build:
  470. filters: *filter-not-release-or-master
  471. - codespell:
  472. filters: *filter-not-release-or-master
  473. - gometalinter:
  474. filters: *filter-not-release-or-master
  475. - test-frontend:
  476. filters: *filter-not-release-or-master
  477. - test-backend:
  478. filters: *filter-not-release-or-master
  479. - mysql-integration-test:
  480. filters: *filter-not-release-or-master
  481. - postgres-integration-test:
  482. filters: *filter-not-release-or-master
  483. - grafana-docker-pr:
  484. requires:
  485. - build
  486. - test-backend
  487. - test-frontend
  488. - codespell
  489. - gometalinter
  490. - mysql-integration-test
  491. - postgres-integration-test
  492. filters: *filter-not-release-or-master