config.yml 7.03 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
        - 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
        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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
executors:
  golang:
    docker:
      - image: circleci/golang:1.12
    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
Łukasz Magiera's avatar
Łukasz Magiera committed
46 47

jobs:
Steven Allen's avatar
Steven Allen committed
48
  gobuild:
Steven Allen's avatar
Steven Allen committed
49
    executor: golang
Steven Allen's avatar
Steven Allen committed
50 51 52 53 54 55 56 57 58 59 60 61 62
    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
63
  golint:
Steven Allen's avatar
Steven Allen committed
64
    executor: golang
Steven Allen's avatar
Steven Allen committed
65 66 67 68 69 70 71
    steps:
    - checkout
    - *make_out_dirs
    - *restore_gomod
    - run: |
        make -O test_go_lint
    - *store_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
72
  gotest:
Steven Allen's avatar
Steven Allen committed
73
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
74 75
    steps:
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
76 77
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
78

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

86 87
    - run:
        when: always
Jakub Sztandera's avatar
Jakub Sztandera committed
88 89 90 91
        command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
92 93 94 95 96 97 98 99
    - 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
100
    executor: golang
Łukasz Magiera's avatar
Łukasz Magiera committed
101
    steps:
Jakub Sztandera's avatar
Jakub Sztandera committed
102
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
103
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
104 105
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
106

107
    - 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
108

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

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