config.yml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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.5
  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.11.5
  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.11.5
  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. gometalinter:
  84. docker:
  85. - image: circleci/golang:1.11.5
  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: Gometalinter tests
  94. command: './scripts/gometalinter.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.11.5
  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.3
  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/grafana*
  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.3
  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/grafana*
  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.3
  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/grafana-enterprise*
  260. build-all-enterprise:
  261. docker:
  262. - image: grafana/build-container:1.2.3
  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/grafana-enterprise*
  306. deploy-enterprise-master:
  307. docker:
  308. - image: grafana/grafana-ci-deploy:1.2.1
  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: 'cd enterprise-dist && ../scripts/build/release_publisher/release_publisher -apikey ${GRAFANA_COM_API_KEY} -enterprise -from-local'
  327. deploy-enterprise-release:
  328. docker:
  329. - image: grafana/grafana-ci-deploy:1.2.1
  330. steps:
  331. - checkout
  332. - attach_workspace:
  333. at: .
  334. - run:
  335. name: gcp credentials
  336. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  337. - run:
  338. name: sign in to gcp
  339. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  340. - run:
  341. name: deploy to s3
  342. command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/release'
  343. - run:
  344. name: deploy to gcp
  345. command: '/opt/google-cloud-sdk/bin/gsutil cp ./enterprise-dist/* gs://$GCP_BUCKET_NAME/enterprise/release'
  346. - run:
  347. name: Deploy to Grafana.com
  348. command: './scripts/build/publish.sh --enterprise'
  349. - run:
  350. name: Load GPG private key
  351. command: './scripts/build/load-signing-key.sh'
  352. - run:
  353. name: Update Debian repository
  354. command: './scripts/build/update_repo/update-deb.sh "enterprise" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "enterprise-dist"'
  355. - run:
  356. name: Update RPM repository
  357. command: './scripts/build/update_repo/update-rpm.sh "enterprise" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "enterprise-dist"'
  358. deploy-master:
  359. docker:
  360. - image: grafana/grafana-ci-deploy:1.2.1
  361. steps:
  362. - attach_workspace:
  363. at: .
  364. - run:
  365. name: deploy to s3
  366. command: |
  367. # Also
  368. cp dist/grafana-latest.linux-x64.tar.gz dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  369. aws s3 sync ./dist s3://$BUCKET_NAME/master
  370. - run:
  371. name: Trigger Windows build
  372. command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
  373. - run:
  374. name: gcp credentials
  375. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  376. - run:
  377. name: sign in to gcp
  378. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  379. - run:
  380. name: deploy to gcp
  381. command: '/opt/google-cloud-sdk/bin/gsutil cp ./dist/* gs://$GCP_BUCKET_NAME/oss/master'
  382. - run:
  383. name: Publish to Grafana.com
  384. command: |
  385. rm dist/grafana-master-$(echo "${CIRCLE_SHA1}" | cut -b1-7).linux-x64.tar.gz
  386. rm dist/*latest*
  387. cd dist && ../scripts/build/release_publisher/release_publisher -apikey ${GRAFANA_COM_API_KEY} -from-local
  388. deploy-release:
  389. docker:
  390. - image: grafana/grafana-ci-deploy:1.2.1
  391. steps:
  392. - checkout
  393. - attach_workspace:
  394. at: .
  395. - run:
  396. name: deploy to s3
  397. command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
  398. - run:
  399. name: gcp credentials
  400. command: 'echo ${GCP_GRAFANA_UPLOAD_KEY} > /tmp/gcpkey.json'
  401. - run:
  402. name: sign in to gcp
  403. command: '/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcpkey.json'
  404. - run:
  405. name: deploy to gcp
  406. command: '/opt/google-cloud-sdk/bin/gsutil cp ./dist/* gs://$GCP_BUCKET_NAME/oss/release'
  407. - run:
  408. name: Deploy to Grafana.com
  409. command: './scripts/build/publish.sh'
  410. - run:
  411. name: Load GPG private key
  412. command: './scripts/build/load-signing-key.sh'
  413. - run:
  414. name: Update Debian repository
  415. command: './scripts/build/update_repo/update-deb.sh "oss" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "dist"'
  416. - run:
  417. name: Update RPM repository
  418. command: './scripts/build/update_repo/update-rpm.sh "oss" "$GPG_KEY_PASSWORD" "$CIRCLE_TAG" "dist"'
  419. store-build-artifacts:
  420. docker:
  421. - image: circleci/node:8
  422. steps:
  423. - attach_workspace:
  424. at: .
  425. - store_artifacts:
  426. path: ./dist
  427. workflows:
  428. version: 2
  429. build-master:
  430. jobs:
  431. - build-all:
  432. filters: *filter-only-master
  433. - build-all-enterprise:
  434. filters: *filter-only-master
  435. - codespell:
  436. filters: *filter-only-master
  437. - gometalinter:
  438. filters: *filter-only-master
  439. - test-frontend:
  440. filters: *filter-only-master
  441. - test-backend:
  442. filters: *filter-only-master
  443. - mysql-integration-test:
  444. filters: *filter-only-master
  445. - postgres-integration-test:
  446. filters: *filter-only-master
  447. - deploy-master:
  448. requires:
  449. - build-all
  450. - test-backend
  451. - test-frontend
  452. - codespell
  453. - gometalinter
  454. - mysql-integration-test
  455. - postgres-integration-test
  456. filters: *filter-only-master
  457. - grafana-docker-master:
  458. requires:
  459. - build-all
  460. - build-all-enterprise
  461. - test-backend
  462. - test-frontend
  463. - codespell
  464. - gometalinter
  465. - mysql-integration-test
  466. - postgres-integration-test
  467. filters: *filter-only-master
  468. - deploy-enterprise-master:
  469. requires:
  470. - build-all
  471. - test-backend
  472. - test-frontend
  473. - codespell
  474. - gometalinter
  475. - mysql-integration-test
  476. - postgres-integration-test
  477. - build-all-enterprise
  478. filters: *filter-only-master
  479. release:
  480. jobs:
  481. - build-all:
  482. filters: *filter-only-release
  483. - build-all-enterprise:
  484. filters: *filter-only-release
  485. - codespell:
  486. filters: *filter-only-release
  487. - gometalinter:
  488. filters: *filter-only-release
  489. - test-frontend:
  490. filters: *filter-only-release
  491. - test-backend:
  492. filters: *filter-only-release
  493. - mysql-integration-test:
  494. filters: *filter-only-release
  495. - postgres-integration-test:
  496. filters: *filter-only-release
  497. - deploy-release:
  498. requires:
  499. - build-all
  500. - test-backend
  501. - test-frontend
  502. - codespell
  503. - gometalinter
  504. - mysql-integration-test
  505. - postgres-integration-test
  506. filters: *filter-only-release
  507. - deploy-enterprise-release:
  508. requires:
  509. - build-all
  510. - build-all-enterprise
  511. - test-backend
  512. - test-frontend
  513. - codespell
  514. - gometalinter
  515. - mysql-integration-test
  516. - postgres-integration-test
  517. filters: *filter-only-release
  518. - grafana-docker-release:
  519. requires:
  520. - build-all
  521. - build-all-enterprise
  522. - test-backend
  523. - test-frontend
  524. - codespell
  525. - gometalinter
  526. - mysql-integration-test
  527. - postgres-integration-test
  528. filters: *filter-only-release
  529. build-branches-and-prs:
  530. jobs:
  531. - build:
  532. filters: *filter-not-release-or-master
  533. - codespell:
  534. filters: *filter-not-release-or-master
  535. - gometalinter:
  536. filters: *filter-not-release-or-master
  537. - test-frontend:
  538. filters: *filter-not-release-or-master
  539. - test-backend:
  540. filters: *filter-not-release-or-master
  541. - mysql-integration-test:
  542. filters: *filter-not-release-or-master
  543. - postgres-integration-test:
  544. filters: *filter-not-release-or-master
  545. - cache-server-test:
  546. filters: *filter-not-release-or-master
  547. - grafana-docker-pr:
  548. requires:
  549. - build
  550. - test-backend
  551. - test-frontend
  552. - codespell
  553. - gometalinter
  554. - mysql-integration-test
  555. - postgres-integration-test
  556. - cache-server-test
  557. filters: *filter-not-release-or-master
  558. - store-build-artifacts:
  559. requires:
  560. - build
  561. - test-backend
  562. - test-frontend
  563. - codespell
  564. - gometalinter
  565. - mysql-integration-test
  566. - postgres-integration-test
  567. - cache-server-test
  568. filters: *filter-not-release-or-master