github.com/franono/tendermint@v0.32.2-0.20200527150959-749313264ce9/.circleci/config.yml (about)

     1  version: 2.1
     2  
     3  executors:
     4    golang:
     5      docker:
     6        - image: tendermintdev/docker-tendermint-build
     7      working_directory: /go/src/github.com/franono/tendermint
     8      environment:
     9        GOBIN: /tmp/bin
    10    release:
    11      machine: true
    12    docs:
    13      docker:
    14        - image: tendermintdev/docker-website-deployment
    15      environment:
    16        AWS_REGION: us-east-1
    17  
    18  commands:
    19    run_test:
    20      parameters:
    21        script_path:
    22          type: string
    23      steps:
    24        - attach_workspace:
    25            at: /tmp/bin
    26        - restore_cache:
    27            name: "Restore source code cache"
    28            keys:
    29              - go-src-v1-{{ .Revision }}
    30        - checkout
    31        - restore_cache:
    32            name: "Restore go modules cache"
    33            keys:
    34              - go-mod-v1-{{ checksum "go.sum" }}
    35        - run:
    36            name: "Running test"
    37            command: |
    38              bash << parameters.script_path >>
    39  
    40  jobs:
    41    setup_dependencies:
    42      executor: golang
    43      steps:
    44        - checkout
    45        - restore_cache:
    46            name: "Restore go modules cache"
    47            keys:
    48              - go-mod-v1-{{ checksum "go.sum" }}
    49        - run:
    50            command: |
    51              mkdir -p /tmp/bin
    52        - run:
    53            name: Cache go modules
    54            command: make go-mod-cache
    55        - run:
    56            name: tools
    57            command: make tools
    58        - run:
    59            name: "Build binaries"
    60            command: make install install_abci
    61        - save_cache:
    62            name: "Save go modules cache"
    63            key: go-mod-v1-{{ checksum "go.sum" }}
    64            paths:
    65              - "/go/pkg/mod"
    66        - save_cache:
    67            name: "Save source code cache"
    68            key: go-src-v1-{{ .Revision }}
    69            paths:
    70              - ".git"
    71        - persist_to_workspace:
    72            root: "/tmp/bin"
    73            paths:
    74              - "."
    75  
    76    test_persistence:
    77      executor: golang
    78      steps:
    79        - run_test:
    80            script_path: test/persist/test_failure_indices.sh
    81  
    82    test_cover:
    83      executor: golang
    84      parallelism: 4
    85      steps:
    86        - restore_cache:
    87            name: "Restore source code cache"
    88            keys:
    89              - go-src-v1-{{ .Revision }}
    90        - checkout
    91        - restore_cache:
    92            name: "Restore go module cache"
    93            keys:
    94              - go-mod-v2-{{ checksum "go.sum" }}
    95        - run:
    96            name: "Run tests"
    97            command: |
    98              export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
    99              export GO111MODULE=on
   100              mkdir -p /tmp/logs /tmp/workspace/profiles
   101              for pkg in $(go list github.com/franono/tendermint/... | circleci tests split --split-by=timings); do
   102                id=$(basename "$pkg")
   103                go test -timeout 7m -mod=readonly -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
   104              done
   105        - persist_to_workspace:
   106            root: /tmp/workspace
   107            paths:
   108              - "profiles/*"
   109        - store_artifacts:
   110            path: /tmp/logs
   111  
   112    test_p2p:
   113      environment:
   114        GOBIN: /home/circleci/.go_workspace/bin
   115        GOPATH: /home/circleci/.go_workspace
   116      machine:
   117        image: circleci/classic:latest
   118      parameters:
   119        ipv:
   120          type: integer
   121          default: 4
   122      steps:
   123        - checkout
   124        - run: mkdir -p $GOPATH/src/github.com/tendermint
   125        - run: ln -sf /home/circleci/project $GOPATH/src/github.com/franono/tendermint
   126        - run: bash test/p2p/circleci.sh << parameters.ipv >>
   127        - store_artifacts:
   128            path: /home/circleci/project/test/p2p/logs
   129  
   130    upload_coverage:
   131      executor: golang
   132      steps:
   133        - attach_workspace:
   134            at: /tmp/workspace
   135        - restore_cache:
   136            name: "Restore source code cache"
   137            keys:
   138              - go-src-v1-{{ .Revision }}
   139        - checkout
   140        - restore_cache:
   141            name: "Restore go module cache"
   142            keys:
   143              - go-mod-v2-{{ checksum "go.sum" }}
   144        - run:
   145            name: gather
   146            command: |
   147              echo "mode: atomic" > coverage.txt
   148              for prof in $(ls /tmp/workspace/profiles/); do
   149                tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
   150              done
   151        - run:
   152            name: upload
   153            command: bash .circleci/codecov.sh -f coverage.txt
   154  
   155    deploy_docs:
   156      executor: docs
   157      steps:
   158        - checkout
   159        - run:
   160            name: "Build docs"
   161            command: make build-docs
   162        - run:
   163            name: "Sync to S3"
   164            command: make sync-docs
   165  
   166    prepare_build:
   167      executor: golang
   168      steps:
   169        - restore_cache:
   170            name: "Restore source code cache"
   171            keys:
   172              - go-src-v1-{{ .Revision }}
   173        - checkout
   174        - run:
   175            name: Get next release number
   176            command: |
   177              export LAST_TAG="`git describe --tags --abbrev=0 --match "${CIRCLE_BRANCH}.*"`"
   178              echo "Last tag: ${LAST_TAG}"
   179              if [ -z "${LAST_TAG}" ]; then
   180                export LAST_TAG="${CIRCLE_BRANCH}"
   181                echo "Last tag not found. Possibly fresh branch or feature branch. Setting ${LAST_TAG} as tag."
   182              fi
   183              export NEXT_TAG="`python -u scripts/release_management/bump-semver.py --version "${LAST_TAG}"`"
   184              echo "Next tag: ${NEXT_TAG}"
   185              echo "export CIRCLE_TAG=\"${NEXT_TAG}\"" > release-version.source
   186        - run:
   187            name: Build dependencies
   188            command: make tools
   189        - persist_to_workspace:
   190            root: .
   191            paths:
   192              - "release-version.source"
   193        - save_cache:
   194            key: v2-release-deps-{{ checksum "go.sum" }}
   195            paths:
   196              - "/go/pkg/mod"
   197  
   198    build_artifacts:
   199      executor: golang
   200      parallelism: 4
   201      steps:
   202        - restore_cache:
   203            name: "Restore source code cache"
   204            keys:
   205              - go-src-v1-{{ .Revision }}
   206        - checkout
   207        - restore_cache:
   208            name: "Restore release dependencies cache"
   209            keys:
   210              - v2-release-deps-{{ checksum "go.sum" }}
   211        - attach_workspace:
   212            at: /tmp/workspace
   213        - run:
   214            name: Build artifact
   215            command: |
   216              # Setting CIRCLE_TAG because we do not tag the release ourselves.
   217              source /tmp/workspace/release-version.source
   218              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
   219              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
   220              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
   221              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
   222        - persist_to_workspace:
   223            root: build
   224            paths:
   225              - "*.zip"
   226              - "tendermint_linux_amd64"
   227  
   228    release_artifacts:
   229      executor: golang
   230      steps:
   231        - restore_cache:
   232            name: "Restore source code cache"
   233            keys:
   234              - go-src-v1-{{ .Revision }}
   235        - checkout
   236        - attach_workspace:
   237            at: /tmp/workspace
   238        - run:
   239            name: "Deploy to GitHub"
   240            command: |
   241              # Setting CIRCLE_TAG because we do not tag the release ourselves.
   242              source /tmp/workspace/release-version.source
   243              echo "---"
   244              ls -la /tmp/workspace/*.zip
   245              echo "---"
   246              python -u scripts/release_management/sha-files.py
   247              echo "---"
   248              cat /tmp/workspace/SHA256SUMS
   249              echo "---"
   250              export RELEASE_ID="`python -u scripts/release_management/github-draft.py`"
   251              echo "Release ID: ${RELEASE_ID}"
   252              #Todo: Parallelize uploads
   253              export GOOS=linux GOARCH=amd64   && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
   254              export GOOS=darwin GOARCH=amd64  && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
   255              export GOOS=windows GOARCH=amd64 && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
   256              export GOOS=linux GOARCH=arm     && python -u scripts/release_management/github-upload.py --id "${RELEASE_ID}"
   257              python -u scripts/release_management/github-upload.py --file "/tmp/workspace/SHA256SUMS" --id "${RELEASE_ID}"
   258              python -u scripts/release_management/github-publish.py --id "${RELEASE_ID}"
   259  
   260    release_docker:
   261      machine:
   262        image: ubuntu-1604:201903-01
   263      steps:
   264        - checkout
   265        - attach_workspace:
   266            at: /tmp/workspace
   267        - run:
   268            name: "Deploy to Docker Hub"
   269            command: |
   270              # Setting CIRCLE_TAG because we do not tag the release ourselves.
   271              source /tmp/workspace/release-version.source
   272              cp /tmp/workspace/tendermint_linux_amd64 DOCKER/tendermint
   273              docker build --label="tendermint" --tag="franono/tendermint:${CIRCLE_TAG}" --tag="franono/tendermint:latest" "DOCKER"
   274              docker login -u "${DOCKERHUB_USER}" --password-stdin \<<< "${DOCKERHUB_PASS}"
   275              docker push "franono/tendermint"
   276              docker logout
   277  
   278    reproducible_builds:
   279      executor: golang
   280      steps:
   281        - attach_workspace:
   282            at: /tmp/workspace
   283        - checkout
   284        - setup_remote_docker:
   285            docker_layer_caching: true
   286        - run:
   287            name: Build tendermint
   288            no_output_timeout: 20m
   289            command: |
   290              sudo apt-get update
   291              sudo apt-get install -y ruby
   292              bash -x ./scripts/gitian-build.sh all
   293              for os in darwin linux windows; do
   294                cp gitian-build-${os}/result/tendermint-${os}-res.yml .
   295                cp gitian-build-${os}/build/out/tendermint-*.tar.gz .
   296                rm -rf gitian-build-${os}/
   297              done
   298        - store_artifacts:
   299            path: /go/src/github.com/franono/tendermint/tendermint-darwin-res.yml
   300        - store_artifacts:
   301            path: /go/src/github.com/franono/tendermint/tendermint-linux-res.yml
   302        - store_artifacts:
   303            path: /go/src/github.com/franono/tendermint/tendermint-windows-res.yml
   304        - store_artifacts:
   305            path: /go/src/github.com/franono/tendermint/tendermint-*.tar.gz
   306  
   307    # # Test RPC implementation against the swagger documented specs
   308    # contract_tests:
   309    #   working_directory: /home/circleci/.go_workspace/src/github.com/franono/tendermint
   310    #   machine:
   311    #     image: circleci/classic:latest
   312    #   environment:
   313    #     GOBIN: /home/circleci/.go_workspace/bin
   314    #     GOPATH: /home/circleci/.go_workspace/
   315    #     GOOS: linux
   316    #     GOARCH: amd64
   317    #   parallelism: 1
   318    #   steps:
   319    #     - checkout
   320    #     - run:
   321    #         name: Test RPC endpoints against swagger documentation
   322    #         command: |
   323    #           set -x
   324    #           export PATH=~/.local/bin:$PATH
   325    #           # install node and dredd
   326    #           ./scripts/get_nodejs.sh
   327    #           # build the binaries with a proper version of Go
   328    #           docker run --rm -v "$PWD":/go/src/github.com/franono/tendermint -w /go/src/github.com/franono/tendermint golang make build-linux build-contract-tests-hooks
   329    #           # This docker image works with go 1.7, we can install here the hook handler that contract-tests is going to use
   330    #           go get github.com/snikch/goodman/cmd/goodman
   331    #           make contract-tests
   332  
   333  workflows:
   334    version: 2
   335    test-suite:
   336      jobs:
   337        - deploy_docs:
   338            context: tendermint-docs
   339            filters:
   340              branches:
   341                only:
   342                  - master
   343              tags:
   344                only:
   345                  - /^v.*/
   346        - deploy_docs:
   347            context: tendermint-docs-staging
   348            filters:
   349              branches:
   350                only:
   351                  - docs-staging
   352        - setup_dependencies
   353        - test_cover:
   354            requires:
   355              - setup_dependencies
   356        - test_persistence:
   357            requires:
   358              - setup_dependencies
   359        - test_p2p
   360        - test_p2p:
   361            name: test_p2p_ipv6
   362            ipv: 6
   363        - upload_coverage:
   364            requires:
   365              - test_cover
   366        - reproducible_builds:
   367            filters:
   368              branches:
   369                only:
   370                  - master
   371                  - /v[0-9]+\.[0-9]+/
   372        # - contract_tests:
   373        #     requires:
   374        #       - setup_dependencies
   375  
   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]+/
   398                  - master