config.yml 11.1 KB
Newer Older
Steven Allen's avatar
Steven Allen committed
1
version: 2.1
Łukasz Magiera's avatar
Łukasz Magiera committed
2

Jakub Sztandera's avatar
Jakub Sztandera committed
3 4
aliases:
  make_out_dirs: &make_out_dirs
Steven Allen's avatar
Steven Allen committed
5
    run: mkdir -p /tmp/circleci-artifacts /tmp/circleci-workspace /tmp/circleci-test-results/{unit,sharness}
Jakub Sztandera's avatar
Jakub Sztandera committed
6 7 8
  restore_gomod: &restore_gomod
    restore_cache:
      keys:
Steven Allen's avatar
Steven Allen committed
9 10 11 12
        - v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
        - v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-
        - v5-dep-{{ .Branch }}-
        - v5-dep-master-
Jakub Sztandera's avatar
Jakub Sztandera committed
13 14
  store_gomod: &store_gomod
      save_cache:
Steven Allen's avatar
Steven Allen committed
15
        key: v5-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
Jakub Sztandera's avatar
Jakub Sztandera committed
16 17 18
        paths:
          - ~/go/pkg/mod
          - ~/.cache/go-build/
19 20 21 22 23
  only-version-tags: &only-version-tags
    tags:
      only: /^v[0-9].*/
    branches:
      ignore: /.*/
Jakub Sztandera's avatar
Jakub Sztandera committed
24

Steven Allen's avatar
Steven Allen committed
25 26 27 28 29 30 31
default_environment: &default_environment
  SERVICE: circle-ci
  TRAVIS: 1
  CIRCLE: 1
  CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
  CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
  GIT_PAGER: cat
Jakub Sztandera's avatar
Jakub Sztandera committed
32

Steven Allen's avatar
Steven Allen committed
33 34 35
executors:
  golang:
    docker:
36
      - image: circleci/golang:1.14.4
Steven Allen's avatar
Steven Allen committed
37 38 39 40 41 42 43 44 45 46
    working_directory: ~/ipfs/go-ipfs
    environment:
      <<: *default_environment
      GO111MODULE: "on"
      TEST_NO_DOCKER: 1
      TEST_NO_FUSE: 1
      GOPATH: /home/circleci/go
      TEST_VERBOSE: 1
  node:
    docker:
47
      - image: circleci/node:12
Steven Allen's avatar
Steven Allen committed
48 49 50
    working_directory: ~/ipfs/go-ipfs
    environment:
      <<: *default_environment
51 52
  node-browsers:
    docker:
53
      - image: circleci/node:12-browsers
54 55 56 57 58 59 60
    working_directory: ~/ipfs/go-ipfs
    environment:
      <<: *default_environment
      NO_SANDBOX: true
      IPFS_REUSEPORT: false
      LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
      E2E_IPFSD_TYPE: go
61 62
  dockerizer:
    docker:
63
      - image: circleci/golang:1.14.4
Oli Evans's avatar
Oli Evans committed
64
    environment:
Oli Evans's avatar
Oli Evans committed
65
      IMAGE_NAME: ipfs/go-ipfs
Oli Evans's avatar
Oli Evans committed
66
      WIP_IMAGE_TAG: wip
Łukasz Magiera's avatar
Łukasz Magiera committed
67 68

jobs:
Steven Allen's avatar
Steven Allen committed
69
  gobuild:
Steven Allen's avatar
Steven Allen committed
70
    executor: golang
Steven Allen's avatar
Steven Allen committed
71 72 73 74 75 76 77 78 79 80 81 82 83
    steps:
    - checkout
    - *make_out_dirs
    - *restore_gomod
    - run:
        command: make cmd/ipfs-try-build
        environment:
          TEST_NO_FUSE: 0
    - run:
        command: make cmd/ipfs-try-build
        environment:
          TEST_NO_FUSE: 1
    - *store_gomod
Steven Allen's avatar
Steven Allen committed
84
  golint:
Steven Allen's avatar
Steven Allen committed
85
    executor: golang
Steven Allen's avatar
Steven Allen committed
86 87 88 89 90 91 92
    steps:
    - checkout
    - *make_out_dirs
    - *restore_gomod
    - run: |
        make -O test_go_lint
    - *store_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
93
  gotest:
Steven Allen's avatar
Steven Allen committed
94
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
95 96
    steps:
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
97 98
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
99

100
    - run: |
Jakub Sztandera's avatar
Jakub Sztandera committed
101
        make -j 1 test/unit/gotest.junit.xml \
102
        && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
103
    - run:
Jakub Sztandera's avatar
Jakub Sztandera committed
104 105 106
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile

107 108
    - run:
        when: always
Jakub Sztandera's avatar
Jakub Sztandera committed
109 110 111 112
        command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
113 114 115 116 117 118 119 120
    - store_test_results:
        path: /tmp/circleci-test-results
    # Save artifacts
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results
  sharness:
Steven Allen's avatar
Steven Allen committed
121
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
122
    steps:
Jakub Sztandera's avatar
Jakub Sztandera committed
123
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
124
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
125 126
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
127

128
    - run: make -O -j 10 coverage/sharness_tests.coverprofile test/sharness/test-results/sharness.xml TEST_GENERATE_JUNIT=1 CONTINUE_ON_S_FAILURE=1
Łukasz Magiera's avatar
Łukasz Magiera committed
129

Jakub Sztandera's avatar
Jakub Sztandera committed
130 131 132
    - run:
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
133

Jakub Sztandera's avatar
Jakub Sztandera committed
134
    - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness
135
    # make sure we fail if there are test failures
Jakub Sztandera's avatar
Jakub Sztandera committed
136 137 138 139
    - run: find test/sharness/test-results -name 't*-*.sh.*.counts' | test/sharness/lib/sharness/aggregate-results.sh | grep 'failed\s*0'

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
140 141 142 143 144 145 146
    - store_test_results:
        path: /tmp/circleci-test-results
    # Save artifacts
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results
Steven Allen's avatar
Steven Allen committed
147
  build:
Steven Allen's avatar
Steven Allen committed
148
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
149 150 151 152
    steps:
      - checkout
      - *make_out_dirs
      - *restore_gomod
Steven Allen's avatar
Steven Allen committed
153 154 155 156 157 158 159 160
      - run:
          name: Building
          command: make build
      - run:
          name: Storing
          command: |
            mkdir -p /tmp/circleci-workspace/bin
            cp cmd/ipfs/ipfs /tmp/circleci-workspace/bin
Łukasz Magiera's avatar
Łukasz Magiera committed
161 162 163
      - persist_to_workspace:
          root: /tmp/circleci-workspace
          paths:
Steven Allen's avatar
Steven Allen committed
164
            - bin/ipfs
Łukasz Magiera's avatar
Łukasz Magiera committed
165 166
      - *store_gomod
  interop:
Steven Allen's avatar
Steven Allen committed
167
    executor: node
Steven Allen's avatar
Steven Allen committed
168
    parallelism: 4
Łukasz Magiera's avatar
Łukasz Magiera committed
169 170 171 172 173
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
174 175
          name: Installing dependencies
          command: |
176
            npm init -y
177 178
            npm install ipfs@^0.48.1
            npm install ipfs-interop@^2.0.0
179
            npm install mocha-circleci-reporter@0.0.3
180
          working_directory: ~/ipfs/go-ipfs/interop
Łukasz Magiera's avatar
Łukasz Magiera committed
181
      - run:
182 183 184 185
          name: Running tests
          command: |
            mkdir -p /tmp/test-results/interop/
            export MOCHA_FILE="$(mktemp /tmp/test-results/interop/unit.XXXXXX.xml)"
186
            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
Łukasz Magiera's avatar
Łukasz Magiera committed
187
          working_directory: ~/ipfs/go-ipfs/interop
188 189
          environment:
            IPFS_REUSEPORT: false
190
            LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
Steven Allen's avatar
Steven Allen committed
191
            IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
192 193
      - store_test_results:
          path: /tmp/test-results
Steven Allen's avatar
Steven Allen committed
194
  go-ipfs-api:
Steven Allen's avatar
Steven Allen committed
195
    executor: golang
Steven Allen's avatar
Steven Allen committed
196 197 198 199 200
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
201
          name: Cloning
Steven Allen's avatar
Steven Allen committed
202 203 204
          command: |
            git clone https://github.com/ipfs/go-ipfs-api.git
            git -C go-ipfs-api log -1
Steven Allen's avatar
Steven Allen committed
205 206
      - run:
          name: Starting the daemon
Steven Allen's avatar
Steven Allen committed
207 208 209 210
          command: /tmp/circleci-workspace/bin/ipfs daemon --init --enable-namesys-pubsub
          background: true
      - run:
          name: Waiting for the daemon
211
          no_output_timeout: 30s
Steven Allen's avatar
Steven Allen committed
212 213 214 215
          command: |
            while ! /tmp/circleci-workspace/bin/ipfs id --api=/ip4/127.0.0.1/tcp/5001 2>/dev/null; do
              sleep 1
            done
Steven Allen's avatar
Steven Allen committed
216 217 218 219
      - restore_cache:
          keys:
            - v1-go-api-{{ checksum "~/ipfs/go-ipfs/go-ipfs-api/go.sum" }}
            - v1-go-api-
Steven Allen's avatar
Steven Allen committed
220 221 222
      - run:
          command: go test -v ./...
          working_directory: ~/ipfs/go-ipfs/go-ipfs-api
Steven Allen's avatar
Steven Allen committed
223 224 225 226 227 228 229 230
      - save_cache:
          key: v1-go-api-{{ checksum "~/ipfs/go-ipfs/go-ipfs-api/go.sum" }}
          paths:
            - ~/go/pkg/mod
            - ~/.cache/go-build/
      - run:
          name: Stopping the daemon
          command: /tmp/circleci-workspace/bin/ipfs shutdown
Steven Allen's avatar
Steven Allen committed
231
  go-ipfs-http-client:
Steven Allen's avatar
Steven Allen committed
232
    executor: golang
Steven Allen's avatar
Steven Allen committed
233 234 235 236 237
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
238
          name: Cloning
Steven Allen's avatar
Steven Allen committed
239 240 241
          command: |
            git clone https://github.com/ipfs/go-ipfs-http-client.git
            git -C go-ipfs-http-client log -1
Steven Allen's avatar
Steven Allen committed
242 243 244 245 246 247
      - restore_cache:
          keys:
            - v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }}
            - v1-http-client-
      - run:
          name: go test -v ./...
Steven Allen's avatar
Steven Allen committed
248 249 250 251
          command: |
            export PATH=/tmp/circleci-workspace/bin:$PATH
            go test -v ./...
          working_directory: ~/ipfs/go-ipfs/go-ipfs-http-client
Steven Allen's avatar
Steven Allen committed
252 253 254 255 256
      - save_cache:
          key: v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }}
          paths:
            - ~/go/pkg/mod
            - ~/.cache/go-build/
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
  ipfs-webui:
    executor: node-browsers
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
          name: Cloning
          command: |
            git clone https://github.com/ipfs-shipyard/ipfs-webui.git
            git -C ipfs-webui log -1
      - restore_cache:
          keys:
            - v1-ipfs-webui-{{ checksum "~/ipfs/go-ipfs/ipfs-webui/package-lock.json" }}
            - v1-ipfs-webui-
      - run:
          name: Installing dependencies
          command: |
            npm install
          working_directory: ~/ipfs/go-ipfs/ipfs-webui
      - run:
          name: Running upstream tests (finish early if they fail)
          command: |
            npm test || circleci-agent step halt
          working_directory: ~/ipfs/go-ipfs/ipfs-webui
      - run:
          name: Running tests with go-ipfs built from current commit
          command: npm test
          working_directory: ~/ipfs/go-ipfs/ipfs-webui
          environment:
            IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
      - save_cache:
          key: v1-ipfs-webui-{{ checksum "~/ipfs/go-ipfs/ipfs-webui/package-lock.json" }}
          paths:
            - ~/ipfs/go-ipfs/ipfs-webui/node_modules
Oli Evans's avatar
Oli Evans committed
292 293 294 295
  docker-build:
    executor: dockerizer
    steps:
      - checkout
296 297
      - setup_remote_docker:
          version: "18.09.3"
Oli Evans's avatar
Oli Evans committed
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
      - run:
          name: Build Docker image
          command: |
            docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
      - run:
          name: Archive Docker image
          command: docker save -o go-ipfs-image.tar $IMAGE_NAME
      - persist_to_workspace:
          root: .
          paths:
            - ./go-ipfs-image.tar
  docker-push:
    executor: dockerizer
    steps:
      - checkout
313 314
      - setup_remote_docker:
          version: "18.09.3"
Oli Evans's avatar
Oli Evans committed
315 316 317 318 319 320 321 322 323
      - attach_workspace:
          at: /tmp/workspace
      - run:
          name: Load archived Docker image
          command: docker load -i /tmp/workspace/go-ipfs-image.tar
      - run:
          name: Publish Docker Image to Docker Hub
          command: |
            echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
Oli Evans's avatar
Oli Evans committed
324
            ./bin/push-docker-tags.sh $(date -u +%F) "$CIRCLE_SHA1" "$CIRCLE_BRANCH" "$CIRCLE_TAG"
Oli Evans's avatar
Oli Evans committed
325

Łukasz Magiera's avatar
Łukasz Magiera committed
326 327
workflows:
  version: 2
Oli Evans's avatar
Oli Evans committed
328 329 330

  # Runs for all branches, but not on tags
  # see: https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
Łukasz Magiera's avatar
Łukasz Magiera committed
331 332
  test:
    jobs:
Steven Allen's avatar
Steven Allen committed
333
    - gobuild
Steven Allen's avatar
Steven Allen committed
334
    - golint
Łukasz Magiera's avatar
Łukasz Magiera committed
335 336
    - gotest
    - sharness
Steven Allen's avatar
Steven Allen committed
337
    - build
Łukasz Magiera's avatar
Łukasz Magiera committed
338 339
    - interop:
        requires:
Steven Allen's avatar
Steven Allen committed
340 341 342 343 344 345 346
          - build
    - go-ipfs-api:
        requires:
          - build
    - go-ipfs-http-client:
        requires:
          - build
347 348 349
    - ipfs-webui:
        requires:
          - build
Oli Evans's avatar
Oli Evans committed
350 351
    - docker-build
    - docker-push:
352 353
        # Requires dockerhub credentials, from circleci context.
        context: dockerhub
Oli Evans's avatar
Oli Evans committed
354
        requires:
355 356 357 358 359 360 361
          - docker-build
          - golint
          - gotest
          - sharness
          - interop
          - go-ipfs-api
          - go-ipfs-http-client
362
          - ipfs-webui
363 364
        filters:
          branches:
365
            only:
366 367
              - master
              - feat/stabilize-dht
Oli Evans's avatar
Oli Evans committed
368

369 370 371
  # NOTE: CircleCI only builds tags if you explicitly filter for them. That
  # also means tag-based jobs can only depend on other tag-based jobs, so we
  # use a separate workflow because every job needs to be tagged together.
Oli Evans's avatar
Oli Evans committed
372
  # see: https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
373
  docker-on-tag:
Oli Evans's avatar
Oli Evans committed
374 375
    jobs:
      - docker-build:
376
          filters: *only-version-tags
Oli Evans's avatar
Oli Evans committed
377
      - docker-push:
378
          context: dockerhub
379
          filters: *only-version-tags
Oli Evans's avatar
Oli Evans committed
380 381
          requires:
            - docker-build