Skip to content

Commit b0b1810

Browse files
authored
Adding github action to run goimports (cosmos#1673)
1 parent 419c3c4 commit b0b1810

10 files changed

Lines changed: 47 additions & 4 deletions

File tree

.github/scripts/go-imports.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
formatted_files="$(docker run -v "$(pwd)":/ibc-go --rm -w "/ibc-go" --entrypoint="" cytopia/goimports goimports -l -local 'github.com/cosmos/ibc-go' /ibc-go)"
3+
4+
exit_code=0
5+
for f in $formatted_files
6+
do
7+
# we don't care about formatting in pb.go files.
8+
if [ "${f: -5}" == "pb.go" ]; then
9+
continue
10+
fi
11+
exit_code=1
12+
echo "formatted file ${f}..."
13+
done
14+
15+
if [ "${exit_code}" == 1 ]; then
16+
echo "not all files were correctly formated, run the following:"
17+
echo "make goimports"
18+
fi
19+
20+
exit $exit_code

.github/workflows/goimports.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Goimports
2+
on: pull_request
3+
jobs:
4+
goimports:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v3
8+
- name: "Go Imports"
9+
run: .github/scripts/go-imports.sh

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
44
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
5+
CHANGED_GO_FILES := $(shell git diff --name-only | grep .go$$ | grep -v pb.go)
6+
ALL_GO_FILES := $(shell find . -regex ".*\.go$$" | grep -v pb.go)
57
VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//')
68
COMMIT := $(shell git log -1 --format='%H')
79
LEDGER_ENABLED ?= true
@@ -351,6 +353,12 @@ format:
351353
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk
352354
.PHONY: format
353355

356+
goimports:
357+
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(CHANGED_GO_FILES)" &> /dev/null || echo "No changed go files to format"
358+
359+
goimports-all:
360+
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(ALL_GO_FILES)"
361+
354362
###############################################################################
355363
### Devdoc ###
356364
###############################################################################

modules/apps/29-fee/client/cli/query.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import (
88
"github.com/cosmos/cosmos-sdk/client/flags"
99
sdk "github.com/cosmos/cosmos-sdk/types"
1010
"github.com/cosmos/cosmos-sdk/version"
11+
"github.com/spf13/cobra"
12+
1113
"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
1214
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
13-
"github.com/spf13/cobra"
1415
)
1516

1617
// GetCmdIncentivizedPacket returns the unrelayed incentivized packet for a given packetID

modules/apps/29-fee/keeper/msg_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package keeper_test
33
import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
6-
6+
77
"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
88
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
99
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"

modules/apps/29-fee/types/expected_keepers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
"github.com/cosmos/cosmos-sdk/x/auth/types"
66
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
7+
78
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
89
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
910
)

modules/apps/29-fee/types/msgs_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55

66
sdk "github.com/cosmos/cosmos-sdk/types"
7+
78
"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
89
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
910
ibctesting "github.com/cosmos/ibc-go/v4/testing"

modules/core/keeper/keeper_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
1212
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1313
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
14+
1415
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
1516
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
1617
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

testing/chain_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
sdk "github.com/cosmos/cosmos-sdk/types"
99
"github.com/cosmos/cosmos-sdk/x/staking/types"
10+
1011
ibctesting "github.com/cosmos/ibc-go/v4/testing"
1112
)
1213

testing/simapp/app.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import (
8080
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
8181
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
8282
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
83+
8384
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
8485
icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller"
8586
icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper"
@@ -102,7 +103,7 @@ import (
102103
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
103104
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
104105
ibcmock "github.com/cosmos/ibc-go/v4/testing/mock"
105-
simappparams "github.com/cosmos/ibc-go/v4/testing/simapp/params"
106+
simappparams "github.com/cosmos/ibc-go/v4/testing/simapp/params"
106107

107108
authz "github.com/cosmos/cosmos-sdk/x/authz"
108109
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
@@ -164,7 +165,7 @@ var (
164165
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
165166
ibcfeetypes.ModuleName: nil,
166167
icatypes.ModuleName: nil,
167-
ibcmock.ModuleName: nil,
168+
ibcmock.ModuleName: nil,
168169
}
169170
)
170171

0 commit comments

Comments
 (0)