Skip to content

Commit

Permalink
chore: upgrade to Go 1.22 (#1249)
Browse files Browse the repository at this point in the history
## Motivation

Part of #1248
We want to cut a release of celestia-core with Go 1.22 support to enable
celestia-node to bump to Go 1.22.

## Description

1. Upgrade to Go 1.22
2. Bump pyroscope deps
3. Copy over golangci-lint config from CometBFT v0.34.x branch
4. Resolve a few lint issues by copying code from CometBFT v0.34.x
branch
  • Loading branch information
rootulp authored Feb 29, 2024
1 parent 9110107 commit f95a434
Show file tree
Hide file tree
Showing 26 changed files with 221 additions and 101 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# steps:
# - uses: actions/setup-go@v3
# with:
# go-version: "1.19"
# go-version: "1.22"

# - uses: actions/checkout@v3

Expand All @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- uses: actions/checkout@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand All @@ -70,7 +70,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-nightly-34x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
# steps:
# - uses: actions/setup-go@v3
# with:
# go-version: "1.19"
# go-version: "1.22"
# - uses: actions/checkout@v3
# - uses: technote-space/get-diff-action@v6
# with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
Expand All @@ -34,7 +34,7 @@ jobs:
# Required: the version of golangci-lint is required and
# must be specified without patch version: we always use the
# latest patch version.
version: v1.50.1
version: v1.56.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

# Similar check to ./release-version.yml, but enforces this when pushing
# tags. The ./release-version.yml check can be bypassed and is mainly
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- name: Check version
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.22'

- name: Generate release notes
run: |
Expand All @@ -32,4 +32,3 @@ jobs:
args: release --clean --release-notes ../release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6
with:
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
# steps:
# - uses: actions/setup-go@v3
# with:
# go-version: "1.19"
# go-version: "1.22"
# - uses: actions/checkout@v3
# - uses: technote-space/get-diff-action@v6
# with:
Expand Down
90 changes: 84 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
run:
skip-files:
- "libs/pubsub/query/query.peg.go"

linters:
enable:
- asciicheck
Expand All @@ -10,13 +14,13 @@ linters:
- goconst
- gofmt
- goimports
- revive
#- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
#- nakedret
- nolintlint
- prealloc
- staticcheck
Expand All @@ -31,6 +35,13 @@ issues:
- path: _test\.go
linters:
- gosec
- staticcheck
- nolintlint
- path: test/fuzz/
linters:
- gosec
- nolintlint
- staticcheck
max-same-issues: 50

linters-settings:
Expand All @@ -40,7 +51,74 @@ linters-settings:
min-confidence: 0
maligned:
suggest-new: true

run:
skip-files:
- libs/pubsub/query/query.peg.go
goconst:
ignore-tests: true
depguard:
rules:
main:
files:
- $all
- "!$test"
allow:
- $gostd
- github.com/tendermint
- github.com/cometbft
- github.com/cosmos
- github.com/gogo
- github.com/Workiva/go-datastructures
- github.com/ChainSafe/go-schnorrkel
- github.com/creachadair/taskgroup
- github.com/gtank/merlin
- github.com/btcsuite/btcd/btcec/v2
- github.com/BurntSushi/toml
- github.com/go-git/go-git/v5
- github.com/go-kit
- github.com/go-logfmt/logfmt
- github.com/gofrs/uuid
- github.com/google
- github.com/gorilla/websocket
- github.com/informalsystems/tm-load-test/pkg/loadtest
- github.com/lib/pq
- github.com/libp2p/go-buffer-pool
- github.com/Masterminds/semver/v3
- github.com/minio/highwayhash
- github.com/oasisprotocol/curve25519-voi
- github.com/pkg/errors
- github.com/prometheus
- github.com/rcrowley/go-metrics
- github.com/rs/cors
- github.com/snikch/goodman
- github.com/spf13
- github.com/stretchr/testify/require
- github.com/syndtr/goleveldb
# celestia-core specific
- github.com/influxdata/influxdb-client-go/v2
- github.com/grafana/pyroscope-go
- github.com/grafana/otel-profiling-go
- github.com/celestiaorg/nmt
test:
files:
- "$test"
allow:
- $gostd
- github.com/cosmos
- github.com/tendermint
- github.com/cometbft
- github.com/gogo
- github.com/Workiva/go-datastructures
- github.com/ChainSafe/go-schnorrkel
- github.com/creachadair/taskgroup
- github.com/gtank/merlin
- github.com/adlio/schema
- github.com/btcsuite/btcd
- github.com/fortytw2/leaktest
- github.com/go-kit
- github.com/google/uuid
- github.com/gorilla/websocket
- github.com/lib/pq
- github.com/oasisprotocol/curve25519-voi/primitives/merlin
- github.com/ory/dockertest
- github.com/pkg/errors
- github.com/prometheus/client_golang/prometheus/promhttp
- github.com/spf13
- github.com/stretchr/testify
3 changes: 1 addition & 2 deletions DOCKER/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use a build arg to ensure that both stages use the same,
# hopefully current, go version.
ARG GOLANG_BASE_IMAGE=golang:1.19-alpine
ARG GOLANG_BASE_IMAGE=golang:1.22-alpine

# stage 1 Generate CometBFT Binary
FROM --platform=$BUILDPLATFORM $GOLANG_BASE_IMAGE as builder
Expand Down Expand Up @@ -58,4 +58,3 @@ CMD ["node"]

# Expose the data directory as a volume since there's mutable state in there
VOLUME [ "$CMTHOME" ]

10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ endif

proto-gen: check-proto-deps
@echo "Generating Protobuf files"
@go run github.com/bufbuild/buf/cmd/buf generate
@go run github.com/bufbuild/buf/cmd/buf@v1.29.0 generate
@mv ./proto/tendermint/abci/types.pb.go ./abci/types/
@cp ./proto/tendermint/rpc/grpc/types.pb.go ./rpc/grpc
.PHONY: proto-gen
Expand All @@ -163,7 +163,7 @@ proto-gen: check-proto-deps
# execution only.
proto-lint: check-proto-deps
@echo "Linting Protobuf files"
@go run github.com/bufbuild/buf/cmd/buf lint
@go run github.com/bufbuild/buf/cmd/buf@v1.29.0 lint
.PHONY: proto-lint

proto-format: check-proto-format-deps
Expand All @@ -176,11 +176,11 @@ proto-check-breaking: check-proto-deps
@echo "Note: This is only useful if your changes have not yet been committed."
@echo " Otherwise read up on buf's \"breaking\" command usage:"
@echo " https://docs.buf.build/breaking/usage"
@go run github.com/bufbuild/buf/cmd/buf breaking --against ".git"
@go run github.com/bufbuild/buf/cmd/buf@v1.29.0 breaking --against ".git"
.PHONY: proto-check-breaking

proto-check-breaking-ci:
@go run github.com/bufbuild/buf/cmd/buf breaking --against $(HTTPS_GIT)#branch=v0.34.x-celestia
@go run github.com/bufbuild/buf/cmd/buf@v1.29.0 breaking --against $(HTTPS_GIT)#branch=v0.34.x-celestia
.PHONY: proto-check-breaking-ci

###############################################################################
Expand Down Expand Up @@ -259,7 +259,7 @@ format:

lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 run
.PHONY: lint

vulncheck:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This repo intends on preserving the minimal possible diff with [cometbft/cometbf
- **specific to Celestia**: consider if [celestia-app](https://github.com/celestiaorg/celestia-app) is a better target
- **not specific to Celestia**: consider making the contribution upstream in CometBFT

1. [Install Go](https://go.dev/doc/install) 1.19+
1. [Install Go](https://go.dev/doc/install) 1.22+
2. Fork this repo
3. Clone your fork
4. Find an issue to work on (see [good first issues](https://github.com/celestiaorg/celestia-core/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22))
Expand Down
Loading

0 comments on commit f95a434

Please sign in to comment.