|
| 1 | +version: 2.1 |
| 2 | +orbs: |
| 3 | + go: gotest/tools@0.0.9 |
| 4 | + |
| 5 | +executors: |
| 6 | + golang: |
| 7 | + docker: |
| 8 | + - image: circleci/golang:1.13 |
| 9 | + resource_class: medium |
| 10 | + |
| 11 | +commands: |
| 12 | + install-deps: |
| 13 | + steps: |
| 14 | + - go/install-ssh |
| 15 | + - go/install: {package: git} |
| 16 | + prepare: |
| 17 | + parameters: |
| 18 | + linux: |
| 19 | + default: true |
| 20 | + description: is a linux build environment? |
| 21 | + type: boolean |
| 22 | + darwin: |
| 23 | + default: false |
| 24 | + description: is a darwin build environment? |
| 25 | + type: boolean |
| 26 | + steps: |
| 27 | + - checkout |
| 28 | + - when: |
| 29 | + condition: << parameters.linux >> |
| 30 | + steps: |
| 31 | + - run: sudo apt-get update |
| 32 | + - run: sudo apt-get install ocl-icd-opencl-dev |
| 33 | + - run: git submodule sync |
| 34 | + - run: git submodule update --init |
| 35 | + |
| 36 | +jobs: |
| 37 | + mod-tidy-check: |
| 38 | + executor: golang |
| 39 | + steps: |
| 40 | + - install-deps |
| 41 | + - prepare |
| 42 | + - go/mod-download |
| 43 | + - go/mod-tidy-check |
| 44 | + |
| 45 | + build-all: |
| 46 | + executor: golang |
| 47 | + steps: |
| 48 | + - install-deps |
| 49 | + - prepare |
| 50 | + - go/mod-download |
| 51 | + - restore_cache: |
| 52 | + name: restore go mod cache |
| 53 | + key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }} |
| 54 | + - run: |
| 55 | + command: make build |
| 56 | + |
| 57 | + test: &test |
| 58 | + description: | |
| 59 | + Run tests. |
| 60 | + parameters: |
| 61 | + executor: |
| 62 | + type: executor |
| 63 | + default: golang |
| 64 | + executor: << parameters.executor >> |
| 65 | + steps: |
| 66 | + - install-deps |
| 67 | + - prepare |
| 68 | + - go/mod-download |
| 69 | + - restore_cache: |
| 70 | + name: restore go mod cache |
| 71 | + key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }} |
| 72 | + - run: |
| 73 | + name: run tests |
| 74 | + command: make test |
| 75 | + - save_cache: |
| 76 | + name: save go mod cache |
| 77 | + key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }} |
| 78 | + paths: |
| 79 | + - "~/go/pkg" |
| 80 | + - "~/go/src/github.com" |
| 81 | + - "~/go/src/golang.org" |
| 82 | + |
| 83 | + build-macos: |
| 84 | + description: build with Darwin |
| 85 | + macos: |
| 86 | + xcode: "10.0.0" |
| 87 | + working_directory: ~/go/src/github.com/filecoin-project/go-commp-utils |
| 88 | + steps: |
| 89 | + - prepare: |
| 90 | + linux: false |
| 91 | + darwin: true |
| 92 | + - run: |
| 93 | + name: Install go |
| 94 | + command: | |
| 95 | + curl -O https://dl.google.com/go/go1.13.4.darwin-amd64.pkg && \ |
| 96 | + sudo installer -pkg go1.13.4.darwin-amd64.pkg -target / |
| 97 | + - run: |
| 98 | + name: Install pkg-config |
| 99 | + command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config |
| 100 | + - run: go version |
| 101 | + - run: |
| 102 | + name: Install Rust |
| 103 | + command: | |
| 104 | + curl https://sh.rustup.rs -sSf | sh -s -- -y |
| 105 | + - run: |
| 106 | + name: Install jq |
| 107 | + command: | |
| 108 | + curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output /usr/local/bin/jq |
| 109 | + chmod +x /usr/local/bin/jq |
| 110 | + - restore_cache: |
| 111 | + name: restore go mod and cargo cache |
| 112 | + key: v1-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/go-commp-utils/go.sum" }} |
| 113 | + - install-deps |
| 114 | + - go/mod-download |
| 115 | + - run: |
| 116 | + command: make |
| 117 | + - save_cache: |
| 118 | + name: save cargo cache |
| 119 | + key: v1-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/go-commp-utils/go.sum" }} |
| 120 | + paths: |
| 121 | + - "~/.rustup" |
| 122 | + - "~/.cargo" |
| 123 | + |
| 124 | + lint: |
| 125 | + description: | |
| 126 | + Run golangci-lint. |
| 127 | + parameters: |
| 128 | + executor: |
| 129 | + type: executor |
| 130 | + default: golang |
| 131 | + golangci-lint-version: |
| 132 | + type: string |
| 133 | + default: 1.17.1 |
| 134 | + executor: << parameters.executor >> |
| 135 | + steps: |
| 136 | + - install-deps |
| 137 | + - prepare |
| 138 | + - go/mod-download |
| 139 | + - run: |
| 140 | + command: make |
| 141 | + - go/install-golangci-lint: |
| 142 | + gobin: $HOME/.local/bin |
| 143 | + version: << parameters.golangci-lint-version >> |
| 144 | + - run: |
| 145 | + name: Lint |
| 146 | + command: make lint |
| 147 | + |
| 148 | +workflows: |
| 149 | + version: 2.1 |
| 150 | + ci: |
| 151 | + jobs: |
| 152 | + - lint |
| 153 | + - test |
| 154 | + - mod-tidy-check |
| 155 | + - build-all |
| 156 | + - build-macos |
0 commit comments