config.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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.12.3
  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: './scripts/circle-test-mysql.sh'
  37. postgres-integration-test:
  38. docker:
  39. - image: circleci/golang:1.12.3
  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: './scripts/circle-test-postgres.sh'
  55. cache-server-test:
  56. docker:
  57. - image: circleci/golang:1.12.3
  58. - image: circleci/redis:4-alpine
  59. - image: memcached
  60. working_directory: /go/src/github.com/grafana/grafana
  61. steps:
  62. - checkout
  63. - run: dockerize -wait tcp://127.0.0.1:11211 -timeout 120s
  64. - run: dockerize -wait tcp://127.0.0.1:6379 -timeout 120s
  65. - run:
  66. name: cache server tests
  67. command: './scripts/circle-test-cache-servers.sh'
  68. codespell:
  69. docker:
  70. - image: circleci/python
  71. steps:
  72. - checkout
  73. - run:
  74. name: install codespell
  75. command: 'sudo pip install codespell'
  76. - run:
  77. # Important: all words have to be in lowercase, and separated by "\n".
  78. name: exclude known exceptions
  79. command: 'echo -e "unknwon" > words_to_ignore.txt'
  80. - run:
  81. name: check documentation spelling errors
  82. command: 'codespell -I ./words_to_ignore.txt docs/'
  83. backend-lint:
  84. docker:
  85. - image: circleci/golang:1.12.3
  86. environment:
  87. # we need CGO because of go-sqlite3
  88. CGO_ENABLED: 1
  89. working_directory: /go/src/github.com/grafana/grafana
  90. steps:
  91. - checkout
  92. - run:
  93. name: backend lint
  94. command: './scripts/backend-lint.sh'
  95. test-frontend:
  96. docker:
  97. - image: circleci/node:8
  98. steps:
  99. - checkout
  100. - restore_cache:
  101. key: dependency-cache-{{ checksum "yarn.lock" }}
  102. - run:
  103. name: yarn install
  104. command: 'yarn install --pure-lockfile --no-progress'
  105. no_output_timeout: 15m
  106. - save_cache:
  107. key: dependency-cache-{{ checksum "yarn.lock" }}
  108. paths:
  109. - node_modules
  110. - run:
  111. name: frontend tests
  112. command: './scripts/circle-test-frontend.sh'
  113. test-backend:
  114. docker:
  115. - image: circleci/golang:1.12.3
  116. working_directory: /go/src/github.com/grafana/grafana
  117. steps:
  118. - checkout
  119. - run:
  120. name: build backend and run go tests
  121. command: './scripts/circle-test-backend.sh'
  122. build-all:
  123. docker:
  124. - image: grafana/build-container:1.2.5
  125. working_directory: /go/src/github.com/grafana/grafana
  126. steps:
  127. - checkout
  128. - run:
  129. name: prepare build tools
  130. command: '/tmp/bootstrap.sh'
  131. - restore_cache:
  132. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  133. - run:
  134. name: download phantomjs binaries
  135. command: './scripts/build/download-phantomjs.sh'
  136. - save_cache:
  137. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  138. paths:
  139. - /tmp/phantomjs
  140. - run:
  141. name: build and package grafana
  142. command: './scripts/build/build-all.sh'
  143. - run:
  144. name: sign packages
  145. command: './scripts/build/sign_packages.sh'
  146. - run:
  147. name: verify signed packages
  148. command: |
  149. mkdir -p ~/.rpmdb/pubkeys
  150. curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
  151. ./scripts/build/verify_signed_packages.sh dist/*.rpm
  152. - run:
  153. name: sha-sum packages
  154. command: 'go run build.go sha-dist'
  155. - run:
  156. name: Test and build Grafana.com release publisher
  157. command: 'cd scripts/build/release_publisher && go test . && go build -o release_publisher .'
  158. - persist_to_workspace:
  159. root: .
  160. paths:
  161. - dist/*
  162. - scripts/*.sh
  163. - scripts/build/release_publisher/release_publisher
  164. - scripts/build/publish.sh
  165. build:
  166. docker:
  167. - image: grafana/build-container:1.2.5
  168. working_directory: /go/src/github.com/grafana/grafana
  169. steps:
  170. - checkout
  171. - run:
  172. name: prepare build tools
  173. command: '/tmp/bootstrap.sh'
  174. - run:
  175. name: build and package grafana
  176. command: './scripts/build/build.sh'
  177. - run:
  178. name: sign packages
  179. command: './scripts/build/sign_packages.sh'
  180. - run:
  181. name: sha-sum packages
  182. command: 'go run build.go sha-dist'
  183. - run:
  184. name: Test Grafana.com release publisher
  185. command: 'cd scripts/build/release_publisher && go test .'
  186. - persist_to_workspace:
  187. root: .
  188. paths:
  189. - dist/*
  190. grafana-docker-master:
  191. machine:
  192. image: circleci/classic:201808-01
  193. steps:
  194. - checkout
  195. - attach_workspace:
  196. at: .
  197. - run: docker info
  198. - run: docker run --privileged linuxkit/binfmt:v0.6
  199. - run: cp dist/grafana-latest.linux-*.tar.gz packaging/docker
  200. - run: cd packaging/docker && ./build-deploy.sh "master-${CIRCLE_SHA1}"
  201. - run: rm packaging/docker/grafana-latest.linux-*.tar.gz
  202. - run: cp enterprise-dist/grafana-enterprise-*.linux-amd64.tar.gz packaging/docker/grafana-latest.linux-x64.tar.gz
  203. - run: cd packaging/docker && ./build-enterprise.sh "master"
  204. grafana-docker-pr:
  205. machine:
  206. image: circleci/classic:201808-01
  207. steps:
  208. - checkout
  209. - attach_workspace:
  210. at: .
  211. - run: docker info
  212. - run: docker run --privileged linuxkit/binfmt:v0.6
  213. - run: cp dist/grafana-latest.linux-*.tar.gz packaging/docker
  214. - run: cd packaging/docker && ./build.sh "${CIRCLE_SHA1}"
  215. grafana-docker-release:
  216. machine:
  217. image: circleci/classic:201808-01
  218. steps:
  219. - checkout
  220. - attach_workspace:
  221. at: .
  222. - run: docker info
  223. - run: docker run --privileged linuxkit/binfmt:v0.6
  224. - run: cp dist/grafana-latest.linux-*.tar.gz packaging/docker
  225. - run: cd packaging/docker && ./build-deploy.sh "${CIRCLE_TAG}"
  226. - run: rm packaging/docker/grafana-latest.linux-*.tar.gz
  227. - run: cp enterprise-dist/grafana-enterprise-*.linux-amd64.tar.gz packaging/docker/grafana-latest.linux-x64.tar.gz
  228. - run: cd packaging/docker && ./build-enterprise.sh "${CIRCLE_TAG}"
  229. build-enterprise:
  230. docker:
  231. - image: grafana/build-container:1.2.5
  232. working_directory: /go/src/github.com/grafana/grafana
  233. steps:
  234. - checkout
  235. - run:
  236. name: prepare build tools
  237. command: '/tmp/bootstrap.sh'
  238. - run:
  239. name: checkout enterprise
  240. command: './scripts/build/prepare-enterprise.sh'
  241. - run:
  242. name: test enterprise
  243. command: 'go test ./pkg/extensions/...'
  244. - run:
  245. name: build and package enterprise
  246. command: './scripts/build/build.sh -enterprise'
  247. - run:
  248. name: sign packages
  249. command: './scripts/build/sign_packages.sh'
  250. - run:
  251. name: sha-sum packages
  252. command: 'go run build.go sha-dist'
  253. - run:
  254. name: move enterprise packages into their own folder
  255. command: 'mv dist enterprise-dist'
  256. - persist_to_workspace:
  257. root: .
  258. paths:
  259. - enterprise-dist/*
  260. build-all-enterprise:
  261. docker:
  262. - image: grafana/build-container:1.2.5
  263. working_directory: /go/src/github.com/grafana/grafana
  264. steps:
  265. - checkout
  266. - run:
  267. name: prepare build tools
  268. command: '/tmp/bootstrap.sh'
  269. - run:
  270. name: checkout enterprise
  271. command: './scripts/build/prepare-enterprise.sh'
  272. - restore_cache:
  273. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  274. - run:
  275. name: download phantomjs binaries
  276. command: './scripts/build/download-phantomjs.sh'
  277. - save_cache:
  278. key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
  279. paths:
  280. - /tmp/phantomjs
  281. - run:
  282. name: test enterprise
  283. command: 'go test ./pkg/extensions/...'
  284. - run:
  285. name: build and package grafana
  286. command: './scripts/build/build-all.sh -enterprise'
  287. - run:
  288. name: sign packages
  289. command: './scripts/build/sign_packages.sh'
  290. - run:
  291. name: verify signed packages
  292. command: |
  293. mkdir -p ~/.rpmdb/pubkeys
  294. curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
  295. ./scripts/build/verify_signed_packages.sh dist/*.rpm
  296. - run:
  297. name: sha-sum packages
  298. command: 'go run build.go sha-dist'
  299. - run:
  300. name: move enterprise packages into their own folder
  301. command: 'mv dist enterprise-dist'
  302. - persist_to_workspace:
  303. root: .
  304. paths:
  305. - enterprise-dist/*
  306. deploy-enterprise-master:
  307. docker:
  308. - image: grafana/grafana-ci-deploy:1.2.2
  309. steps:
  310. - attach_workspace:
  311. at: .
  312. - run:
  313. name: gcp credentials
  314. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  315. - run:
  316. name: sign in to gcp
  317. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  318. - run:
  319. name: deploy to s3
  320. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/master'
  321. - run:
  322. name: deploy to gcp
  323. command: '/opt/google-cloud-sdk/bin/gsutil cp ./enterprise-dist/* gs://$GCP_BUCKET_NAME/enterprise/master'
  324. - run:
  325. name: Deploy to grafana.com
  326. command: |
  327. cd enterprise-dist
  328. ../scripts/build/release_publisher/release_publisher -apikey ${GRAFANA_COM_API_KEY} -enterprise -version "v$(cat grafana.version)" --nightly
  329. deploy-enterprise-release:
  330. docker:
  331. - image: grafana/grafana-ci-deploy:1.2.2
  332. steps:
  333. - checkout
  334. - attach_workspace:
  335. at: .
  336. - run:
  337. name: gcp credentials
  338. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  339. - run:
  340. name: sign in to gcp
  341. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  342. - run:
  343. name: deploy to s3
  344. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/release'
  345. - run:
  346. name: deploy to gcp
  347. command: '/opt/google-cloud-sdk/bin/gsutil cp ./enterprise-dist/* gs://$GCP_BUCKET_NAME/enterprise/release'
  348. - run:
  349. name: Deploy to Grafana.com
  350. command: './scripts/build/publish.sh --enterprise'
  351. - run:
  352. name: Load GPG private key
  353. command: './scripts/build/load-signing-key.sh'
  354. - run:
  355. name: Update Debian repository
  356. command: './scripts/build/update_repo/update-deb.sh "enterprise" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "enterprise-dist"'
  357. - run:
  358. name: Update RPM repository
  359. command: './scripts/build/update_repo/update-rpm.sh "enterprise" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "enterprise-dist"'
  360. deploy-master:
  361. docker:
  362. - image: grafana/grafana-ci-deploy:1.2.2
  363. steps:
  364. - attach_workspace:
  365. at: .
  366. - run:
  367. name: deploy to s3
  368. command: |
  369. # Also
  370. cp dist/grafana-latest.linux-x64.tar.gz dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  371. aws s3 sync ./dist s3://$BUCKET_NAME/master
  372. - run:
  373. name: Trigger Windows build
  374. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  375. - run:
  376. name: gcp credentials
  377. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  378. - run:
  379. name: sign in to gcp
  380. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  381. - run:
  382. name: deploy to gcp
  383. command: '/opt/google-cloud-sdk/bin/gsutil cp ./dist/* gs://$GCP_BUCKET_NAME/oss/master'
  384. - run:
  385. name: Publish to Grafana.com
  386. command: |
  387. rm dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  388. rm dist/*latest*
  389. cd dist && ../scripts/build/release_publisher/release_publisher -apikey ${GRAFANA_COM_API_KEY} -version "v$(cat grafana.version)" --nightly
  390. deploy-release:
  391. docker:
  392. - image: grafana/grafana-ci-deploy:1.2.2
  393. steps:
  394. - checkout
  395. - attach_workspace:
  396. at: .
  397. - run:
  398. name: deploy to s3
  399. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  400. - run:
  401. name: gcp credentials
  402. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  403. - run:
  404. name: sign in to gcp
  405. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  406. - run:
  407. name: deploy to gcp
  408. command: '/opt/google-cloud-sdk/bin/gsutil cp ./dist/* gs://$GCP_BUCKET_NAME/oss/release'
  409. - run:
  410. name: Deploy to Grafana.com
  411. command: './scripts/build/publish.sh'
  412. - run:
  413. name: Load GPG private key
  414. command: './scripts/build/load-signing-key.sh'
  415. - run:
  416. name: Update Debian repository
  417. command: './scripts/build/update_repo/update-deb.sh "oss" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "dist"'
  418. - run:
  419. name: Update RPM repository
  420. command: './scripts/build/update_repo/update-rpm.sh "oss" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "dist"'
  421. store-build-artifacts:
  422. docker:
  423. - image: circleci/node:8
  424. steps:
  425. - attach_workspace:
  426. at: .
  427. - store_artifacts:
  428. path: ./dist
  429. workflows:
  430. version: 2
  431. build-master:
  432. jobs:
  433. - build-all:
  434. filters: *filter-only-master
  435. - build-all-enterprise:
  436. filters: *filter-only-master
  437. - codespell:
  438. filters: *filter-only-master
  439. - backend-lint:
  440. filters: *filter-only-master
  441. - test-frontend:
  442. filters: *filter-only-master
  443. - test-backend:
  444. filters: *filter-only-master
  445. - mysql-integration-test:
  446. filters: *filter-only-master
  447. - postgres-integration-test:
  448. filters: *filter-only-master
  449. - deploy-master:
  450. requires:
  451. - build-all
  452. - test-backend
  453. - test-frontend
  454. - codespell
  455. - backend-lint
  456. - mysql-integration-test
  457. - postgres-integration-test
  458. filters: *filter-only-master
  459. - grafana-docker-master:
  460. requires:
  461. - build-all
  462. - build-all-enterprise
  463. - test-backend
  464. - test-frontend
  465. - codespell
  466. - backend-lint
  467. - mysql-integration-test
  468. - postgres-integration-test
  469. filters: *filter-only-master
  470. - deploy-enterprise-master:
  471. requires:
  472. - build-all
  473. - test-backend
  474. - test-frontend
  475. - codespell
  476. - backend-lint
  477. - mysql-integration-test
  478. - postgres-integration-test
  479. - build-all-enterprise
  480. filters: *filter-only-master
  481. release:
  482. jobs:
  483. - build-all:
  484. filters: *filter-only-release
  485. - build-all-enterprise:
  486. filters: *filter-only-release
  487. - codespell:
  488. filters: *filter-only-release
  489. - backend-lint:
  490. filters: *filter-only-release
  491. - test-frontend:
  492. filters: *filter-only-release
  493. - test-backend:
  494. filters: *filter-only-release
  495. - mysql-integration-test:
  496. filters: *filter-only-release
  497. - postgres-integration-test:
  498. filters: *filter-only-release
  499. - deploy-release:
  500. requires:
  501. - build-all
  502. - test-backend
  503. - test-frontend
  504. - codespell
  505. - backend-lint
  506. - mysql-integration-test
  507. - postgres-integration-test
  508. filters: *filter-only-release
  509. - deploy-enterprise-release:
  510. requires:
  511. - build-all
  512. - build-all-enterprise
  513. - test-backend
  514. - test-frontend
  515. - codespell
  516. - backend-lint
  517. - mysql-integration-test
  518. - postgres-integration-test
  519. filters: *filter-only-release
  520. - grafana-docker-release:
  521. requires:
  522. - build-all
  523. - build-all-enterprise
  524. - test-backend
  525. - test-frontend
  526. - codespell
  527. - backend-lint
  528. - mysql-integration-test
  529. - postgres-integration-test
  530. filters: *filter-only-release
  531. build-branches-and-prs:
  532. jobs:
  533. - build:
  534. filters: *filter-not-release-or-master
  535. - codespell:
  536. filters: *filter-not-release-or-master
  537. - backend-lint:
  538. filters: *filter-not-release-or-master
  539. - test-frontend:
  540. filters: *filter-not-release-or-master
  541. - test-backend:
  542. filters: *filter-not-release-or-master
  543. - mysql-integration-test:
  544. filters: *filter-not-release-or-master
  545. - postgres-integration-test:
  546. filters: *filter-not-release-or-master
  547. - cache-server-test:
  548. filters: *filter-not-release-or-master
  549. - grafana-docker-pr:
  550. requires:
  551. - build
  552. - test-backend
  553. - test-frontend
  554. - codespell
  555. - backend-lint
  556. - mysql-integration-test
  557. - postgres-integration-test
  558. - cache-server-test
  559. filters: *filter-not-release-or-master
  560. - store-build-artifacts:
  561. requires:
  562. - build
  563. - test-backend
  564. - test-frontend
  565. - codespell
  566. - backend-lint
  567. - mysql-integration-test
  568. - postgres-integration-test
  569. - cache-server-test
  570. filters: *filter-not-release-or-master