config.yml 3.22 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 5 6 7 8
aliases:
  make_out_dirs: &make_out_dirs
    run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS/{unit,sharness}
  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 32 33 34 35
    CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
    CIRCLE: 1
    SERVICE: circle-ci
    CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
    TEST_VERBOSE: 1
    TRAVIS: 1

  docker:
Jakub Sztandera's avatar
Jakub Sztandera committed
36
    - image: circleci/golang:1.12
Łukasz Magiera's avatar
Łukasz Magiera committed
37 38

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

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

77 78
    - run:
        when: always
Jakub Sztandera's avatar
Jakub Sztandera committed
79 80 81 82
        command: mv "test/unit/gotest.junit.xml" /tmp/circleci-test-results/unit

    - *store_gomod

Łukasz Magiera's avatar
Łukasz Magiera committed
83 84 85 86 87 88 89 90 91 92
    - store_test_results:
        path: /tmp/circleci-test-results
    # Save artifacts
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results
  sharness:
    <<: *defaults
    steps:
Jakub Sztandera's avatar
Jakub Sztandera committed
93
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
94
    - checkout
Jakub Sztandera's avatar
Jakub Sztandera committed
95 96
    - *make_out_dirs
    - *restore_gomod
Łukasz Magiera's avatar
Łukasz Magiera committed
97

98
    - 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
99

Jakub Sztandera's avatar
Jakub Sztandera committed
100 101 102
    - run:
        when: always
        command: bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile
103

Jakub Sztandera's avatar
Jakub Sztandera committed
104
    - run: mv "test/sharness/test-results/sharness.xml" /tmp/circleci-test-results/sharness
105
    # make sure we fail if there are test failures
Jakub Sztandera's avatar
Jakub Sztandera committed
106 107 108 109
    - 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
110 111 112 113 114 115 116 117 118 119 120 121
    - store_test_results:
        path: /tmp/circleci-test-results
    # Save artifacts
    - store_artifacts:
        path: /tmp/circleci-artifacts
    - store_artifacts:
        path: /tmp/circleci-test-results

workflows:
  version: 2
  test:
    jobs:
Steven Allen's avatar
Steven Allen committed
122
    - gobuild
Steven Allen's avatar
Steven Allen committed
123
    - golint
Łukasz Magiera's avatar
Łukasz Magiera committed
124 125
    - gotest
    - sharness