github.com/klaytn/klaytn@v1.12.1/.circleci/config.yml (about) 1 version: 2.1 2 3 aliases: 4 - &filter-only-version-tag 5 tags: 6 only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ 7 branches: 8 ignore: /.*/ 9 - &filter-version-not-release 10 tags: 11 only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/ 12 branches: 13 ignore: 14 - /release\/.*/ 15 - master 16 17 orbs: 18 codecov: codecov/codecov@1.0.5 19 docker: circleci/docker@2.1.1 20 21 executors: 22 linux-executor: # this executor is for general testing and packaging linux binaries 23 working_directory: ~/go/src/github.com/klaytn/klaytn 24 resource_class: medium 25 docker: 26 - image: klaytn/build_base:1.2-ubuntu18.04-go.1.20.6-solc0.8.13 27 auth: 28 username: $DOCKER_LOGIN 29 password: $DOCKER_PASSWORD 30 linux-others-executor: # this executor is for test-others job 31 working_directory: /go/src/github.com/klaytn/klaytn 32 resource_class: xlarge 33 docker: 34 - image: klaytn/build_base:1.2-ubuntu18.04-go.1.20.6-solc0.8.13 35 auth: 36 username: $DOCKER_LOGIN 37 password: $DOCKER_PASSWORD 38 - image: localstack/localstack:0.13.0 39 auth: 40 username: $DOCKER_LOGIN 41 password: $DOCKER_PASSWORD 42 - image: circleci/redis:6.0.8-alpine 43 auth: 44 username: $DOCKER_LOGIN 45 password: $DOCKER_PASSWORD 46 - name: zookeeper 47 image: wurstmeister/zookeeper 48 auth: 49 username: $DOCKER_LOGIN 50 password: $DOCKER_PASSWORD 51 - name: kafka 52 image: wurstmeister/kafka 53 auth: 54 username: $DOCKER_LOGIN 55 password: $DOCKER_PASSWORD 56 environment: 57 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 58 KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://kafka:9094 59 KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://kafka:9094 60 KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT 61 KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE 62 darwin-executor: # this executor is for packaging darwin binaries 63 working_directory: ~/go/src/github.com/klaytn/klaytn 64 macos: 65 xcode: 14.2.0 66 resource_class: macos.x86.medium.gen2 67 rpm-executor: # this executor is for packaging rpm binaries 68 working_directory: /go/src/github.com/klaytn/klaytn 69 docker: 70 - image: klaytn/circleci-rpmbuild:1.20.6-gcc7 71 auth: 72 username: $DOCKER_LOGIN 73 password: $DOCKER_PASSWORD 74 default: 75 working_directory: ~/go/src/github.com/klaytn/klaytn 76 docker: 77 - image: cimg/go:1.20.6 78 79 commands: 80 install-darwin-dependencies: 81 description: Install dependencies on darwin machine 82 steps: 83 - run: 84 name: "install darwin dependencies" 85 command: | 86 # install awscli 87 brew install awscli 88 # install golang 89 curl -O https://dl.google.com/go/go1.20.6.darwin-amd64.tar.gz 90 mkdir $HOME/go1.20.6 91 tar -C $HOME/go1.20.6 -xzf go1.20.6.darwin-amd64.tar.gz 92 pre-build: 93 description: "before build, set version" 94 steps: 95 - run: 96 name: "set variables" 97 command: | 98 export GOPATH=~/go 99 export PATH=$HOME/go1.20.6/go/bin:$PATH 100 pat="^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*" 101 102 if [[ $CIRCLE_TAG =~ $pat ]]; then 103 echo "this is rc version $CIRCLE_TAG" 104 rc_num=$(echo $CIRCLE_TAG | cut -d '-' -f 2) 105 106 sed 's/%d.%d.%d/%d.%d.%d~'$rc_num'/' params/version.go > params/version.go.tmp 107 mv params/version.go.tmp params/version.go 108 sed -n '/%d.%d.%d/p' params/version.go 109 else 110 echo "this is not RC version" 111 fi 112 echo "export KLAYTN_VERSION=$(go run build/rpm/main.go version)" >> $BASH_ENV 113 build-packaging: 114 description: "Build for each OS/Network" 115 parameters: 116 os-network: 117 type: string 118 default: "linux-amd64" 119 baobab: 120 type: string 121 default: "" 122 steps: 123 - run: 124 name: "build and packaging" 125 command: | 126 export GOPATH=~/go 127 export PATH=$HOME/go1.20.6/go/bin:$PATH 128 make all 129 for item in kcn kpn ken kscn kspn ksen kbn kgen homi; do 130 ./build/package-tar.sh << parameters.baobab >> << parameters.os-network >> $item 131 done 132 upload-repo: 133 description: "upload packaging tar.gz" 134 parameters: 135 item: 136 type: string 137 default: "kcn kpn ken kgen kscn kbn kspn ksen homi" 138 steps: 139 - run: 140 name: "upload S3 repo" 141 command: | 142 export GOPATH=~/go 143 export PATH=$HOME/go1.20.6/go/bin:$PATH 144 KLAYTN_VERSION=$(go run build/rpm/main.go version) 145 for item in << parameters.item >>; do aws s3 cp packages/${item}-*.tar.gz s3://$FRONTEND_BUCKET/packages/klaytn/$KLAYTN_VERSION/; done 146 rpm-tagging: 147 description: "rpm tagging for cypress" 148 steps: 149 - run: 150 name: "rpm tagging" 151 command: | 152 for item in kcn kpn ken kscn kspn ksen kbn kgen homi; do 153 ./build/package-rpm.sh $item 154 done 155 - run: 156 name: "upload S3 repo" 157 command: | 158 PLATFORM_SUFFIX=$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) 159 KLAYTN_VERSION=$(go run build/rpm/main.go version) 160 161 for item in kcn kpn ken kscn kspn ksen kbn kgen homi; do 162 TARGET_RPM=$(find $item-linux-x86_64/rpmbuild/RPMS/x86_64/ | awk -v pat="$item(d)?-v" '$0~pat') 163 aws s3 cp $TARGET_RPM s3://$FRONTEND_BUCKET/packages/rhel/7/prod/ 164 aws s3 cp $TARGET_RPM s3://$FRONTEND_BUCKET/packages/klaytn/$KLAYTN_VERSION/ 165 done 166 rpm-tagging-baobab: 167 description: "rpm tagging for baobab" 168 steps: 169 - run: 170 name: "rpm tagging baobab" 171 command: | 172 for item in kcn kpn ken; do 173 ./build/package-rpm.sh -b $item 174 done 175 - run: 176 name: "upload S3 repo" 177 command: | 178 for item in kcn kpn ken; do 179 TARGET_RPM=$(find $item-linux-x86_64/rpmbuild/RPMS/x86_64/ | awk -v pat="$item(d)?-baobab-v" '$0~pat') 180 aws s3 cp $TARGET_RPM s3://$FRONTEND_BUCKET/packages/rhel/7/prod/ 181 aws s3 cp $TARGET_RPM s3://$FRONTEND_BUCKET/packages/klaytn/$KLAYTN_VERSION/ 182 done 183 createrepo-update: 184 steps: 185 - run: 186 name: "createrepo update" 187 command: | 188 aws s3 sync s3://$FRONTEND_BUCKET/packages/rhel/7/prod/ rhel/7/prod/ 189 createrepo --update rhel/7/prod 190 aws s3 sync --delete rhel/7/prod/repodata/ s3://$FRONTEND_BUCKET/packages/rhel/7/prod/repodata/ 191 tag-verify: 192 steps: 193 - run: 194 name: "Verify tag and file version match" 195 command: | 196 echo "tag version is " $CIRCLE_TAG 197 KLAYTN_VERSION=$(go run build/rpm/main.go version) 198 echo "version on version.go" $KLAYTN_VERSION 199 if [ $KLAYTN_VERSION == ${CIRCLE_TAG%-*} ]; then 200 echo "verification pass" 201 else 202 echo "It's not same version." 203 exit 1 204 fi 205 tagger-verify: 206 steps: 207 - run: 208 name: "Verify tag and file version match" 209 command: | 210 TAGGER=$(git for-each-ref --format='%(tagger)' refs/tags/$CIRCLE_TAG | sed 's/ .*//') 211 if [ $TAGGER == 'circleci-klaytn' ]; then 212 echo "Pass! Tagger is circleci-klaytn" 213 else 214 echo "only circleci-klaytn can tagging major version" 215 exit 1 216 fi 217 make-pr: 218 steps: 219 - run: 220 name: "Push to release branch" 221 command: | 222 echo "push to release branch: /release/${CIRCLE_TAG%-*}" 223 git checkout -b release/${CIRCLE_TAG%-*} 224 git push origin release/${CIRCLE_TAG%-*} 225 - run: 226 name: "Install hub" 227 command: | 228 curl -sSLf https://github.com/github/hub/releases/download/v2.12.3/hub-linux-amd64-2.12.3.tgz | \ 229 tar zxf - --strip-components=1 -C /tmp && \ 230 sudo mv /tmp/bin/hub /usr/local/bin/hub 231 type hub 232 - run: 233 name: "Create pull request" 234 command: | 235 version=$(hub pr list -s open -L 10 -f "%H%n") 236 echo $version 237 if [[ $version == *"release/${CIRCLE_TAG%-*}"* ]]; then 238 echo "PR already exist" 239 else 240 echo "hub pull-request -m "[Master] release/$CIRCLE_TAG QA Signoff" -b $CIRCLE_PROJECT_USERNAME:master -h $CIRCLE_PROJECT_USERNAME:${CIRCLE_TAG%-*}" 241 echo -e "[Master] release/${CIRCLE_TAG%-*} QA Sign-off\n\nThis PR is automatically created by CI to release a new official version of $CIRCLE_PROJECT_REPONAME.\n\nWhen this PR is approved by QA team, a new version will be released." | hub pull-request -b $CIRCLE_PROJECT_USERNAME:master -h $CIRCLE_PROJECT_USERNAME:release/${CIRCLE_TAG%-*} -r $GITHUB_reviewer -l circleci -F- 242 fi 243 - run: 244 name: "build announce" 245 command: .circleci/scripts/build_announce.sh 246 tagging-delete-branch: 247 steps: 248 - run: 249 name: "Generate tag" 250 command: | 251 export version=$(go run build/rpm/main.go version) >> $BASH_ENV 252 echo "git tag $version" 253 git config --global user.email "team.devops@groundx.xyz" 254 git config --global user.name "circleci-klaytn" 255 git tag -a $version -m "$CIRCLE_STAGE" 256 git push origin $version 257 - run: 258 name: "Delete release branch" 259 command: | 260 export version=$(go run build/rpm/main.go version) >> $BASH_ENV 261 #delete release branch. it trigger by merge title 262 if [[ "release/v" = $(git log --oneline -1 | grep -o "release/v") ]]; then 263 echo "Delete branch release/$version" 264 git push origin --delete release/$version 265 else 266 echo "Need to delete branch manually" 267 fi 268 wait-other-containers-ready: 269 steps: 270 - run: 271 name: "Install net-cat" 272 command: apt install -y netcat 273 - run: 274 name: "Waiting for Redis to be ready" 275 command: | 276 for i in `seq 1 10`; 277 do 278 nc -z 127.0.0.1 6379 && echo Success && exit 0 279 echo -n . 280 sleep 1 281 done 282 echo Failed waiting for Redis && exit 1 283 - run: 284 name: "Waiting for zookeeper to be ready" 285 command: | 286 for i in `seq 1 10`; 287 do 288 nc -z zookeeper 2181 && echo Success && exit 0 289 echo -n . 290 sleep 1 291 done 292 echo Failed waiting for zookeeper && exit 1 293 - run: 294 name: "Waiting for Kafka to be ready" 295 command: | 296 for i in `seq 1 10`; 297 do 298 nc -z kafka 9092 && echo Success && exit 0 299 echo -n . 300 sleep 1 301 done 302 echo Failed waiting for Kafka && exit 1 303 - run: 304 name: "Wait until localstack container running" 305 command: | 306 timeout 60 sh -c \ 307 'until nc -z localhost 4566; do 308 echo "Waiting for Localstack ..." 309 sleep 1 310 done' 311 notify-success: 312 steps: 313 - run: 314 name: "notify slack when job success" 315 command : | 316 curl --data '{"text": "✅ Job *'$CIRCLE_JOB'* succeeded on *'$CIRCLE_BRANCH''$CIRCLE_TAG'*. Please see '$CIRCLE_BUILD_URL' for details."}' "$SLACK_WEBHOOK_URL" 317 when: on_success 318 notify-failure: 319 steps: 320 - run: 321 name: "notify slack when job fail" 322 command : | 323 curl --data '{"text": "❌ Job *'$CIRCLE_JOB'* failed on *'$CIRCLE_BRANCH'*. Please see '$CIRCLE_BUILD_URL' for details."}' "$SLACK_WEBHOOK_URL" 324 when: on_fail 325 run-rpc: 326 steps: 327 - run: 328 name: "Run rpc-tester on 1CN private network" 329 no_output_timeout: 30m 330 command: | 331 make kcn 332 git clone https://$TEST_TOKEN@github.com/klaytn/klaytn-rpc-tester.git 333 cd klaytn-rpc-tester 334 cp ../build/bin/kcn script/cn/bin/ 335 cd script 336 ./set_CNonly.sh 337 cd .. 338 cp config_template.json config.json 339 apt install python3.8 python3-venv -y 340 python3.8 -m venv --without-pip venv 341 source venv/bin/activate 342 curl https://bootstrap.pypa.io/get-pip.py | python 343 pip3 install -r requirements.txt 344 python3 main.py --protocol rpc 345 jobs: 346 build: 347 executor: linux-executor 348 steps: 349 - checkout 350 - pre-build 351 - run: 352 name: "Build" 353 command: make all 354 355 test-linter: 356 executor: linux-executor 357 steps: 358 - checkout 359 - run: 360 name: "Run golangci-lint" 361 no_output_timeout: 30m 362 command: go run build/ci.go lint -v --new-from-rev=dev 363 364 test-datasync: 365 executor: linux-others-executor 366 steps: 367 - checkout 368 - wait-other-containers-ready 369 - run: 370 name: "Run test datasync" 371 no_output_timeout: 30m 372 command: make test-datasync 373 374 test-networks: 375 executor: linux-executor 376 steps: 377 - checkout 378 - run: 379 name: "Run test networks" 380 no_output_timeout: 30m 381 command: make test-networks 382 383 test-node: 384 executor: linux-executor 385 steps: 386 - checkout 387 - run: 388 name: "Run test node" 389 no_output_timeout: 30m 390 command: make test-node 391 392 test-tests: 393 executor: linux-executor 394 steps: 395 - checkout 396 - run: 397 name: "Run test tests" 398 no_output_timeout: 30m 399 command: | 400 git clone --depth 1 https://$TEST_TOKEN@github.com/klaytn/klaytn-tests.git tests/testdata 401 make test-tests 402 403 test-others: 404 executor: linux-others-executor 405 resource_class: xlarge 406 steps: 407 - checkout 408 - wait-other-containers-ready 409 - run: 410 name: "Run test others" 411 no_output_timeout: 30m 412 command: | 413 make test-others 414 415 test-rpc: 416 executor: linux-executor 417 steps: 418 - checkout 419 - pre-build 420 - run-rpc 421 422 pass-tests: 423 executor: default 424 steps: 425 - run: 426 name: "tests pass!" 427 command: echo "tests pass!" 428 429 tagger-verify: 430 executor: default 431 steps: 432 - checkout 433 - tagger-verify 434 435 coverage: 436 executor: linux-others-executor 437 resource_class: xlarge 438 steps: 439 - checkout 440 - wait-other-containers-ready 441 - run: 442 shell: /bin/bash 443 name: "Run coverage tests" 444 command: | 445 set -e 446 export GOPATH=/go 447 git clone --depth 1 https://$TEST_TOKEN@github.com/klaytn/klaytn-tests.git tests/testdata 448 make cover 449 mkdir -p /tmp/coverage_reports 450 cp coverage_report.txt /tmp/coverage_reports/ 451 cp coverage_report.html /tmp/coverage_reports/ 452 - notify-failure 453 - notify-success 454 - store_artifacts: 455 path: /tmp/coverage_reports 456 - codecov/upload: 457 file: /tmp/coverage_reports/coverage_* 458 459 linters: 460 executor: linux-executor 461 steps: 462 - checkout 463 - run: 464 name: "Run linters" 465 command: | 466 make lint-try 467 mkdir -p /tmp/linter_reports 468 cp linter_report.txt /tmp/linter_reports/ 469 - notify-failure 470 - notify-success 471 - store_artifacts: 472 path: /tmp/linter_reports 473 474 rpc-tester-report: 475 executor: linux-executor 476 steps: 477 - checkout 478 - pre-build 479 - run-rpc 480 - notify-failure 481 - notify-success 482 483 packaging-linux: 484 executor: linux-executor 485 resource_class: large 486 steps: 487 - checkout 488 - pre-build 489 - build-packaging 490 - upload-repo 491 492 packaging-linux-baobab: 493 executor: linux-executor 494 resource_class: large 495 steps: 496 - checkout 497 - pre-build 498 - build-packaging: 499 baobab: "-b" 500 - upload-repo: 501 item: "kcn kpn ken" 502 503 packaging-darwin: 504 executor: darwin-executor 505 steps: 506 - checkout 507 - install-darwin-dependencies 508 - pre-build 509 - build-packaging: 510 os-network: "darwin-amd64" 511 - upload-repo 512 513 packaging-darwin-baobab: 514 executor: darwin-executor 515 steps: 516 - checkout 517 - install-darwin-dependencies 518 - pre-build 519 - build-packaging: 520 os-network: "darwin-amd64" 521 baobab: "-b" 522 - upload-repo: 523 item: "kcn kpn ken" 524 525 rpm-tagged: 526 executor: rpm-executor 527 steps: 528 - checkout 529 - pre-build 530 - rpm-tagging 531 532 rpm-tagged-baobab: 533 executor: rpm-executor 534 steps: 535 - checkout 536 - pre-build 537 - rpm-tagging-baobab 538 539 deploy-rpm-public: 540 executor: rpm-executor 541 steps: 542 - add_ssh_keys 543 - createrepo-update 544 - notify-failure 545 - notify-success 546 547 tag-verify: 548 executor: linux-executor 549 steps: 550 - checkout 551 - tag-verify 552 553 release-PR: 554 executor: default 555 steps: 556 - add_ssh_keys 557 - checkout 558 - make-pr 559 - notify-failure 560 - notify-success 561 562 major-tagging: 563 executor: default 564 steps: 565 - add_ssh_keys 566 - checkout 567 - tagging-delete-branch 568 569 workflows: 570 version: 2 571 build_n_packaging: 572 jobs: 573 - build: 574 filters: *filter-version-not-release 575 - test-datasync: 576 filters: *filter-version-not-release 577 - test-networks: 578 filters: *filter-version-not-release 579 - test-node: 580 filters: *filter-version-not-release 581 - test-tests: 582 filters: *filter-version-not-release 583 - test-others: 584 filters: *filter-version-not-release 585 - test-linter: 586 filters: *filter-version-not-release 587 - tagger-verify: 588 filters: 589 tags: 590 only: /^v[0-9]+\.[0-9]+\.[0-9]+/ 591 branches: 592 ignore: /.*/ 593 - test-rpc: 594 filters: *filter-only-version-tag 595 596 - pass-tests: 597 requires: 598 - build 599 - test-datasync 600 - test-networks 601 - test-node 602 - test-tests 603 - test-others 604 - tag-verify 605 - tagger-verify 606 filters: *filter-version-not-release 607 608 - docker/publish: # for dev branch 609 filters: 610 branches: 611 only: dev 612 requires: 613 - pass-tests 614 extra_build_args: '--platform=linux/amd64' 615 image: klaytn/klaytn 616 tag: dev 617 executor: docker/docker 618 use-remote-docker: true 619 remote-docker-version: 20.10.14 620 use-buildkit: true 621 622 - docker/publish: # for release versions 623 filters: 624 tags: 625 only: /^v[0-9]+\.[0-9]+\.[0-9]+/ 626 branches: 627 ignore: /.*/ 628 requires: 629 - pass-tests 630 extra_build_args: '--platform=linux/amd64' 631 image: klaytn/klaytn 632 tag: latest,$CIRCLE_TAG 633 executor: docker/docker 634 use-remote-docker: true 635 remote-docker-version: 20.10.14 636 use-buildkit: true 637 638 - tag-verify: 639 filters: *filter-only-version-tag 640 641 - deploy-rpm-public: 642 requires: 643 - rpm-tagged 644 - rpm-tagged-baobab 645 - packaging-linux 646 - packaging-linux-baobab 647 - packaging-darwin 648 - packaging-darwin-baobab 649 filters: 650 tags: 651 only: /^v[0-9]+\.[0-9]+\.[0-9]/ 652 branches: 653 ignore: /.*/ 654 655 - release-PR: 656 requires: 657 - rpm-tagged 658 - rpm-tagged-baobab 659 - packaging-linux 660 - packaging-linux-baobab 661 - packaging-darwin 662 - packaging-darwin-baobab 663 filters: 664 tags: 665 only: /^v[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+.*/ 666 branches: 667 ignore: /.*/ 668 669 - rpm-tagged: 670 filters: *filter-only-version-tag 671 requires: 672 - pass-tests 673 - rpm-tagged-baobab: 674 filters: *filter-only-version-tag 675 requires: 676 - pass-tests 677 - packaging-linux: 678 filters: *filter-only-version-tag 679 requires: 680 - pass-tests 681 - packaging-linux-baobab: 682 filters: *filter-only-version-tag 683 requires: 684 - pass-tests 685 - packaging-darwin: 686 filters: *filter-only-version-tag 687 requires: 688 - pass-tests 689 - packaging-darwin-baobab: 690 filters: *filter-only-version-tag 691 requires: 692 - pass-tests 693 694 - major-tagging: 695 filters: 696 branches: 697 only: master 698 699 nightly-coverage: 700 triggers: 701 - schedule: 702 cron: "0 18 * * *" 703 filters: 704 branches: 705 only: dev 706 jobs: 707 - coverage 708 709 nightly-linters: 710 triggers: 711 - schedule: 712 cron: "0 19 * * *" 713 filters: 714 branches: 715 only: dev 716 jobs: 717 - linters 718 719 nightly-rpc: 720 triggers: 721 - schedule: 722 cron: "0 20 * * *" 723 filters: 724 branches: 725 only: dev 726 jobs: 727 - rpc-tester-report