config.yml 4.42 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
Łukasz Magiera's avatar
Łukasz Magiera committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
  build-interop:
    docker:
      - image: circleci/golang:1.12
    <<: *defaults
    steps:
      - checkout
      - *make_out_dirs
      - *restore_gomod
      - run: make build
      - run: cp cmd/ipfs/ipfs /tmp/circleci-workspace
      - persist_to_workspace:
          root: /tmp/circleci-workspace
          paths:
            - ipfs
      - *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
      - run:
          command: npm install
          working_directory: ~/ipfs/go-ipfs/interop
          environment:
            IPFS_GO_EXEC: /tmp/circleci-workspace/ipfs
      - run:
          command: npm test
          working_directory: ~/ipfs/go-ipfs/interop
          environment:
            IPFS_GO_EXEC: /tmp/circleci-workspace/ipfs

Łukasz Magiera's avatar
Łukasz Magiera committed
158 159 160 161 162

workflows:
  version: 2
  test:
    jobs:
Steven Allen's avatar
Steven Allen committed
163
    - gobuild
Steven Allen's avatar
Steven Allen committed
164
    - golint
Łukasz Magiera's avatar
Łukasz Magiera committed
165 166
    - gotest
    - sharness
Łukasz Magiera's avatar
Łukasz Magiera committed
167 168 169 170
    - build-interop
    - interop:
        requires:
          - build-interop