From 4f8de94bb9a1c813c2ea1c6ac8f9675b9a1da647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Mon, 18 Jan 2021 21:30:04 +0000 Subject: [PATCH] circleci: run build on bare linux. --- .circleci/config.yml | 56 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aaaa8bb..6f8839e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,11 +1,57 @@ # Golang CircleCI 2.0 configuration file -version: 2 +version: 2.1 + +parameters: + go-version: + type: string + default: "1.15.5" + workspace-dir: + type: string + default: "/home/circleci" + +commands: + setup: + description: "install go, checkout and restore cache" + steps: + - run: + name: "install go" + command: | + curl --create-dirs -o $GOPATH/go.tar.gz https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz + tar --strip-components=1 -C $GOPATH -xzf $GOPATH/go.tar.gz + rm -rf $GOPATH/go.tar.gz + - checkout + - restore_cache: + keys: + - 'v2-pkg-cache-{{ checksum "go.sum" }}-{{ .Environment.GOVERSION }}' + - 'bin-cache-{{ .Branch }}' + setup-macos: + description: "install go, checkout and restore cache" + steps: + - run: + name: "install go on macOS" + command: | + brew --version + [ ! -d /usr/local/opt/go@1.14 ] && brew update && brew install go@1.14 && echo "done installing go" + echo 'export GOPATH="$HOME/go"' >> $BASH_ENV + echo 'export PATH="/usr/local/opt/go@1.14/bin:$GOPATH/bin:$PATH"' >> $BASH_ENV + source $BASH_ENV + go version + - checkout + +executors: + linux: + machine: + image: ubuntu-1604:201903-01 + working_directory: << pipeline.parameters.workspace-dir >>/project + environment: + GOPATH: << pipeline.parameters.workspace-dir >>/go/<< pipeline.parameters.go-version >> + PATH: << pipeline.parameters.workspace-dir >>/go/<< pipeline.parameters.go-version >>/bin:<< pipeline.parameters.workspace-dir >>/bin:/usr/local/bin:/usr/bin:/bin + GOVERSION: << pipeline.parameters.go-version >> + jobs: build: - docker: - - image: circleci/golang:1.15 - - working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}} + executor: linux steps: - checkout + - setup - run: make