|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +executors: |
| 4 | + golang: |
| 5 | + docker: |
| 6 | + - image: circleci/golang:1.17 |
| 7 | + working_directory: /go/src/github.com/MeMeCosmos/meme |
| 8 | + |
| 9 | +commands: |
| 10 | + make: |
| 11 | + parameters: |
| 12 | + description: |
| 13 | + type: string |
| 14 | + target: |
| 15 | + type: string |
| 16 | + steps: |
| 17 | + - attach_workspace: |
| 18 | + at: /tmp/bin |
| 19 | + - restore_cache: |
| 20 | + name: "Restore source code cache" |
| 21 | + keys: |
| 22 | + - go-src-v1-{{ .Revision }} |
| 23 | + - checkout |
| 24 | + - restore_cache: |
| 25 | + name: "Restore go modules cache" |
| 26 | + keys: |
| 27 | + - go-mod-v1-{{ checksum "go.sum" }} |
| 28 | + - run: |
| 29 | + name: << parameters.description >> |
| 30 | + command: | |
| 31 | + export BINDIR=/tmp/bin |
| 32 | + make << parameters.target >> |
| 33 | +
|
| 34 | +jobs: |
| 35 | + setup-dependencies: |
| 36 | + executor: golang |
| 37 | + steps: |
| 38 | + - checkout |
| 39 | + - restore_cache: |
| 40 | + name: "Restore go modules cache" |
| 41 | + keys: |
| 42 | + - go-mod-v1-{{ checksum "go.sum" }} |
| 43 | + - run: |
| 44 | + name: Cache go modules |
| 45 | + command: make go-mod-cache |
| 46 | + - run: |
| 47 | + name: Build |
| 48 | + command: make build |
| 49 | + - run: |
| 50 | + name: "Git garbage collection" |
| 51 | + command: git gc |
| 52 | + - save_cache: |
| 53 | + name: "Save go modules cache" |
| 54 | + key: go-mod-v1-{{ checksum "go.sum" }} |
| 55 | + paths: |
| 56 | + - "/go/pkg/mod" |
| 57 | + - save_cache: |
| 58 | + name: "Save source code cache" |
| 59 | + key: go-src-v1-{{ .Revision }} |
| 60 | + paths: |
| 61 | + - ".git" |
| 62 | + |
| 63 | + lint: |
| 64 | + docker: |
| 65 | + - image: golangci/golangci-lint:v1.43.0 |
| 66 | + steps: |
| 67 | + - checkout |
| 68 | + - run: |
| 69 | + name: Lint |
| 70 | + command: | |
| 71 | + golangci-lint run --version |
| 72 | + golangci-lint run --tests=false --timeout=5m0s |
| 73 | +
|
| 74 | + test-cover: |
| 75 | + executor: golang |
| 76 | + parallelism: 4 |
| 77 | + steps: |
| 78 | + - checkout |
| 79 | + - restore_cache: |
| 80 | + keys: |
| 81 | + - go-mod-v1-{{ checksum "go.sum" }} |
| 82 | + - run: |
| 83 | + name: Run tests with coverage |
| 84 | + command: | |
| 85 | + export GORACE=halt_on_error=1 |
| 86 | + export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')" |
| 87 | + export GO111MODULE=on |
| 88 | + mkdir -p /tmp/logs /tmp/workspace/profiles |
| 89 | + for pkg in $(go list ./... | grep -v '/simulation' | circleci tests split); do |
| 90 | + id=$(echo "$pkg" | sed 's|[/.]|_|g') |
| 91 | + go test -mod=readonly -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" | tee "/tmp/logs/$id-$RANDOM.log" |
| 92 | + done |
| 93 | + - persist_to_workspace: |
| 94 | + root: /tmp/workspace |
| 95 | + paths: |
| 96 | + - "profiles/*" |
| 97 | + - store_artifacts: |
| 98 | + path: /tmp/logs |
| 99 | + |
| 100 | + benchmark: |
| 101 | + executor: golang |
| 102 | + parallelism: 1 |
| 103 | + steps: |
| 104 | + - checkout |
| 105 | + - restore_cache: |
| 106 | + keys: |
| 107 | + - go-mod-v1-{{ checksum "go.sum" }} |
| 108 | + - run: |
| 109 | + name: Benchmarks for gas calculations |
| 110 | + command: | |
| 111 | + cd ./x/wasm/keeper |
| 112 | + go test -bench . |
| 113 | + - run: |
| 114 | + name: Benchmarks to compare with native modules |
| 115 | + command: | |
| 116 | + cd ./benchmarks |
| 117 | + go test -bench . |
| 118 | +
|
| 119 | + upload-coverage: |
| 120 | + executor: golang |
| 121 | + steps: |
| 122 | + - attach_workspace: |
| 123 | + at: /tmp/workspace |
| 124 | + - checkout |
| 125 | + - run: |
| 126 | + name: gather |
| 127 | + command: | |
| 128 | + set -ex |
| 129 | +
|
| 130 | + echo "--> Concatenating profiles:" |
| 131 | + ls /tmp/workspace/profiles/ |
| 132 | + echo "mode: atomic" > coverage.txt |
| 133 | + for prof in $(ls /tmp/workspace/profiles/); do |
| 134 | + tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt |
| 135 | + done |
| 136 | + - run: |
| 137 | + name: upload |
| 138 | + command: bash <(curl -s https://codecov.io/bash) -f coverage.txt |
| 139 | + |
| 140 | + docker-image: |
| 141 | + executor: golang |
| 142 | + steps: |
| 143 | + - attach_workspace: |
| 144 | + at: /tmp/workspace |
| 145 | + - checkout |
| 146 | + - setup_remote_docker: |
| 147 | + # >= v20.10 https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2 |
| 148 | + version: 20.10.11 |
| 149 | + - run: |
| 150 | + name: Build Docker artifact |
| 151 | + command: docker build --pull -t "cosmwasm/wasmd:${CIRCLE_SHA1}" . |
| 152 | + - run: |
| 153 | + name: Push application Docker image to docker hub |
| 154 | + command: | |
| 155 | + if [ "${CIRCLE_BRANCH}" = "master" ]; then |
| 156 | + docker tag "cosmwasm/wasmd:${CIRCLE_SHA1}" cosmwasm/wasmd:latest |
| 157 | + docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" |
| 158 | + docker push cosmwasm/wasmd:latest |
| 159 | + docker logout |
| 160 | + fi |
| 161 | +
|
| 162 | + docker-tagged: |
| 163 | + executor: golang |
| 164 | + steps: |
| 165 | + - attach_workspace: |
| 166 | + at: /tmp/workspace |
| 167 | + - checkout |
| 168 | + - setup_remote_docker: |
| 169 | + # >= v20.10 https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2 |
| 170 | + version: 20.10.11 |
| 171 | + - run: |
| 172 | + name: Build Docker artifact |
| 173 | + command: docker build --pull -t "cosmwasm/wasmd:${CIRCLE_TAG}" . |
| 174 | + - run: |
| 175 | + name: Push application Docker image to docker hub |
| 176 | + command: | |
| 177 | + docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" |
| 178 | + docker push "cosmwasm/wasmd:${CIRCLE_TAG}" |
| 179 | + docker logout |
| 180 | +
|
| 181 | +workflows: |
| 182 | + version: 2 |
| 183 | + test-suite: |
| 184 | + jobs: |
| 185 | + # this is now a slow process... let's only run on master |
| 186 | + - docker-image: |
| 187 | + requires: |
| 188 | + - setup-dependencies |
| 189 | + filters: |
| 190 | + branches: |
| 191 | + only: |
| 192 | + - master |
| 193 | + - docker-tagged: |
| 194 | + filters: |
| 195 | + tags: |
| 196 | + only: |
| 197 | + - /^v.*/ |
| 198 | + branches: |
| 199 | + ignore: |
| 200 | + - /.*/ |
| 201 | + requires: |
| 202 | + - setup-dependencies |
| 203 | + - setup-dependencies: |
| 204 | + # filters here are needed to enable this job also for tags |
| 205 | + filters: |
| 206 | + tags: |
| 207 | + only: |
| 208 | + - /^v.*/ |
| 209 | + - lint: |
| 210 | + requires: |
| 211 | + - setup-dependencies |
| 212 | + - test-cover: |
| 213 | + requires: |
| 214 | + - setup-dependencies |
| 215 | + - upload-coverage: |
| 216 | + requires: |
| 217 | + - test-cover |
| 218 | + - benchmark: |
| 219 | + requires: |
| 220 | + - test-cover |
0 commit comments