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.

421 lines
13 KiB

7 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. reproducible_builds:
  312. <<: *defaults
  313. steps:
  314. - attach_workspace:
  315. at: /tmp/workspace
  316. - checkout
  317. - setup_remote_docker:
  318. docker_layer_caching: true
  319. - run:
  320. name: Build tendermint
  321. no_output_timeout: 20m
  322. command: |
  323. sudo apt-get install -y ruby
  324. bash -x ./scripts/gitian-build.sh all
  325. for os in darwin linux windows; do
  326. cp gitian-build-${os}/result/tendermint-${os}-res.yml .
  327. cp gitian-build-${os}/build/out/tendermint-*.tar.gz .
  328. rm -rf gitian-build-${os}/
  329. done
  330. - store_artifacts:
  331. path: /go/src/github.com/tendermint/tendermint/tendermint-darwin-res.yml
  332. - store_artifacts:
  333. path: /go/src/github.com/tendermint/tendermint/tendermint-linux-res.yml
  334. - store_artifacts:
  335. path: /go/src/github.com/tendermint/tendermint/tendermint-windows-res.yml
  336. - store_artifacts:
  337. path: /go/src/github.com/tendermint/tendermint/tendermint-*.tar.gz
  338. workflows:
  339. version: 2
  340. test-suite:
  341. jobs:
  342. - deploy_docs:
  343. filters:
  344. branches:
  345. only:
  346. - master
  347. - setup_dependencies
  348. - test_abci_apps:
  349. requires:
  350. - setup_dependencies
  351. - test_abci_cli:
  352. requires:
  353. - setup_dependencies
  354. - test_apps:
  355. requires:
  356. - setup_dependencies
  357. - test_cover:
  358. requires:
  359. - setup_dependencies
  360. - test_persistence:
  361. requires:
  362. - setup_dependencies
  363. - localnet:
  364. requires:
  365. - setup_dependencies
  366. - test_p2p
  367. - upload_coverage:
  368. requires:
  369. - test_cover
  370. - reproducible_builds:
  371. filters:
  372. branches:
  373. only:
  374. - master
  375. - /v[0-9]+\.[0-9]+/
  376. release:
  377. jobs:
  378. - prepare_build
  379. - build_artifacts:
  380. requires:
  381. - prepare_build
  382. - release_artifacts:
  383. requires:
  384. - prepare_build
  385. - build_artifacts
  386. filters:
  387. branches:
  388. only:
  389. - /v[0-9]+\.[0-9]+/
  390. - release_docker:
  391. requires:
  392. - prepare_build
  393. - build_artifacts
  394. filters:
  395. branches:
  396. only:
  397. - /v[0-9]+\.[0-9]+/