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.

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