config.yml 18 KB

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