Skip to content

Commit

Permalink
chore: bump to Go 1.22 (#375)
Browse files Browse the repository at this point in the history
* chore: bump to Go 1.22

* ci: fix CI by bumping Go in dockerfiles

Also checkout codebase before setup go

* chore(deps): bump golangci-lint

* lint: gofumpt file

* fix: WriteFile permissions

Inspired by: cosmos@ac74e23
Fixes thislint error:

crypto/keyring/keyring.go:722:14: G306: Expect WriteFile permissions to be 0600 or less (gosec)
			if err := os.WriteFile(dir+"/keyhash", passwordHash, 0o555); err != nil {

* fix: resolve implicit memory aliasing in for loop

Inspired by:
https://github.com/cosmos/cosmos-sdk/blob/28801fc666f1c33f315e815bd57f2952fd6e0b00/x/group/keeper/keeper.go#L390

* lint: remove depguard

Not used on cosmos-sdk main branch

* lint: resolve nakedret
  • Loading branch information
rootulp authored Mar 10, 2024
1 parent 0244d0c commit 2a2347c
Show file tree
Hide file tree
Showing 23 changed files with 246 additions and 192 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: go.mod
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.49.0
version: v1.56.2
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- run: make build
Expand All @@ -32,9 +32,10 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -50,9 +51,9 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- uses: actions/cache@v3
Expand All @@ -69,9 +70,9 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- uses: actions/cache@v3
Expand All @@ -88,9 +89,9 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- uses: actions/cache@v3
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/test-race.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
install-tparse:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -38,9 +39,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
id: git_diff
with:
Expand All @@ -55,9 +56,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -89,9 +90,9 @@ jobs:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
go-arch: ["amd64", "arm", "arm64"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
id: git_diff
with:
Expand All @@ -44,9 +44,9 @@ jobs:
container: tendermintdev/docker-tm-db-testing
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
id: git_diff
with:
Expand All @@ -67,9 +67,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -101,9 +101,9 @@ jobs:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down Expand Up @@ -180,9 +180,9 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- uses: technote-space/[email protected]
id: git_diff
with:
Expand All @@ -203,9 +203,10 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -220,9 +221,9 @@ jobs:
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- name: Display go version
run: go version
- uses: technote-space/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ run:
linters:
disable-all: true
enable:
- depguard
- dogsled
- exportloopref
- goconst
Expand Down Expand Up @@ -58,4 +57,4 @@ linters-settings:
nolintlint:
allow-unused: false
require-explanation: false
require-specific: false
require-specific: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys add foo
# > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys list
# TODO: demo connecting rest-server (or is this in server now?)
FROM golang:1.19-alpine AS build-env
FROM golang:1.22.1-alpine AS build-env

# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ benchmark:
###############################################################################

golangci_lint_cmd=golangci-lint
golangci_version=v1.49.0
golangci_version=v1.56.2

lint:
@echo "--> Running linter"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
}

if app.initChainer == nil {
return
return res
}

// add block gas meter for any genesis transactions (allow infinite gas)
Expand Down
14 changes: 7 additions & 7 deletions contrib/devtools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FROM bufbuild/buf:1.1.0 as BUILDER

FROM golang:1.19-alpine
FROM golang:1.22.1-alpine

RUN apk add --no-cache \
nodejs \
Expand All @@ -20,19 +20,19 @@ ENV GOLANG_PROTOBUF_VERSION=1.28.0 \
RUN go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION}
RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION}
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION}

# install all gogo protobuf binaries
RUN git clone https://github.com/regen-network/protobuf.git; \
cd protobuf; \
go mod download; \
make install
cd protobuf; \
go mod download; \
make install

# we need to use git clone because we use 'replace' directive in go.mod
# protoc-gen-gocosmos was moved to to in cosmos/gogoproto but pending a migration there.
RUN git clone https://github.com/regen-network/cosmos-proto.git; \
cd cosmos-proto/protoc-gen-gocosmos; \
go install .
cd cosmos-proto/protoc-gen-gocosmos; \
go install .

RUN npm install -g swagger-combine

Expand Down
2 changes: 1 addition & 1 deletion contrib/images/simd-dlv/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine AS build
FROM golang:1.22.1-alpine AS build

RUN apk add build-base git linux-headers libc-dev
RUN go install github.com/go-delve/delve/cmd/dlv@latest
Expand Down
2 changes: 1 addition & 1 deletion contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine AS build
FROM golang:1.22.1-alpine AS build

RUN apk add build-base git linux-headers

Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/rosetta-ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine as build
FROM golang:1.22.1-alpine as build

RUN apk add --no-cache tar git

Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/rosetta-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine as build
FROM golang:1.22.1-alpine as build

RUN apk add git gcc libc-dev --no-cache

Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
continue
}

if err := os.WriteFile(dir+"/keyhash", passwordHash, 0o555); err != nil {
if err := os.WriteFile(dir+"/keyhash", passwordHash, 0o600); err != nil {
return "", err
}

Expand Down
Loading

0 comments on commit 2a2347c

Please sign in to comment.