diff --git a/.github/workflows/setup/action.yaml b/.github/workflows/setup/action.yaml index 4e4f457..3320363 100644 --- a/.github/workflows/setup/action.yaml +++ b/.github/workflows/setup/action.yaml @@ -6,13 +6,9 @@ runs: - name: Set up go uses: actions/setup-go@v4 with: - go-version: 1.21.3 + go-version: 1.20.10 - name: Install asdf & tools uses: asdf-vm/actions/setup@v2 - name: Setup shell: bash - run: | - asdf plugin-add protoc https://github.com/paxosglobal/asdf-protoc.git - asdf install protoc 24.4 - asdf global protoc 24.4 - make bootstrap + run: make bootstrap diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..52039c4 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,3 @@ +protoc 24.4 +yq 4.35.2 +grpcurl 1.8.8 diff --git a/Dockerfile b/Dockerfile index 8df0ec1..b81b9fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as build +FROM golang:1.20 as build ENV GO111MODULE on @@ -11,7 +11,7 @@ RUN go mod download COPY . ./ RUN make bin -FROM golang:1.18 as deploy +FROM golang:1.20 as deploy WORKDIR /app/ diff --git a/README.md b/README.md index ce11cee..b96f3b3 100644 --- a/README.md +++ b/README.md @@ -48,17 +48,16 @@ It aims to provide an efficient and flexible way to access the on-chain data: ## Quick Start -Make sure your local go version is 1.18 by running the following commands: +If you're not using [asdf](https://asdf-vm.com/), then make sure your local go version is 1.20+ by running the following commands: ```shell -brew install go@1.18 +brew install go@1.20.10 brew unlink go -brew link go@1.18 +brew link go@1.20.10 brew install protobuf@3.21.12 brew unlink protobuf brew link protobuf - ``` To set up for the first time (only done once): diff --git a/go.mod b/go.mod index d424cdd..73d23e9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/coinbase/chainstorage -go 1.18 +go 1.20 require ( github.com/VividCortex/ewma v1.2.0 diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 66f05a0..58baf62 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -2,12 +2,32 @@ set -exo pipefail -source ./scripts/precheck.sh - +# Use asdf if it's available +if [ -x "$(command -v asdf)" ]; then + if ! [ -x "$(command -v go)" ]; then + if ! asdf plugin-list | grep -e '^golang$' &> /dev/null; then + asdf plugin add golang https://github.com/asdf-community/asdf-golang.git + asdf install golang 1.20.10 + asdf global golang 1.20.10 + fi + fi + if ! asdf plugin-list | grep -e '^yq$' &> /dev/null; then + asdf plugin-add yq https://github.com/sudermanjr/asdf-yq.git + fi + if ! asdf plugin-list | grep -e '^protoc$' &> /dev/null; then + asdf plugin-add protoc https://github.com/paxosglobal/asdf-protoc.git + fi + if ! asdf plugin-list | grep -e '^grpcurl$' &> /dev/null; then + asdf plugin-add grpcurl https://github.com/asdf-community/asdf-grpcurl.git + fi + asdf install +else + source ./scripts/precheck.sh + go install github.com/mikefarah/yq/v4@v4.35.2 +fi go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 -go install github.com/mikefarah/yq/v4@v4.35.2 go install github.com/golang/mock/mockgen@v1.6.0 go install github.com/gordonklaus/ineffassign@v0.0.0-20230610083614-0e73809eb601 go install github.com/kisielk/errcheck@v1.6.3 @@ -15,3 +35,7 @@ go install github.com/go-bindata/go-bindata/go-bindata@v3.1.2 go install golang.org/x/tools/cmd/goimports@v0.13.0 go mod download go mod tidy + +if [ -x "$(command -v asdf)" ]; then + asdf reshim +fi diff --git a/scripts/precheck.sh b/scripts/precheck.sh index 577bc15..cfa1acc 100755 --- a/scripts/precheck.sh +++ b/scripts/precheck.sh @@ -2,6 +2,12 @@ set -eo pipefail +# Check if golang is installed +if ! [ -x "$(command -v go)" ]; then + echo 'Error: go is not installed. Please refer https://golang.org/ for installation instruction' >&2 + exit 1 +fi + # Check if protobuf is installed if ! [ -x "$(command -v protoc)" ]; then echo 'Error: protobuf is not installed. Please refer https://grpc.io/docs/protoc-installation/ for installation instruction' >&2