From 0686b4428fcf8bb35b1bb80dc25259f8de72caf8 Mon Sep 17 00:00:00 2001 From: benjamin202410 Date: Wed, 25 Dec 2024 22:59:24 -0800 Subject: [PATCH] upgrade to golang 1.22 (#763) Co-authored-by: liam.lai --- .github/workflows/ci.yml | 2 +- .travis.yml.bak | 180 --------------------------------------- Dockerfile | 2 +- Dockerfile.bootnode | 2 +- Dockerfile.node | 2 +- Makefile | 2 +- build/ci.go | 2 +- cicd/Dockerfile | 2 +- go.mod | 2 +- 9 files changed, 8 insertions(+), 188 deletions(-) delete mode 100644 .travis.yml.bak diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c41c2b2a6..9d568dc509 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: '1.21.x' + go-version: '1.22.x' - name: Run tests run: ${{ matrix.script }} env: diff --git a/.travis.yml.bak b/.travis.yml.bak deleted file mode 100644 index b4e3db53b3..0000000000 --- a/.travis.yml.bak +++ /dev/null @@ -1,180 +0,0 @@ -sudo: required -language: go -go_import_path: github.com/XinFinOrg/XDPoSChain - -on: - branches: - - master - - dev-upgrade - tags: true - -env: - global: - - GOPROXY=https://proxy.golang.org - - GO111MODULE=on - # Terraform env - - tf_version=1.3.0 - # Setting terraform init CLI options - https://www.terraform.io/docs/commands/init.html - - tf_init_cli_options=" -input=false" - # Set terraform validation CLI options - https://www.terraform.io/docs/commands/validate.html - - tf_validation_cli_options="" - # Set terraform plan CLI options - https://www.terraform.io/docs/commands/plan.html - - tf_plan_cli_options=" -lock=false -input=false" - # Set terraform apply CLI options - https://www.terraform.io/docs/commands/apply.html - - tf_apply_cli_options=" -auto-approve -input=false" - - -jobs: - include: - - stage: Tests - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: A-B tests - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[a-b].*") - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[a-m].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: C-[a-m] tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[n-o].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: C-[n-o] tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/c[p-z].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: C-[p-z] tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[d-i].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: D-I tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[j-n].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: J-N tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[o-r].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: O-R tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/s.*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: S tests - - script: travis_retry go run build/ci.go test -coverage $(go list ./... | grep "github.com\/XinFinOrg\/XDPoSChain\/[t-z].*") - os: linux - dist: bionic - go: 1.21.x - env: - - GO111MODULE=auto - name: T-Z tests - - - stage: TAG Build - if: tag IS present - services: - - docker - install: skip - before_script: - - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - docker --version # document the version travis is using - - docker build -t xinfinorg/xdposchain:$TRAVIS_TAG -f cicd/Dockerfile . - script: - - docker push xinfinorg/xdposchain:$TRAVIS_TAG - - - stage: (Devnet) Build, and push images - if: branch = dev-upgrade AND type = push AND tag IS blank - services: - - docker - install: skip - before_script: - - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - docker --version # document the version travis is using - - docker pull xinfinorg/devnet:latest # build the "previous" tag so that our devnet environment can run with both old and new code at the same time. - - docker tag xinfinorg/devnet:latest xinfinorg/devnet:previous - - docker rmi xinfinorg/devnet:latest - - docker build -t xinfinorg/devnet:latest -f cicd/Dockerfile . - script: - - docker push xinfinorg/devnet:latest - - docker push xinfinorg/devnet:previous - - - stage: (Devnet)Terraform plan - if: branch = dev-upgrade AND type = push AND tag IS blank - dist: xenial - language: bash - install: - - wget https://releases.hashicorp.com/terraform/"$tf_version"/terraform_"$tf_version"_linux_amd64.zip - - unzip terraform_"$tf_version"_linux_amd64.zip - - sudo mv terraform /usr/local/bin/ - - rm terraform_"$tf_version"_linux_amd64.zip - script: - - echo "Pull request detected, creating change plan(Devnet)" - - cd cicd/devnet/terraform - # Terraform init, validate, then create change plan. If any fail, fail validation - - terraform init $tf_init_cli_options - - terraform validate $tf_validation_cli_options - - terraform plan $tf_plan_cli_options - - - stage: (Devnet) Terraform apply - if: branch = dev-upgrade AND type = push AND tag IS blank - dist: xenial - language: bash - install: - # Download and install terraform before each run - - wget https://releases.hashicorp.com/terraform/"$tf_version"/terraform_"$tf_version"_linux_amd64.zip - - unzip terraform_"$tf_version"_linux_amd64.zip - - sudo mv terraform /usr/local/bin/ - - rm terraform_"$tf_version"_linux_amd64.zip - - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" - - unzip awscliv2.zip - - sudo ./aws/install - - export PATH=$PATH:$HOME/.local/bin # put aws in the path - script: - - echo "Merge detected, executing changes(Devnet)" - - cd cicd/devnet/terraform - # Terraform init and then apply changes to environment - - terraform init $tf_init_cli_options - - terraform apply $tf_apply_cli_options - - sleep 5 - - | - source .env - for ((i=$us_east_2_start;i<$us_east_2_end;i++)); do - echo "Force deploy xdc-$i" - aws ecs update-service --region us-east-2 --cluster devnet-xdcnode-cluster --service ecs-service-xdc$i --force-new-deployment --no-cli-pager; - done - for ((i=$eu_west_1_start;i<$eu_west_1_end;i++)); do - echo "Force deploy xdc-$i" - aws ecs update-service --region eu-west-1 --cluster devnet-xdcnode-cluster --service ecs-service-xdc$i --force-new-deployment --no-cli-pager; - done - for ((i=$ap_southeast_2_start;i<$ap_southeast_2_end;i++)); do - echo "Force deploy xdc-$i" - aws ecs update-service --region ap-southeast-2 --cluster devnet-xdcnode-cluster --service ecs-service-xdc$i --force-new-deployment --no-cli-pager; - done - aws ecs update-service --region ap-southeast-1 --cluster devnet-xdcnode-cluster --service ecs-service-rpc1 --force-new-deployment --no-cli-pager; - - - stage: (Devnet) Send Deployment Notification - if: branch = dev-upgrade AND type = push AND tag IS blank - language: bash - script: - - curl --location --request POST "66.94.98.186:8080/deploy?environment=devnet&service=xdc&version=$TRAVIS_COMMIT" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1207545aa7..5aba541a49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.22-alpine as builder RUN apk add --no-cache make gcc musl-dev linux-headers git diff --git a/Dockerfile.bootnode b/Dockerfile.bootnode index bb906b581f..374bea3d3c 100644 --- a/Dockerfile.bootnode +++ b/Dockerfile.bootnode @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.22-alpine as builder RUN apk add --no-cache make gcc musl-dev linux-headers diff --git a/Dockerfile.node b/Dockerfile.node index 3d6f58495b..b3e0f299d9 100644 --- a/Dockerfile.node +++ b/Dockerfile.node @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.22-alpine as builder RUN apk add --no-cache make gcc musl-dev linux-headers git diff --git a/Makefile b/Makefile index 1ab433b070..3bd726906c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GOBIN = $(shell pwd)/build/bin GOFMT = gofmt -GO ?= 1.21.3 +GO ?= 1.22.10 GO_PACKAGES = . GO_FILES := $(shell find $(shell go list -f '{{.Dir}}' $(GO_PACKAGES)) -name \*.go) diff --git a/build/ci.go b/build/ci.go index 7d09ec7c9d..ff3ea89d10 100644 --- a/build/ci.go +++ b/build/ci.go @@ -115,7 +115,7 @@ func doInstall(cmdline []string) { if minor < 21 { log.Println("You have Go version", runtime.Version()) - log.Println("XDC requires at least Go version 1.21 and cannot") + log.Println("XDC requires at least Go version 1.22 and cannot") log.Println("be compiled with an earlier version. Please upgrade your Go installation.") os.Exit(1) } diff --git a/cicd/Dockerfile b/cicd/Dockerfile index bf5b4b5c79..055492e548 100644 --- a/cicd/Dockerfile +++ b/cicd/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.22-alpine as builder RUN apk add make build-base linux-headers diff --git a/go.mod b/go.mod index d948f4cea3..23a0995a49 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/XinFinOrg/XDPoSChain -go 1.21 +go 1.22 require ( github.com/VictoriaMetrics/fastcache v1.12.2