config.yml 5.44 KB
Newer Older
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
version: 2.1
orbs:
  go: gotest/tools@0.0.9

executors:
  golang:
    docker:
      - image: circleci/golang:1.13
    resource_class: 2xlarge

commands:
  install-deps:
    steps:
      - go/install-ssh
      - go/install: {package: git}
  prepare:
    parameters:
      linux:
        default: true
        description: is a linux build environment?
        type: boolean
      darwin:
        default: false
        description: is a darwin build environment?
        type: boolean
    steps:
      - checkout
      - when:
          condition: << parameters.linux >>
          steps:
            - run: sudo apt-get update
            - run: sudo apt-get install ocl-icd-opencl-dev
      - run: git submodule sync
      - run: git submodule update --init
  download-params:
    steps:
      - run:
          command: |
            cat go.mod | grep go-paramfetch > go-paramfetch-checksum.txt
      - restore_cache:
          name: Restore parameters cache
          keys:
            - 'groth-params-and-keys-{{ checksum "go-paramfetch-checksum.txt" }}'
          paths:
            - /var/tmp/filecoin-proof-parameters/
      - run:
          name: Download Groth parameters and keys for 1KiB sector size (hard-coded in test)
          command: make fetch-params
      - save_cache:
          name: Save parameters cache
          key: 'groth-params-and-keys-{{ checksum "go-paramfetch-checksum.txt" }}'
          paths:
            - /var/tmp/filecoin-proof-parameters/

jobs:
  mod-tidy-check:
    executor: golang
    steps:
      - install-deps
      - prepare
      - go/mod-download
      - go/mod-tidy-check

  build-all:
    executor: golang
    steps:
      - install-deps
      - prepare
      - go/mod-download
      - restore_cache:
          name: restore go mod cache
          key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
      - run:
          command: make build
Jakub Sztandera's avatar
Jakub Sztandera committed
75
76
      - run:
          command: CGO_ENABLED=0 make build
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

  test: &test
    description: |
      Run tests.
    parameters:
      executor:
        type: executor
        default: golang
    executor: << parameters.executor >>
    steps:
      - install-deps
      - prepare
      - go/mod-download
      - restore_cache:
          name: restore go mod cache
          key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
      - run:
          command: make deps
          no_output_timeout: 30m
      - download-params
      - run:
          name: run tests
          command: make test
          no_output_timeout: 60m
      - save_cache:
          name: save go mod cache
          key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
          paths:
            - "~/go/pkg"
            - "~/go/src/github.com"
            - "~/go/src/golang.org"

  build-macos:
    description: build with Darwin
    macos:
      xcode: "10.0.0"
    working_directory: ~/go/src/github.com/filecoin-project/go-sectorbuilder
    steps:
      - prepare:
          linux: false
          darwin: true
      - run:
          name: Install go
          command: |
            curl -O https://dl.google.com/go/go1.13.4.darwin-amd64.pkg && \
            sudo installer -pkg go1.13.4.darwin-amd64.pkg -target /
      - run:
          name: Install pkg-config
          command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config
      - run: go version
      - run:
          name: Install Rust
          command: |
            curl https://sh.rustup.rs -sSf | sh -s -- -y
      - run:
          name: Install jq
          command: |
            mkdir $HOME/.bin
            curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output $HOME/.bin/jq
            chmod +x $HOME/.bin/jq
      - restore_cache:
          name: restore go mod and cargo cache
          key: v1-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/go-sectorbuilder/go.sum" }}
      - install-deps
      - go/mod-download
      - run:
          command: make build
          no_output_timeout: 30m
      - save_cache:
          name: save cargo cache
          key: v1-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/go-sectorbuilder/go.sum" }}
          paths:
            - "~/.rustup"
            - "~/.cargo"

  lint: &lint
    description: |
      Run golangci-lint.
    parameters:
      executor:
        type: executor
        default: golang
      golangci-lint-version:
        type: string
        default: 1.17.1
      concurrency:
        type: string
        default: '2'
        description: |
          Concurrency used to run linters. Defaults to 2 because NumCPU is not
          aware of container CPU limits.
      args:
        type: string
        default: ''
        description: |
          Arguments to pass to golangci-lint
    executor: << parameters.executor >>
    steps:
      - install-deps
      - prepare
      - go/mod-download
      - run:
          command: make deps
          no_output_timeout: 30m
      - go/install-golangci-lint:
          gobin: $HOME/.local/bin
          version: << parameters.golangci-lint-version >>
      - run:
          name: Lint
          command: |
            $HOME/.local/bin/golangci-lint run -v \
              --concurrency << parameters.concurrency >> << parameters.args >>
  lint-changes:
    <<: *lint

  lint-all:
    <<: *lint

workflows:
  version: 2.1
  ci:
    jobs:
      - lint-changes:
          args: "--new-from-rev origin/master"
      - test
      - mod-tidy-check
      - build-all
      - build-macos