You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
13 KiB

6 years ago
  1. version: 2
  2. defaults: &defaults
  3. working_directory: /go/src/github.com/tendermint/tendermint
  4. docker:
  5. - image: circleci/golang
  6. environment:
  7. GOBIN: /tmp/workspace/bin
  8. docs_update_config: &docs_update_config
  9. working_directory: ~/repo
  10. docker:
  11. - image: tendermintdev/jq_curl
  12. environment:
  13. AWS_REGION: us-east-1
  14. release_management_docker: &release_management_docker
  15. machine: true
  16. jobs:
  17. setup_dependencies:
  18. <<: *defaults
  19. steps:
  20. - run: mkdir -p /tmp/workspace/bin
  21. - run: mkdir -p /tmp/workspace/profiles
  22. - checkout
  23. - restore_cache:
  24. keys:
  25. - v3-pkg-cache
  26. - run:
  27. name: tools
  28. command: |
  29. export PATH="$GOBIN:$PATH"
  30. make get_tools
  31. - run:
  32. name: dependencies
  33. command: |
  34. export PATH="$GOBIN:$PATH"
  35. make get_vendor_deps
  36. - run:
  37. name: binaries
  38. command: |
  39. export PATH="$GOBIN:$PATH"
  40. make install install_abci
  41. - persist_to_workspace:
  42. root: /tmp/workspace
  43. paths:
  44. - bin
  45. - profiles
  46. - save_cache:
  47. key: v3-pkg-cache
  48. paths:
  49. - /go/pkg
  50. - save_cache:
  51. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  52. paths:
  53. - /go/src/github.com/tendermint/tendermint
  54. build_slate:
  55. <<: *defaults
  56. steps:
  57. - attach_workspace:
  58. at: /tmp/workspace
  59. - restore_cache:
  60. key: v3-pkg-cache
  61. - restore_cache:
  62. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  63. - run:
  64. name: slate docs
  65. command: |
  66. set -ex
  67. export PATH="$GOBIN:$PATH"
  68. make build-slate
  69. lint:
  70. <<: *defaults
  71. steps:
  72. - attach_workspace:
  73. at: /tmp/workspace
  74. - restore_cache:
  75. key: v3-pkg-cache
  76. - restore_cache:
  77. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  78. - run:
  79. name: metalinter
  80. command: |
  81. set -ex
  82. export PATH="$GOBIN:$PATH"
  83. make lint
  84. - run:
  85. name: check_dep
  86. command: |
  87. set -ex
  88. export PATH="$GOBIN:$PATH"
  89. make check_dep
  90. test_abci_apps:
  91. <<: *defaults
  92. steps:
  93. - attach_workspace:
  94. at: /tmp/workspace
  95. - restore_cache:
  96. key: v3-pkg-cache
  97. - restore_cache:
  98. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  99. - run:
  100. name: Run abci apps tests
  101. command: |
  102. export PATH="$GOBIN:$PATH"
  103. bash abci/tests/test_app/test.sh
  104. # if this test fails, fix it and update the docs at:
  105. # https://github.com/tendermint/tendermint/blob/develop/docs/abci-cli.md
  106. test_abci_cli:
  107. <<: *defaults
  108. steps:
  109. - attach_workspace:
  110. at: /tmp/workspace
  111. - restore_cache:
  112. key: v3-pkg-cache
  113. - restore_cache:
  114. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  115. - run:
  116. name: Run abci-cli tests
  117. command: |
  118. export PATH="$GOBIN:$PATH"
  119. bash abci/tests/test_cli/test.sh
  120. test_apps:
  121. <<: *defaults
  122. steps:
  123. - attach_workspace:
  124. at: /tmp/workspace
  125. - restore_cache:
  126. key: v3-pkg-cache
  127. - restore_cache:
  128. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  129. - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends bsdmainutils
  130. - run:
  131. name: Run tests
  132. command: bash test/app/test.sh
  133. test_cover:
  134. <<: *defaults
  135. parallelism: 4
  136. steps:
  137. - attach_workspace:
  138. at: /tmp/workspace
  139. - restore_cache:
  140. key: v3-pkg-cache
  141. - restore_cache:
  142. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  143. - run: mkdir -p /tmp/logs
  144. - run:
  145. name: Run tests
  146. command: |
  147. for pkg in $(go list github.com/tendermint/tendermint/... | circleci tests split --split-by=timings); do
  148. id=$(basename "$pkg")
  149. go test -v -timeout 5m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
  150. done
  151. - persist_to_workspace:
  152. root: /tmp/workspace
  153. paths:
  154. - "profiles/*"
  155. - store_artifacts:
  156. path: /tmp/logs
  157. test_persistence:
  158. <<: *defaults
  159. steps:
  160. - attach_workspace:
  161. at: /tmp/workspace
  162. - restore_cache:
  163. key: v3-pkg-cache
  164. - restore_cache:
  165. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  166. - run:
  167. name: Run tests
  168. command: bash test/persist/test_failure_indices.sh
  169. localnet:
  170. working_directory: /home/circleci/.go_workspace/src/github.com/tendermint/tendermint
  171. machine:
  172. image: circleci/classic:latest
  173. environment:
  174. GOBIN: /home/circleci/.go_workspace/bin
  175. GOPATH: /home/circleci/.go_workspace/
  176. GOOS: linux
  177. GOARCH: amd64
  178. parallelism: 1
  179. steps:
  180. - checkout
  181. - run:
  182. name: run localnet and exit on failure
  183. command: |
  184. set -x
  185. docker run --rm -v "$PWD":/go/src/github.com/tendermint/tendermint -w /go/src/github.com/tendermint/tendermint golang make build-linux
  186. make localnet-start &
  187. ./scripts/localnet-blocks-test.sh 40 5 10 localhost
  188. test_p2p:
  189. environment:
  190. GOBIN: /home/circleci/.go_workspace/bin
  191. GOPATH: /home/circleci/.go_workspace
  192. machine:
  193. image: circleci/classic:latest
  194. steps:
  195. - checkout
  196. - run: mkdir -p $GOPATH/src/github.com/tendermint
  197. - run: ln -sf /home/circleci/project $GOPATH/src/github.com/tendermint/tendermint
  198. - run: bash test/p2p/circleci.sh
  199. - store_artifacts:
  200. path: /home/circleci/project/test/p2p/logs
  201. upload_coverage:
  202. <<: *defaults
  203. steps:
  204. - attach_workspace:
  205. at: /tmp/workspace
  206. - restore_cache:
  207. key: v3-pkg-cache
  208. - restore_cache:
  209. key: v3-tree-{{ .Environment.CIRCLE_SHA1 }}
  210. - run:
  211. name: gather
  212. command: |
  213. set -ex
  214. echo "mode: atomic" > coverage.txt
  215. for prof in $(ls /tmp/workspace/profiles/); do
  216. tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
  217. done
  218. - run:
  219. name: upload
  220. command: bash .circleci/codecov.sh -f coverage.txt
  221. deploy_docs:
  222. <<: *docs_update_config
  223. steps:
  224. - checkout
  225. - run:
  226. name: Trigger website build
  227. command: |
  228. curl --silent \
  229. --show-error \
  230. -X POST \
  231. --header "Content-Type: application/json" \
  232. -d "{\"branch\": \"$CIRCLE_BRANCH\"}" \
  233. "https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$WEBSITE_REPO_NAME/build?circle-token=$TENDERBOT_API_TOKEN" > response.json
  234. RESULT=`jq -r '.status' response.json`
  235. MESSAGE=`jq -r '.message' response.json`
  236. if [[ ${RESULT} == "null" ]] || [[ ${RESULT} -ne "200" ]]; then
  237. echo "CircleCI API call failed: $MESSAGE"
  238. exit 1
  239. else
  240. echo "Website build started"
  241. fi
  242. prepare_build:
  243. <<: *defaults
  244. steps:
  245. - checkout
  246. - run:
  247. name: Get next release number
  248. command: |
  249. export LAST_TAG="`git describe --tags --abbrev=0 --match "${CIRCLE_BRANCH}.*"`"
  250. echo "Last tag: ${LAST_TAG}"
  251. if [ -z "${LAST_TAG}" ]; then
  252. export LAST_TAG="${CIRCLE_BRANCH}"
  253. echo "Last tag not found. Possibly fresh branch or feature branch. Setting ${LAST_TAG} as tag."
  254. fi
  255. export NEXT_TAG="`python -u scripts/release_management/bump-semver.py --version "${LAST_TAG}"`"
  256. echo "Next tag: ${NEXT_TAG}"
  257. echo "export CIRCLE_TAG=\"${NEXT_TAG}\"" > release-version.source
  258. - run:
  259. name: Build dependencies
  260. command: |
  261. make get_tools get_vendor_deps
  262. - persist_to_workspace:
  263. root: .
  264. paths:
  265. - "release-version.source"
  266. - save_cache:
  267. key: v1-release-deps-{{ .Branch }}-{{ .Revision }}
  268. paths:
  269. - "vendor"
  270. build_artifacts:
  271. <<: *defaults
  272. parallelism: 4
  273. steps:
  274. - checkout
  275. - restore_cache:
  276. keys:
  277. - v1-release-deps-{{ .Branch }}-{{ .Revision }}
  278. - attach_workspace:
  279. at: /tmp/workspace
  280. - run:
  281. name: Build artifact
  282. command: |
  283. # Setting CIRCLE_TAG because we do not tag the release ourselves.
  284. source /tmp/workspace/release-version.source
  285. if test ${CIRCLE_NODE_INDEX:-0} == 0 ;then export GOOS=linux GOARCH=amd64 && export OUTPUT=build/tendermint_${GOOS}_${GOARCH} && make build && python -u scripts/release_management/zip-file.py ;fi
  286. if test ${CIRCLE_NODE_INDEX:-0} == 1 ;then export GOOS=darwin GOARCH=amd64 && export OUTPUT=build/tendermint_${GOOS}_${GOARCH} && make build && python -u scripts/release_management/zip-file.py ;fi
  287. if test ${CIRCLE_NODE_INDEX:-0} == 2 ;then export GOOS=windows GOARCH=amd64 && export OUTPUT=build/tendermint_${GOOS}_${GOARCH} && make build && python -u scripts/release_management/zip-file.py ;fi
  288. if test ${CIRCLE_NODE_INDEX:-0} == 3 ;then export GOOS=linux GOARCH=arm && export OUTPUT=build/tendermint_${GOOS}_${GOARCH} && make build && python -u scripts/release_management/zip-file.py ;fi
  289. - persist_to_workspace:
  290. root: build
  291. paths:
  292. - "*.zip"
  293. - "tendermint_linux_amd64"
  294. release_artifacts:
  295. <<: *defaults
  296. steps:
  297. - checkout
  298. - attach_workspace:
  299. at: /tmp/workspace
  300. - run:
  301. name: Deploy to GitHub
  302. command: |
  303. # Setting CIRCLE_TAG because we do not tag the release ourselves.
  304. source /tmp/workspace/release-version.source
  305. echo "---"
  306. ls -la /tmp/workspace/*.zip
  307. echo "---"
  308. python -u scripts/release_management/sha-files.py
  309. echo "---"
  310. cat /tmp/workspace/SHA256SUMS
  311. echo "---"
  312. export RELEASE_ID="`python -u scripts/release_management/github-draft.py`"
  313. echo "Release ID: ${RELEASE_ID}"
  314. #Todo: Parallelize uploads
  315. export GOOS=linux GOARCH=amd64 && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
  316. export GOOS=darwin GOARCH=amd64 && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
  317. export GOOS=windows GOARCH=amd64 && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
  318. export GOOS=linux GOARCH=arm && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
  319. python -u scripts/release_management/github-upload.py --file "/tmp/workspace/SHA256SUMS" --id "${RELEASE_ID}"
  320. python -u scripts/release_management/github-publish.py --id "${RELEASE_ID}"
  321. release_docker:
  322. <<: *release_management_docker
  323. steps:
  324. - checkout
  325. - attach_workspace:
  326. at: /tmp/workspace
  327. - run:
  328. name: Deploy to Docker Hub
  329. command: |
  330. # Setting CIRCLE_TAG because we do not tag the release ourselves.
  331. source /tmp/workspace/release-version.source
  332. cp /tmp/workspace/tendermint_linux_amd64 DOCKER/tendermint
  333. docker build --label="tendermint" --tag="tendermint/tendermint:${CIRCLE_TAG}" --tag="tendermint/tendermint:latest" "DOCKER"
  334. docker login -u "${DOCKERHUB_USER}" --password-stdin <<< "${DOCKERHUB_PASS}"
  335. docker push "tendermint/tendermint"
  336. docker logout
  337. workflows:
  338. version: 2
  339. test-suite:
  340. jobs:
  341. - deploy_docs:
  342. filters:
  343. branches:
  344. only:
  345. - master
  346. - develop
  347. - setup_dependencies
  348. - lint:
  349. requires:
  350. - setup_dependencies
  351. - test_abci_apps:
  352. requires:
  353. - setup_dependencies
  354. - test_abci_cli:
  355. requires:
  356. - setup_dependencies
  357. - test_apps:
  358. requires:
  359. - setup_dependencies
  360. - test_cover:
  361. requires:
  362. - setup_dependencies
  363. - test_persistence:
  364. requires:
  365. - setup_dependencies
  366. - localnet:
  367. requires:
  368. - setup_dependencies
  369. - test_p2p
  370. - upload_coverage:
  371. requires:
  372. - test_cover
  373. release:
  374. jobs:
  375. - prepare_build
  376. - build_artifacts:
  377. requires:
  378. - prepare_build
  379. - release_artifacts:
  380. requires:
  381. - prepare_build
  382. - build_artifacts
  383. filters:
  384. branches:
  385. only:
  386. - /v[0-9]+\.[0-9]+/
  387. - release_docker:
  388. requires:
  389. - prepare_build
  390. - build_artifacts
  391. filters:
  392. branches:
  393. only:
  394. - /v[0-9]+\.[0-9]+/