config.yml 7.02 KB
Newer Older
Jakub Sztandera's avatar
Jakub Sztandera committed
1
version: 2.0
Łukasz Magiera's avatar
Łukasz Magiera committed
2

Jakub Sztandera's avatar
Jakub Sztandera committed
3 4
aliases:
  make_out_dirs: &make_out_dirs
Łukasz Magiera's avatar
Łukasz Magiera committed
5
    run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_WORKSPACE $CIRCLE_TEST_REPORTS/{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
        - v4-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
        - v4-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-
        - v4-dep-{{ .Branch }}-
        - v4-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: v4-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}-{{ .Environment.CIRCLE_JOB }}
Jakub Sztandera's avatar
Jakub Sztandera committed
16 17 18 19 20
        paths:
          - ~/go/pkg/mod
          - ~/.cache/go-build/


Łukasz Magiera's avatar
Łukasz Magiera committed
21 22 23
defaults: &defaults
  working_directory: ~/ipfs/go-ipfs
  environment:
Jakub Sztandera's avatar
Jakub Sztandera committed
24 25
    GO111MODULE: "on"
    TEST_NO_DOCKER: 1
Jakub Sztandera's avatar
Jakub Sztandera committed
26
    TEST_NO_FUSE: 1
Jakub Sztandera's avatar
Jakub Sztandera committed
27
    GOPATH: /home/circleci/go
Łukasz Magiera's avatar
Łukasz Magiera committed
28 29 30 31
    CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
    CIRCLE: 1
    SERVICE: circle-ci
    CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
Łukasz Magiera's avatar
Łukasz Magiera committed
32
    CIRCLE_WORKSPACE: /tmp/circleci-workspace
Łukasz Magiera's avatar
Łukasz Magiera committed
33 34 35 36
    TEST_VERBOSE: 1
    TRAVIS: 1

jobs:
Steven Allen's avatar
Steven Allen committed
37
  gobuild:
Łukasz Magiera's avatar
Łukasz Magiera committed
38 39
    docker:
      - image: circleci/golang:1.12
Steven Allen's avatar
Steven Allen committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53
    <<: *defaults
    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
54 55
  golint:
    <<: *defaults
Łukasz Magiera's avatar
Łukasz Magiera committed
56 57
    docker:
      - image: circleci/golang:1.12
Steven Allen's avatar
Steven Allen committed
58 59 60 61 62 63 64
    steps:
    - checkout
    - *make_out_dirs
    - *restore_gomod
    - run: |
        make -O test_go_lint
    - *store_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
65
  gotest:
Łukasz Magiera's avatar
Łukasz Magiera committed
66 67
    docker:
      - image: circleci/golang:1.12
Łukasz Magiera's avatar
Łukasz Magiera committed
68 69 70
    <<: *defaults
    steps:
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
71 72
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
73

74
    - run: |
Jakub Sztandera's avatar
Jakub Sztandera committed
75
        make -j 1 test/unit/gotest.junit.xml \
76
        && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
Jakub Sztandera's avatar
Jakub Sztandera committed
77 78 79 80
    - run: 
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile

81 82
    - run:
        when: always
Jakub Sztandera's avatar
Jakub Sztandera committed
83 84 85 86
        command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
87 88 89 90 91 92 93 94
    - store_test_results:
        path: /tmp/circleci-test-results
    # Save artifacts
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results
  sharness:
Łukasz Magiera's avatar
Łukasz Magiera committed
95 96
    docker:
      - image: circleci/golang:1.12
Łukasz Magiera's avatar
Łukasz Magiera committed
97 98
    <<: *defaults
    steps:
Jakub Sztandera's avatar
Jakub Sztandera committed
99
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
100
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
101 102
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
103

104
    - 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
105

Jakub Sztandera's avatar
Jakub Sztandera committed
106 107 108
    - run:
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
109

Jakub Sztandera's avatar
Jakub Sztandera committed
110
    - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness
111
    # make sure we fail if there are test failures
Jakub Sztandera's avatar
Jakub Sztandera committed
112 113 114 115
    - 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
116 117 118 119 120 121 122
    - 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
123
  build:
Łukasz Magiera's avatar
Łukasz Magiera committed
124 125 126 127 128 129 130
    docker:
      - image: circleci/golang:1.12
    <<: *defaults
    steps:
      - checkout
      - *make_out_dirs
      - *restore_gomod
Steven Allen's avatar
Steven Allen committed
131 132 133 134 135 136 137 138
      - 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
139 140 141
      - persist_to_workspace:
          root: /tmp/circleci-workspace
          paths:
Steven Allen's avatar
Steven Allen committed
142
            - bin/ipfs
Łukasz Magiera's avatar
Łukasz Magiera committed
143 144 145 146 147 148 149 150 151 152
      - *store_gomod
  interop:
    docker:
      - image: circleci/node:10
    <<: *defaults
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run: git clone https://github.com/ipfs/interop.git
Steven Allen's avatar
Steven Allen committed
153 154 155 156
      - restore_cache:
          keys:
            - v1-interop-{{ checksum "~/ipfs/go-ipfs/interop/package-lock.json" }}
            - v1-interop-
Łukasz Magiera's avatar
Łukasz Magiera committed
157 158 159 160
      - run:
          command: npm install
          working_directory: ~/ipfs/go-ipfs/interop
          environment:
Steven Allen's avatar
Steven Allen committed
161
            IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
Steven Allen's avatar
Steven Allen committed
162 163 164 165
      - save_cache:
          key: v1-interop-{{ checksum "~/ipfs/go-ipfs/interop/package-lock.json" }}
          paths:
            - ~/ipfs/go-ipfs/interop/node_modules
Łukasz Magiera's avatar
Łukasz Magiera committed
166 167 168 169
      - run:
          command: npm test
          working_directory: ~/ipfs/go-ipfs/interop
          environment:
Steven Allen's avatar
Steven Allen committed
170 171 172 173 174 175 176 177 178 179
            IPFS_GO_EXEC: /tmp/circleci-workspace/bin/ipfs
  go-ipfs-api:
    docker:
      - image: circleci/golang:1.12
    <<: *defaults
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
180 181 182 183
          name: Cloning
          command: git clone https://github.com/ipfs/go-ipfs-api.git
      - run:
          name: Starting the daemon
Steven Allen's avatar
Steven Allen committed
184 185 186 187 188 189 190 191 192
          command: /tmp/circleci-workspace/bin/ipfs daemon --init --enable-namesys-pubsub
          background: true
      - run:
          name: Waiting for the daemon
          no_output_timeout: 10s
          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
193 194 195 196
      - 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
197 198 199
      - run:
          command: go test -v ./...
          working_directory: ~/ipfs/go-ipfs/go-ipfs-api
Steven Allen's avatar
Steven Allen committed
200 201 202 203 204 205 206 207
      - 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
208 209 210 211 212 213 214 215 216
  go-ipfs-http-client:
    docker:
      - image: circleci/golang:1.12
    <<: *defaults
    steps:
      - *make_out_dirs
      - attach_workspace:
          at: /tmp/circleci-workspace
      - run:
Steven Allen's avatar
Steven Allen committed
217 218 219 220 221 222 223 224
          name: Cloning
          command: git clone https://github.com/ipfs/go-ipfs-http-client.git
      - 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
225 226 227 228
          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
229 230 231 232 233
      - save_cache:
          key: v1-http-client-{{ checksum "~/ipfs/go-ipfs/go-ipfs-http-client/go.sum" }}
          paths:
            - ~/go/pkg/mod
            - ~/.cache/go-build/
Łukasz Magiera's avatar
Łukasz Magiera committed
234 235 236 237
workflows:
  version: 2
  test:
    jobs:
Steven Allen's avatar
Steven Allen committed
238
    - gobuild
Steven Allen's avatar
Steven Allen committed
239
    - golint
Łukasz Magiera's avatar
Łukasz Magiera committed
240 241
    - gotest
    - sharness
Steven Allen's avatar
Steven Allen committed
242
    - build
Łukasz Magiera's avatar
Łukasz Magiera committed
243 244
    - interop:
        requires:
Steven Allen's avatar
Steven Allen committed
245 246 247 248 249 250 251
          - build
    - go-ipfs-api:
        requires:
          - build
    - go-ipfs-http-client:
        requires:
          - build