config.yml 9.42 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 19
        paths:
          - ~/go/pkg/mod
          - ~/.cache/go-build/

Steven Allen's avatar
Steven Allen committed
20 21 22 23 24 25 26
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
27

Steven Allen's avatar
Steven Allen committed
28 29 30
executors:
  golang:
    docker:
Steven Allen's avatar
Steven Allen committed
31
      - image: circleci/golang:1.13
Steven Allen's avatar
Steven Allen committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45
    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:
      - image: circleci/node:10
    working_directory: ~/ipfs/go-ipfs
    environment:
      <<: *default_environment
46 47
  node-browsers:
    docker:
48
      - image: circleci/node:12-browsers
49 50 51 52 53 54 55
    working_directory: ~/ipfs/go-ipfs
    environment:
      <<: *default_environment
      NO_SANDBOX: true
      IPFS_REUSEPORT: false
      LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
      E2E_IPFSD_TYPE: go
Łukasz Magiera's avatar
Łukasz Magiera committed
56 57

jobs:
Steven Allen's avatar
Steven Allen committed
58
  gobuild:
Steven Allen's avatar
Steven Allen committed
59
    executor: golang
Steven Allen's avatar
Steven Allen committed
60 61 62 63 64 65 66 67 68 69 70 71 72
    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
73
  golint:
Steven Allen's avatar
Steven Allen committed
74
    executor: golang
Steven Allen's avatar
Steven Allen committed
75 76 77 78 79 80 81
    steps:
    - checkout
    - *make_out_dirs
    - *restore_gomod
    - run: |
        make -O test_go_lint
    - *store_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
82
  gotest:
Steven Allen's avatar
Steven Allen committed
83
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
84 85
    steps:
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
86 87
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
88

89
    - run: |
Jakub Sztandera's avatar
Jakub Sztandera committed
90
        make -j 1 test/unit/gotest.junit.xml \
91
        && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
Jakub Sztandera's avatar
Jakub Sztandera committed
92 93 94 95
    - run: 
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile

96 97
    - run:
        when: always
Jakub Sztandera's avatar
Jakub Sztandera committed
98 99 100 101
        command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
102 103 104 105 106 107 108 109
    - 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
110
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
111
    steps:
Jakub Sztandera's avatar
Jakub Sztandera committed
112
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
113
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
114 115
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
116

117
    - 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
118

Jakub Sztandera's avatar
Jakub Sztandera committed
119 120 121
    - run:
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
122

Jakub Sztandera's avatar
Jakub Sztandera committed
123
    - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness
124
    # make sure we fail if there are test failures
Jakub Sztandera's avatar
Jakub Sztandera committed
125 126 127 128
    - 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
129 130 131 132 133 134 135
    - 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
136
  build:
Steven Allen's avatar
Steven Allen committed
137
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
138 139 140 141
    steps:
      - checkout
      - *make_out_dirs
      - *restore_gomod
Steven Allen's avatar
Steven Allen committed
142 143 144 145 146 147 148 149
      - 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
150 151 152
      - persist_to_workspace:
          root: /tmp/circleci-workspace
          paths:
Steven Allen's avatar
Steven Allen committed
153
            - bin/ipfs
Łukasz Magiera's avatar
Łukasz Magiera committed
154 155
      - *store_gomod
  interop:
Steven Allen's avatar
Steven Allen committed
156
    executor: node
Steven Allen's avatar
Steven Allen committed
157
    parallelism: 4
Łukasz Magiera's avatar
Łukasz Magiera committed
158 159 160 161
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
Steven Allen's avatar
Steven Allen committed
162 163 164 165 166
      - run:
          name: Cloning
          command: |
            git clone https://github.com/ipfs/interop.git
            git -C interop log -1
Steven Allen's avatar
Steven Allen committed
167 168
      - restore_cache:
          keys:
Steven Allen's avatar
Steven Allen committed
169 170
            - v2-interop-{{ checksum "~/ipfs/go-ipfs/interop/package-lock.json" }}
            - v2-interop-
Łukasz Magiera's avatar
Łukasz Magiera committed
171
      - run:
172 173 174
          name: Installing dependencies
          command: |
            npm install
Łukasz Magiera's avatar
Łukasz Magiera committed
175
          working_directory: ~/ipfs/go-ipfs/interop
Steven Allen's avatar
Steven Allen committed
176
      - save_cache:
Steven Allen's avatar
Steven Allen committed
177
          key: v2-interop-{{ checksum "~/ipfs/go-ipfs/interop/package-lock.json" }}
Steven Allen's avatar
Steven Allen committed
178 179
          paths:
            - ~/ipfs/go-ipfs/interop/node_modules
180 181 182
      - run:
          name: Installing reporting tools
          command: |
Steven Allen's avatar
Steven Allen committed
183
            npm install --save-dev mocha-junit-reporter@1.23.1 mocha-multi-reporters@1.1.0
184
          working_directory: ~/ipfs/go-ipfs/interop
Łukasz Magiera's avatar
Łukasz Magiera committed
185
      - run:
186 187 188 189
          name: Running tests
          command: |
            mkdir -p /tmp/test-results/interop/
            export MOCHA_FILE="$(mktemp /tmp/test-results/interop/unit.XXXXXX.xml)"
190
            echo '{"reporterEnabled": "mocha-junit-reporter, spec"}' > mocha-conf.json
Steven Allen's avatar
Steven Allen committed
191 192
            node_modules/.bin/mocha -R mocha-multi-reporters --reporter-options "configFile=mocha-conf.json" \
              $(sed -n -e "s|^require('\(.*\)')$|test/\1|p" test/node.js | circleci tests split)
Łukasz Magiera's avatar
Łukasz Magiera committed
193
          working_directory: ~/ipfs/go-ipfs/interop
194 195
          environment:
            IPFS_REUSEPORT: false
196
            LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
Steven Allen's avatar
Steven Allen committed
197
            IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
198 199
      - store_test_results:
          path: /tmp/test-results
Steven Allen's avatar
Steven Allen committed
200
  go-ipfs-api:
Steven Allen's avatar
Steven Allen committed
201
    executor: golang
Steven Allen's avatar
Steven Allen committed
202 203 204 205 206
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
207
          name: Cloning
Steven Allen's avatar
Steven Allen committed
208 209 210
          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
211 212
      - run:
          name: Starting the daemon
Steven Allen's avatar
Steven Allen committed
213 214 215 216
          command: /tmp/circleci-workspace/bin/ipfs daemon --init --enable-namesys-pubsub
          background: true
      - run:
          name: Waiting for the daemon
217
          no_output_timeout: 30s
Steven Allen's avatar
Steven Allen committed
218 219 220 221
          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
222 223 224 225
      - 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
226 227 228
      - run:
          command: go test -v ./...
          working_directory: ~/ipfs/go-ipfs/go-ipfs-api
Steven Allen's avatar
Steven Allen committed
229 230 231 232 233 234 235 236
      - 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
237
  go-ipfs-http-client:
Steven Allen's avatar
Steven Allen committed
238
    executor: golang
Steven Allen's avatar
Steven Allen committed
239 240 241 242 243
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
244
          name: Cloning
Steven Allen's avatar
Steven Allen committed
245 246 247
          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
248 249 250 251 252 253
      - 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
254 255 256 257
          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
258 259 260 261 262
      - save_cache:
          key: v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }}
          paths:
            - ~/go/pkg/mod
            - ~/.cache/go-build/
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 292 293 294 295 296 297
  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
Łukasz Magiera's avatar
Łukasz Magiera committed
298 299 300 301
workflows:
  version: 2
  test:
    jobs:
Steven Allen's avatar
Steven Allen committed
302
    - gobuild
Steven Allen's avatar
Steven Allen committed
303
    - golint
Łukasz Magiera's avatar
Łukasz Magiera committed
304 305
    - gotest
    - sharness
Steven Allen's avatar
Steven Allen committed
306
    - build
Łukasz Magiera's avatar
Łukasz Magiera committed
307 308
    - interop:
        requires:
Steven Allen's avatar
Steven Allen committed
309 310 311 312 313 314 315
          - build
    - go-ipfs-api:
        requires:
          - build
    - go-ipfs-http-client:
        requires:
          - build
316 317 318
    - ipfs-webui:
        requires:
          - build