|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +parameters: |
| 4 | + resource_class: |
| 5 | + type: string |
| 6 | + default: medium |
| 7 | + make_jobs: |
| 8 | + type: string |
| 9 | + default: 3 |
| 10 | + |
| 11 | +aliases: |
| 12 | + make_out_dirs: &make_out_dirs |
| 13 | + run: mkdir -p /tmp/circleci-artifacts /tmp/circleci-workspace /tmp/circleci-test-results/{unit,sharness} |
| 14 | + restore_gomod: &restore_gomod |
| 15 | + restore_cache: |
| 16 | + keys: |
| 17 | + - v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }} |
| 18 | + - v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}- |
| 19 | + - v5-dep-{{ .Branch }}- |
| 20 | + - v5-dep-master- |
| 21 | + store_gomod: &store_gomod |
| 22 | + save_cache: |
| 23 | + key: v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }} |
| 24 | + paths: |
| 25 | + - ~/go/pkg/mod |
| 26 | + - ~/.cache/go-build/ |
| 27 | + |
| 28 | +default_environment: &default_environment |
| 29 | + SERVICE: circle-ci |
| 30 | + TRAVIS: 1 |
| 31 | + CIRCLE: 1 |
| 32 | + CIRCLE_TEST_REPORTS: /tmp/circleci-test-results |
| 33 | + CIRCLE_ARTIFACTS: /tmp/circleci-artifacts |
| 34 | + GIT_PAGER: cat |
| 35 | + |
| 36 | +executors: |
| 37 | + golang: |
| 38 | + docker: |
| 39 | + - image: cimg/go:1.16.7 |
| 40 | + working_directory: ~/ipfs/go-ipfs |
| 41 | + environment: |
| 42 | + <<: *default_environment |
| 43 | + TEST_NO_DOCKER: 1 |
| 44 | + TEST_NO_FUSE: 1 |
| 45 | + TEST_VERBOSE: 1 |
| 46 | + node: |
| 47 | + docker: |
| 48 | + - image: circleci/node:14 |
| 49 | + working_directory: ~/ipfs/go-ipfs |
| 50 | + environment: |
| 51 | + <<: *default_environment |
| 52 | + node-browsers: |
| 53 | + docker: |
| 54 | + - image: circleci/node:14-browsers |
| 55 | + working_directory: ~/ipfs/go-ipfs |
| 56 | + environment: |
| 57 | + <<: *default_environment |
| 58 | + NO_SANDBOX: true |
| 59 | + IPFS_REUSEPORT: false |
| 60 | + LIBP2P_ALLOW_WEAK_RSA_KEYS: 1 |
| 61 | + E2E_IPFSD_TYPE: go |
| 62 | + dockerizer: |
| 63 | + docker: |
| 64 | + - image: cimg/go:1.16.7 |
| 65 | + environment: |
| 66 | + IMAGE_NAME: ipfs/go-ipfs |
| 67 | + WIP_IMAGE_TAG: wip |
| 68 | + |
| 69 | +jobs: |
| 70 | + gobuild: |
| 71 | + executor: golang |
| 72 | + steps: |
| 73 | + - checkout |
| 74 | + - *make_out_dirs |
| 75 | + - *restore_gomod |
| 76 | + - run: |
| 77 | + command: make cmd/ipfs-try-build |
| 78 | + environment: |
| 79 | + TEST_NO_FUSE: 0 |
| 80 | + - run: |
| 81 | + command: make cmd/ipfs-try-build |
| 82 | + environment: |
| 83 | + TEST_NO_FUSE: 1 |
| 84 | + - *store_gomod |
| 85 | + golint: |
| 86 | + executor: golang |
| 87 | + steps: |
| 88 | + - checkout |
| 89 | + - *make_out_dirs |
| 90 | + - *restore_gomod |
| 91 | + - run: | |
| 92 | + make -O test_go_lint |
| 93 | + - *store_gomod |
| 94 | + gotest: |
| 95 | + executor: golang |
| 96 | + steps: |
| 97 | + - checkout |
| 98 | + - *make_out_dirs |
| 99 | + - *restore_gomod |
| 100 | + |
| 101 | + - run: | |
| 102 | + make -j 1 test/unit/gotest.junit.xml \ |
| 103 | + && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]] |
| 104 | + - run: |
| 105 | + when: always |
| 106 | + command: bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile |
| 107 | + - run: |
| 108 | + command: go test -v ./... |
| 109 | + working_directory: ~/ipfs/go-ipfs/docs/examples/go-ipfs-as-a-library |
| 110 | + |
| 111 | + - run: |
| 112 | + when: always |
| 113 | + command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit |
| 114 | + |
| 115 | + - *store_gomod |
| 116 | + |
| 117 | + - store_test_results: |
| 118 | + path: /tmp/circleci-test-results |
| 119 | + # Save artifacts |
| 120 | + - store_artifacts: |
| 121 | + path: /tmp/circleci-artifacts |
| 122 | + - store_artifacts: |
| 123 | + path: /tmp/circleci-test-results |
| 124 | + sharness: |
| 125 | + machine: |
| 126 | + image: ubuntu-2004:202010-01 |
| 127 | + resource_class: << pipeline.parameters.resource_class >> |
| 128 | + working_directory: ~/ipfs/go-ipfs |
| 129 | + environment: |
| 130 | + <<: *default_environment |
| 131 | + TEST_NO_DOCKER: 1 |
| 132 | + TEST_NO_FUSE: 1 |
| 133 | + TEST_VERBOSE: 1 |
| 134 | + steps: |
| 135 | + - run: sudo apt update |
| 136 | + - run: | |
| 137 | + mkdir ~/localgo && cd ~/localgo |
| 138 | + wget https://golang.org/dl/go1.16.7.linux-amd64.tar.gz |
| 139 | + tar xfz go1.16.7.linux-amd64.tar.gz |
| 140 | + echo "export PATH=$(pwd)/go/bin:\$PATH" >> ~/.bashrc |
| 141 | + - run: go version |
| 142 | + - run: sudo apt install socat net-tools |
| 143 | + - checkout |
| 144 | + |
| 145 | + - run: |
| 146 | + mkdir rb-pinning-service-api && |
| 147 | + cd rb-pinning-service-api && |
| 148 | + git init && |
| 149 | + git remote add origin https://github.com/ipfs-shipyard/rb-pinning-service-api.git && |
| 150 | + git fetch --depth 1 origin 773c3adbb421c551d2d89288abac3e01e1f7c3a8 && |
| 151 | + git checkout FETCH_HEAD |
| 152 | + - run: |
| 153 | + cd rb-pinning-service-api && |
| 154 | + docker-compose pull && |
| 155 | + docker-compose up -d |
| 156 | + |
| 157 | + - *make_out_dirs |
| 158 | + - *restore_gomod |
| 159 | + |
| 160 | + - run: |
| 161 | + name: Setup Environment Variables |
| 162 | + # we need the docker host IP; all ports exported by child containers can be accessed there. |
| 163 | + command: echo "export TEST_DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')" >> $BASH_ENV |
| 164 | + - run: |
| 165 | + echo TEST_DOCKER_HOST=$TEST_DOCKER_HOST && |
| 166 | + make -O -j << pipeline.parameters.make_jobs >> coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml TEST_GENERATE_JUNIT=1 CONTINUE_ON_S_FAILURE=1 TEST_DOCKER_HOST=$TEST_DOCKER_HOST |
| 167 | + - run: |
| 168 | + when: always |
| 169 | + command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile |
| 170 | + |
| 171 | + - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness |
| 172 | + # make sure we fail if there are test failures |
| 173 | + - run: find test/sharness/test-results -name 't*-*.sh.*.counts' | test/sharness/lib/sharness/aggregate-results.sh | grep 'failed\s*0' |
| 174 | + |
| 175 | + - *store_gomod |
| 176 | + |
| 177 | + - store_test_results: |
| 178 | + path: /tmp/circleci-test-results |
| 179 | + # Save artifacts |
| 180 | + - store_artifacts: |
| 181 | + path: /tmp/circleci-artifacts |
| 182 | + - store_artifacts: |
| 183 | + path: /tmp/circleci-test-results |
| 184 | + build: |
| 185 | + executor: golang |
| 186 | + steps: |
| 187 | + - checkout |
| 188 | + - *make_out_dirs |
| 189 | + - *restore_gomod |
| 190 | + - run: |
| 191 | + name: Building |
| 192 | + command: make build |
| 193 | + - run: |
| 194 | + name: Storing |
| 195 | + command: | |
| 196 | + mkdir -p /tmp/circleci-workspace/bin |
| 197 | + cp cmd/ipfs/ipfs /tmp/circleci-workspace/bin |
| 198 | + - persist_to_workspace: |
| 199 | + root: /tmp/circleci-workspace |
| 200 | + paths: |
| 201 | + - bin/ipfs |
| 202 | + - *store_gomod |
| 203 | + interop: |
| 204 | + executor: node |
| 205 | + parallelism: 4 |
| 206 | + steps: |
| 207 | + - *make_out_dirs |
| 208 | + - attach_workspace: |
| 209 | + at: /tmp/circleci-workspace |
| 210 | + - run: |
| 211 | + name: Installing dependencies |
| 212 | + command: | |
| 213 | + npm init -y |
| 214 | + npm install ipfs@^0.52.2 |
| 215 | + npm install ipfs-interop@^4.0.0 |
| 216 | + |
| 217 | + working_directory: ~/ipfs/go-ipfs/interop |
| 218 | + - run: |
| 219 | + name: Running tests |
| 220 | + command: | |
| 221 | + mkdir -p /tmp/test-results/interop/ |
| 222 | + export MOCHA_FILE="$(mktemp /tmp/test-results/interop/unit.XXXXXX.xml)" |
| 223 | + npx ipfs-interop -- -t node -f $(sed -n -e "s|^require('\(.*\)')$|test/\1|p" node_modules/ipfs-interop/test/node.js | circleci tests split) -- --reporter mocha-circleci-reporter |
| 224 | + working_directory: ~/ipfs/go-ipfs/interop |
| 225 | + environment: |
| 226 | + IPFS_REUSEPORT: false |
| 227 | + LIBP2P_ALLOW_WEAK_RSA_KEYS: 1 |
| 228 | + IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs |
| 229 | + - store_test_results: |
| 230 | + path: /tmp/test-results |
| 231 | + go-ipfs-api: |
| 232 | + executor: golang |
| 233 | + steps: |
| 234 | + - *make_out_dirs |
| 235 | + - attach_workspace: |
| 236 | + at: /tmp/circleci-workspace |
| 237 | + - run: |
| 238 | + name: Cloning |
| 239 | + command: | |
| 240 | + git clone https://github.com/ipfs/go-ipfs-api.git |
| 241 | + git -C go-ipfs-api log -1 |
| 242 | + - run: |
| 243 | + name: Starting the daemon |
| 244 | + command: /tmp/circleci-workspace/bin/ipfs daemon --init --enable-namesys-pubsub |
| 245 | + background: true |
| 246 | + - run: |
| 247 | + name: Waiting for the daemon |
| 248 | + no_output_timeout: 30s |
| 249 | + command: | |
| 250 | + while ! /tmp/circleci-workspace/bin/ipfs id --api=/ip4/127.0.0.1/tcp/5001 2>/dev/null; do |
| 251 | + sleep 1 |
| 252 | + done |
| 253 | + - restore_cache: |
| 254 | + keys: |
| 255 | + - v1-go-api-{{ checksum "~/ipfs/go-ipfs/go-ipfs-api/go.sum" }} |
| 256 | + - v1-go-api- |
| 257 | + - run: |
| 258 | + command: go test -v ./... |
| 259 | + working_directory: ~/ipfs/go-ipfs/go-ipfs-api |
| 260 | + - save_cache: |
| 261 | + key: v1-go-api-{{ checksum "~/ipfs/go-ipfs/go-ipfs-api/go.sum" }} |
| 262 | + paths: |
| 263 | + - ~/go/pkg/mod |
| 264 | + - ~/.cache/go-build/ |
| 265 | + - run: |
| 266 | + name: Stopping the daemon |
| 267 | + command: /tmp/circleci-workspace/bin/ipfs shutdown |
| 268 | + go-ipfs-http-client: |
| 269 | + executor: golang |
| 270 | + steps: |
| 271 | + - *make_out_dirs |
| 272 | + - attach_workspace: |
| 273 | + at: /tmp/circleci-workspace |
| 274 | + - run: |
| 275 | + name: Cloning |
| 276 | + command: | |
| 277 | + git clone https://github.com/ipfs/go-ipfs-http-client.git |
| 278 | + git -C go-ipfs-http-client log -1 |
| 279 | + - restore_cache: |
| 280 | + keys: |
| 281 | + - v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }} |
| 282 | + - v1-http-client- |
| 283 | + - run: |
| 284 | + name: go test -v ./... |
| 285 | + command: | |
| 286 | + export PATH=/tmp/circleci-workspace/bin:$PATH |
| 287 | + go test -v ./... |
| 288 | + working_directory: ~/ipfs/go-ipfs/go-ipfs-http-client |
| 289 | + - save_cache: |
| 290 | + key: v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }} |
| 291 | + paths: |
| 292 | + - ~/go/pkg/mod |
| 293 | + - ~/.cache/go-build/ |
| 294 | + ipfs-webui: |
| 295 | + executor: node-browsers |
| 296 | + steps: |
| 297 | + - *make_out_dirs |
| 298 | + - attach_workspace: |
| 299 | + at: /tmp/circleci-workspace |
| 300 | + - run: |
| 301 | + name: Cloning |
| 302 | + command: | |
| 303 | + git clone https://github.com/ipfs-shipyard/ipfs-webui.git |
| 304 | + git -C ipfs-webui log -1 |
| 305 | + - restore_cache: |
| 306 | + keys: |
| 307 | + - v1-ipfs-webui-{{ checksum "~/ipfs/go-ipfs/ipfs-webui/package-lock.json" }} |
| 308 | + - v1-ipfs-webui- |
| 309 | + - run: |
| 310 | + name: Installing dependencies |
| 311 | + command: | |
| 312 | + npm install |
| 313 | + working_directory: ~/ipfs/go-ipfs/ipfs-webui |
| 314 | + - run: |
| 315 | + name: Running upstream tests (finish early if they fail) |
| 316 | + command: | |
| 317 | + npm test || circleci-agent step halt |
| 318 | + working_directory: ~/ipfs/go-ipfs/ipfs-webui |
| 319 | + - run: |
| 320 | + name: Running tests with go-ipfs built from current commit |
| 321 | + command: npm test |
| 322 | + working_directory: ~/ipfs/go-ipfs/ipfs-webui |
| 323 | + environment: |
| 324 | + IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs |
| 325 | + - save_cache: |
| 326 | + key: v1-ipfs-webui-{{ checksum "~/ipfs/go-ipfs/ipfs-webui/package-lock.json" }} |
| 327 | + paths: |
| 328 | + - ~/ipfs/go-ipfs/ipfs-webui/node_modules |
| 329 | + # We only run build as a test here. DockerHub images are built and published |
| 330 | + # by Github Action now: https://github.com/ipfs/go-ipfs/pull/8467 |
| 331 | + docker-build: |
| 332 | + executor: dockerizer |
| 333 | + steps: |
| 334 | + - checkout |
| 335 | + - setup_remote_docker: |
| 336 | + version: "19.03.13" |
| 337 | + - run: |
| 338 | + name: Build Docker image |
| 339 | + command: | |
| 340 | + docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG . |
| 341 | +
|
| 342 | +workflows: |
| 343 | + version: 2 |
| 344 | + |
| 345 | + # Runs for all branches, but not on tags |
| 346 | + # see: https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag |
| 347 | + test: |
| 348 | + jobs: |
| 349 | + - gobuild |
| 350 | + - golint |
| 351 | + - gotest |
| 352 | + - sharness |
| 353 | + - build |
| 354 | + - interop: |
| 355 | + requires: |
| 356 | + - build |
| 357 | + - go-ipfs-api: |
| 358 | + requires: |
| 359 | + - build |
| 360 | + - go-ipfs-http-client: |
| 361 | + requires: |
| 362 | + - build |
| 363 | + - ipfs-webui: |
| 364 | + requires: |
| 365 | + - build |
| 366 | + - docker-build |
0 commit comments