Skip to content

Commit

Permalink
Bump go to v1.23 (from v1.21) (#2132)
Browse files Browse the repository at this point in the history
* Switch the go-setup actions to get the version from go.mod.

* Remove the go version steps from the sims workflow since the go setup action does that now.

* In Makefile: Add validate-go-version go the install target. Replace direct uses of the 'go' command with the $(GO) variable.

* Remove the explicit go cache steps from the sims workflow since go setup does that automatically now.

* Remove the explicit runsim install step since the make targets that need it are doing it on their own still anyway.

* Switch to go 1.23 in go.mod and update the Makefile to require go 1.23 (instead of 1.21).

* Update all the docker files to use golang:1.23-bullseye (from golang:1.21-bullseye).

* Remove internal/collections/maps.go since that functionality is in go by default now.

* Update the documentation to indicate go 1.23 is needed now.

* Add a changelog entry and create a summary.md that tells about the bump (since it's a pretty important change to note).

* Bump golangci-lint to v1.60.2.

* Fix all the new lint errors. Lots of integer casting problems were found.

* Fix TestIntBetween because I accidentally deleted a sort line when getting rid of our copy of the Keys function.

* In the heighliner job, try setting up go with the correct version. It's currently using v1.22 which causes make install to fail.

* Remove go setup from that job because it didn't help (kind of didn't expect it to anyway).

* In the heighliner job, try setting the BASE_VERSION env var to the needed golang version since the dockerfile might pick up on it.

* Remove the BASE_VERSION env var from the heighliner job since it's not the problem. Digging into their stuff, they don't yet have support for go v1.23, so we'll just have to wait.

* Include the golangci-lint bump in the changelog stuff.
  • Loading branch information
SpicyLemon committed Aug 22, 2024
1 parent d4c3b76 commit c702324
Show file tree
Hide file tree
Showing 56 changed files with 166 additions and 202 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/dependencies/2132-bump-go-to-1.23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Bump `go` to 1.23 (from 1.21) [#2132](https://github.com/provenance-io/provenance/pull/2132).
* Bump `golangci-lint` to v1.60.2 (from v1.54.2) [#2132](https://github.com/provenance-io/provenance/pull/2132).
2 changes: 2 additions & 0 deletions .changelog/unreleased/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Building or installing `provenanced` from source now requires you to use [Go 1.23](https://golang.org/dl/).
Linting now requires `golangci-lint` v1.60.2. You can update yours using `make golangci-lint-update` or install it using `make golangci-lint`.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: 'go.mod'

- run: go mod vendor

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.21'
go-version-file: 'go.mod'
- uses: golangci/golangci-lint-action@v6
if: env.GIT_DIFF
with:
# If you change this version, be sure to also change it in contrib/devtools/Makefile.
version: v1.54
version: v1.60
args: --timeout 10m --out-${NO_FUTURE}format colored-line-number
github-token: ${{ secrets.github_token }}
- name: No Now Usage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: 'go.mod'
- name: Setup Job
id: setup
run: |
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
version: ${{ steps.vars.outputs.version }}
is_release: ${{ steps.vars.outputs.is_release }}
prerelease: ${{ steps.vars.outputs.prerelease }}
go_version: '1.21'

build_osx:
runs-on: macos-latest
Expand All @@ -68,7 +67,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ needs.build_init.outputs.go_version }}
go-version-file: 'go.mod'
- name: Build osx binary
run: |
export VERSION=${{ needs.build_init.outputs.version }}
Expand All @@ -93,7 +92,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ needs.build_init.outputs.go_version }}
go-version-file: 'go.mod'
- name: Install deps
run: |
sudo apt-get update
Expand Down Expand Up @@ -163,7 +162,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ needs.build_init.outputs.go_version }}
go-version-file: 'go.mod'
- name: Download linux zip artifact
uses: actions/download-artifact@v4
with:
Expand Down
60 changes: 6 additions & 54 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,9 @@ jobs:
file_prefix="sim-test-${GITHUB_SHA:0:7}-${GITHUB_RUN_ATTEMPT}"
echo "Setting output: file-prefix=$file_prefix"
echo "file-prefix=$file_prefix" >> "$GITHUB_OUTPUT"
go_cache_key_hash="${{ hashFiles('go.sum') }}"
echo "Setting output: go-cache-key-hash=$go_cache_key_hash"
echo "go-cache-key-hash=$go_cache_key_hash" >> "$GITHUB_OUTPUT"
outputs:
go-version: '1.21'
should-run: ${{ env.GIT_DIFF }}
file-prefix: ${{ steps.def-vars.outputs.file-prefix }}
go-cache-key-suffix: sims-go3-${{ steps.def-vars.outputs.go-cache-key-hash }}
# In Order:
# * Go binary directory
# * Go module directory
# * Go build cache (Linux)
go-cache-path: |
~/go/bin
~/go/pkg/mod
~/.cache/go-build

build-linux:
needs: setup
Expand All @@ -66,17 +53,8 @@ jobs:
- uses: actions/checkout@v4
- name: Output setup
run: |
echo " go-version: [${{ needs.setup.outputs.go-version }}]"
echo " should-run: [${{ needs.setup.outputs.should-run }}]"
echo " file-prefix: [${{ needs.setup.outputs.file-prefix }}]"
echo "go-cache-key-suffix: [${{ needs.setup.outputs.go-cache-key-suffix }}]"
echo " go-cache-path: [${{ needs.setup.outputs.go-cache-path }}]"
- uses: actions/cache@v4
name: Load go cache
id: go-cache-setup
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.go-cache-key-suffix }}
path: ${{ needs.setup.outputs.go-cache-path }}
echo " should-run: [${{ needs.setup.outputs.should-run }}]"
echo "file-prefix: [${{ needs.setup.outputs.file-prefix }}]"
- name: Setup build environment
env:
DEBIAN_FRONTEND: noninteractive
Expand All @@ -85,12 +63,7 @@ jobs:
sudo apt-get install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev wget curl build-essential cmake gcc sqlite3
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.setup.outputs.go-version }}
- name: Display go version
run: go version
- name: Install runsim
if: steps.go-cache-setup.outputs.cache-hit != 'true'
run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Build provenanced
Expand All @@ -111,11 +84,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: Load go cache
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.go-cache-key-suffix }}
path: ${{ needs.setup.outputs.go-cache-path }}
- name: Define test-logs
id: test-logs
run: |
Expand All @@ -124,9 +92,7 @@ jobs:
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.setup.outputs.go-version }}
- name: Display go version
run: go version
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
Expand Down Expand Up @@ -170,11 +136,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: Load go cache
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.go-cache-key-suffix }}
path: ${{ needs.setup.outputs.go-cache-path }}
- name: Define test-logs
id: test-logs
run: |
Expand All @@ -183,9 +144,7 @@ jobs:
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.setup.outputs.go-version }}
- name: Display go version
run: go version
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
Expand Down Expand Up @@ -214,11 +173,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: Load go cache
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.go-cache-key-suffix }}
path: ${{ needs.setup.outputs.go-cache-path }}
- name: Define test-logs
id: test-logs
run: |
Expand All @@ -227,9 +181,7 @@ jobs:
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version: ${{ needs.setup.outputs.go-version }}
- name: Display go version
run: go version
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ jobs:
path: ./pkgs.txt.part.04
outputs:
should-run: ${{ env.GIT_DIFF }}
go-version: '1.21'
file-prefix: ${{ steps.def-vars.outputs.file-prefix }}


Expand All @@ -104,7 +103,7 @@ jobs:
- uses: actions/setup-go@v5
if: needs.setup-tests.outputs.should-run
with:
go-version: ${{ needs.setup-tests.outputs.go-version }}
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
if: needs.setup-tests.outputs.should-run
with:
Expand Down Expand Up @@ -191,7 +190,7 @@ jobs:
- uses: actions/setup-go@v5
if: needs.setup-tests.outputs.should-run
with:
go-version: ${{ needs.setup-tests.outputs.go-version }}
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
if: needs.setup-tests.outputs.should-run
with:
Expand Down
6 changes: 4 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ linters:
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- depguard
- dogsled
- durationcheck
- errcheck
- errorlint
- errname
- exportloopref
# - forcetypeassert
- gci
- goconst
Expand Down Expand Up @@ -150,7 +150,9 @@ linters-settings:
allow:
- $gostd
- github.com/stretchr/testify

errcheck:
exclude-functions:
- (fmt.State).Write
gci:
custom-order: true
sections:
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ HTTPS_GIT := https://github.com/provenance-io/provenance.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

# Only support go version 1.21
# Only support go version 1.23
SUPPORTED_GO_MAJOR_VERSION = 1
SUPPORTED_GO_MINOR_VERSION = 23
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
SUPPORTED_GO_MAJOR_VERSION = 1
SUPPORTED_GO_MINOR_VERSION = 21
GO_VERSION_VALIDATION_ERR_MSG = Golang version $(GO_MAJOR_VERSION).$(GO_MINOR_VERSION) is not supported, you must use $(SUPPORTED_GO_MAJOR_VERSION).$(SUPPORTED_GO_MINOR_VERSION)

# The below include contains the tools target.
Expand Down Expand Up @@ -128,7 +128,7 @@ all: build format lint test
##############################

# Install puts the binaries in the local environment path.
install: go.sum
install: validate-go-version go.sum
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install $(BUILD_FLAGS) ./cmd/provenanced

build: validate-go-version go.sum
Expand Down Expand Up @@ -222,7 +222,7 @@ $(RELEASE_PLAN): $(RELEASE_CHECKSUM)
build-release-libwasm: $(RELEASE_WASM)

$(RELEASE_WASM): $(RELEASE_BIN)
go mod vendor && \
$(GO) mod vendor && \
cp vendor/github.com/CosmWasm/wasmvm/v2/internal/api/$(LIBWASMVM) $(RELEASE_BIN)

.PHONY: build-release-bin
Expand Down Expand Up @@ -482,7 +482,7 @@ proto-gen:
sh ./scripts/protocgen.sh; \
fi
mv .go.mod.bak go.mod
go mod tidy
$(GO)go mod tidy

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
Expand All @@ -492,7 +492,7 @@ proto-swagger-gen:
docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protoc-swagger-gen.sh; \
fi
go mod tidy
$(GO) mod tidy

proto-format:
@echo "Formatting Protobuf files"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ As the [Provenance Blockchain][provenance] and its core modules are based on the

Developers can use a local checkout and the make targets `make run` and `make localnet-start` to run a local development network.

Note: Requires [Go 1.21+](https://golang.org/dl/)
Note: Requires [Go 1.23](https://golang.org/dl/) (specifically).

See Also: [Building](docs/Building.md)

Expand Down
6 changes: 3 additions & 3 deletions app/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
const (
AccountAddressPrefixMainNet = "pb"
AccountAddressPrefixTestNet = "tp"
CoinTypeMainNet = 505
CoinTypeTestNet = 1
CoinTypeMainNet = uint32(505)
CoinTypeTestNet = uint32(1)
Purpose = 44
)

Expand Down Expand Up @@ -39,7 +39,7 @@ func SetConfig(testnet bool, seal bool) {
ConsNodePubKeyPrefix = AccountAddressPrefix + "valconspub"

config := sdk.GetConfig()
config.SetCoinType(uint32(CoinType))
config.SetCoinType(CoinType)
config.SetPurpose(Purpose)
config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix)
config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix)
Expand Down
6 changes: 3 additions & 3 deletions app/prefix_test/prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestSetConfig(t *testing.T) {
seal bool
expPath string
expHRP string
expCoinType int
expCoinType uint32
expPanic string
}{
{
Expand Down Expand Up @@ -151,8 +151,8 @@ func TestSetConfig(t *testing.T) {
assert.Equal(t, expConsPubPre, consPubPre, "sdkConfig.GetBech32ConsensusPubPrefix()")

assert.Equal(t, tc.expPath, fullBIP44Path, "sdkConfig.GetFullBIP44Path()")
assert.Equal(t, tc.expCoinType, app.CoinType, "CoinType")
assert.Equal(t, tc.expCoinType, int(coinType), "sdkConfig.GetCoinType()")
assert.Equal(t, tc.expCoinType, app.CoinType, "CoinType - Exp = %d, Act = %d", tc.expCoinType, app.CoinType)
assert.Equal(t, tc.expCoinType, coinType, "sdkConfig.GetCoinType() - Exp = %d, Act = %d", tc.expCoinType, coinType)
assert.Equal(t, 44, app.Purpose, "Purpose")
assert.Equal(t, 44, int(purpose), "sdkConfig.GetPurpose()")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/provenanced/cmd/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func GetTreeCmd() *cobra.Command {
cmd.SilenceUsage = true
return fmt.Errorf("command not found: %q", args)
}
cmd.Printf(strings.Join(cmds, "\n") + "\n")
cmd.Printf("%s\n", strings.Join(cmds, "\n"))
return nil
},
DisableFlagsInUseLine: true,
Expand Down
2 changes: 1 addition & 1 deletion contrib/devtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ tools-clean:
rm -f proto-tools-stamp tools-stamp

# If you change this version, be sure to also change it in .github/workflows/lint.yml.
GOLANGCI_LINT_VERSION = v1.54.2
GOLANGCI_LINT_VERSION = v1.60.2
golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT):
@$(MAKE) golangci-lint-update
Expand Down
2 changes: 1 addition & 1 deletion docker/blockchain/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-bullseye as build
FROM golang:1.23-bullseye as build

Check warning on line 1 in docker/blockchain/Dockerfile

View workflow job for this annotation

GitHub Actions / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
ARG VERSION

WORKDIR /go/src/github.com/provenance-io/provenance
Expand Down
2 changes: 1 addition & 1 deletion docs/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Built executables are placed in the `build/` directory.

### Go

Building `provenanced` requires [Go 1.21+](https://golang.org/dl/) (or higher).
Building `provenanced` requires [Go 1.23](https://golang.org/dl/) (specifically).

## Building or Installing `provenanced`

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/provenance-io/provenance

go 1.21
go 1.23

require (
cosmossdk.io/api v0.7.5
Expand Down
Loading

0 comments on commit c702324

Please sign in to comment.