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

defaults: &defaults
  working_directory: ~/ipfs/go-ipfs
  environment:
Jakub Sztandera's avatar
Jakub Sztandera committed
6
    GO111MODULE: "on"
Łukasz Magiera's avatar
Łukasz Magiera committed
7
    TEST_NO_FUSE: 1
Jakub Sztandera's avatar
Jakub Sztandera committed
8 9
    TEST_NO_DOCKER: 1
    GOPATH: /home/circleci/.go_workspace
Łukasz Magiera's avatar
Łukasz Magiera committed
10 11 12 13 14 15 16 17 18 19
    CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
    CIRCLE: 1
    SERVICE: circle-ci
    TEST_NO_DOCKER: 1
    CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
    TEST_VERBOSE: 1
    TRAVIS: 1
    IMPORT_PATH: github.com/ipfs/go-ipfs

  docker:
Jakub Sztandera's avatar
Jakub Sztandera committed
20
    - image: circleci/golang:1.11
Łukasz Magiera's avatar
Łukasz Magiera committed
21 22 23 24 25 26 27 28 29

jobs:
  gotest:
    <<: *defaults
    steps:
    - checkout
    - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
    - restore_cache:
        keys:
Jakub Sztandera's avatar
Jakub Sztandera committed
30 31
        - v2-dep-{{ .Branch }}-
        - v2-dep-master-
Łukasz Magiera's avatar
Łukasz Magiera committed
32 33 34 35

    - run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH"
    - run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH"
    - run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH"
36
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && go mod download
Łukasz Magiera's avatar
Łukasz Magiera committed
37 38

    - save_cache:
39
        key: v2-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}
Łukasz Magiera's avatar
Łukasz Magiera committed
40
        paths:
41
        - ~/.go_workspace/pkg/mod
Łukasz Magiera's avatar
Łukasz Magiera committed
42 43 44


    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov
45 46 47 48
    - run: |
        cd "$HOME/.go_workspace/src/$IMPORT_PATH" \
        && make -j 1 test/unit/gotest.junit.xml \
        && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
Łukasz Magiera's avatar
Łukasz Magiera committed
49
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF unittests -X search -f coverage/unit_tests.coverprofile
50 51 52
    - run:
        when: always
        command: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/unit/gotest.junit.xml" /tmp/circleci-test-results
Łukasz Magiera's avatar
Łukasz Magiera committed
53 54 55 56 57 58 59 60 61 62
    - 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
63
    - run: sudo apt install socat
Łukasz Magiera's avatar
Łukasz Magiera committed
64 65 66 67
    - checkout
    - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
    - restore_cache:
        keys:
Jakub Sztandera's avatar
Jakub Sztandera committed
68 69
        - v2-dep-{{ .Branch }}-
        - v2-dep-master-
Łukasz Magiera's avatar
Łukasz Magiera committed
70 71 72 73

    - run: rm -rf "$HOME/.go_workspace/src/$IMPORT_PATH"
    - run: mkdir -p "$HOME/.go_workspace/src/$IMPORT_PATH"
    - run: cp -aT . "$HOME/.go_workspace/src/$IMPORT_PATH"
74
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && go mod download
Łukasz Magiera's avatar
Łukasz Magiera committed
75 76

    - save_cache:
77
        key: v2-dep-{{ .Branch }}-{{ checksum "~/ipfs/go-ipfs/go.sum" }}
Łukasz Magiera's avatar
Łukasz Magiera committed
78
        paths:
79
        - ~/.go_workspace/pkg/mod
Łukasz Magiera's avatar
Łukasz Magiera committed
80 81

    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && curl -s https://codecov.io/bash > codecov
82
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && make -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
83
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && bash codecov -cF sharness -X search -f coverage/sharness_tests.coverprofile
84 85 86 87
    - run: mv "$HOME/.go_workspace/src/${IMPORT_PATH}/test/sharness/test-results/sharness.xml" /tmp/circleci-test-results

    # make sure we fail if there are test failures
    - run: cd "$HOME/.go_workspace/src/$IMPORT_PATH" && ls test/sharness/test-results/t*-*.sh.*.counts | test/sharness/lib/sharness/aggregate-results.sh | grep 'failed\s*0'
Łukasz Magiera's avatar
Łukasz Magiera committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
    - 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:
    - gotest
    - sharness