aboutsummaryrefslogtreecommitdiffstats
path: root/.circleci/config.yml
blob: 08ff726ece7b04e6b9644a809c5a43a015749aeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
version: 2.1
commands:
  init_workspace:
    steps:
      - run:
          name: Install Dependency Libraries
          command: |
            sudo apt update
            sudo apt-get install openssl libssl-dev libgmp-dev
      - run:
          name: "Prepare Workspace"
          command: sudo chown -R `whoami` /go
      - attach_workspace:
          at: /go
  run_test:
    steps:
      - run:
          name: "Running Test"
          no_output_timeout: 900
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              make test
            elif [ "${CIRCLE_BRANCH}" == "single-chain" ]; then
              make test
            else
              make test-short
            fi
  install_npm:
    steps:
      - run:
          name: Install npm
          command: |
            curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
            sudo apt-get install -y nodejs

executors:
  go1_11:
    docker:
      - image: circleci/golang:1.11
    working_directory: /go/src/github.com/dexon-foundation/dexon-consensus

jobs:
  dep:
    executor: go1_11
    steps:
      - init_workspace
      - checkout
      - restore_cache:
          keys:
            - v1-Gopkg.lock-{{ .Branch }}-{{ checksum "Gopkg.toml" }}
      - restore_cache:
          keys:
            - v1-vendor-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
      - run: bin/install_tools.sh
      - run: dep ensure
      - save_cache:
          key: v1-Gopkg.lock-{{ .Branch }}-{{ checksum "Gopkg.toml" }}
          paths:
            - Gopkg.lock
      - save_cache:
          key: v1-vendor-{{ .Branch }}-{{ checksum "Gopkg.lock" }}
          paths:
            - vendor
      - run: make dep
      - persist_to_workspace:
          root: /go
          paths:
            - src
            - bin
  lint:
    executor: go1_11
    steps:
      - init_workspace
      - run: make check-format
      - run: make lint
      - run: make vet

  security:
    executor: go1_11
    steps:
      - init_workspace
      - run: make check-security

  unit_test:
    executor: go1_11
    environment: 
      GOCACHE: "off"
      NO_INTEGRATION_TEST: true
    steps:
      - init_workspace
      - run_test

  integration_test:
    executor: go1_11
    environment: 
      ONLY_INTEGRATION_TEST: true
      NO_TEST_RACE: true
    steps:
      - init_workspace
      - run_test

  build:
    executor: go1_11
    steps:
      - init_workspace
      - run: make

  snyk:
    executor: go1_11
    steps:
      - init_workspace
      - install_npm
      - run: sudo npm install -g snyk
      - run: snyk auth $SNYK_APIKEY_JHU
      - run: snyk monitor --org=dexon-foundation --project=dexon-consensus

workflows:
  version: 2.1

  nightly:
    jobs:
      - dep
      - snyk:
          requires:
            - dep
    triggers:
      - schedule:
          cron: "0 8 * * *"
          filters:
            branches:
              only:
                - master
                - single-chain

  test_and_build:
    jobs:
      - dep
      - lint:
          requires:
            - dep
      - security:
          requires:
            - dep
      - unit_test:
          requires:
            - security
            - lint
      - integration_test:
          requires:
            - security
            - lint
      - build:
          requires:
            - unit_test
            - integration_test