Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding github action to run goimports #1673

Merged
merged 23 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7a67276
wip: adding github action to run goimports
chatton Jul 7, 2022
da54a3a
chore: adding makefile target for goimports
chatton Jul 7, 2022
613f4d5
chore: adding commands to format files
chatton Jul 7, 2022
439e02d
chore: running goimports on files which were not formatting
chatton Jul 7, 2022
8aa6867
chore: moving workflow into separate file
chatton Jul 7, 2022
52160fe
chore: reverted link-check to main
chatton Jul 7, 2022
c5dfe87
chore: resetting to main
chatton Jul 7, 2022
67a4cf9
chore: only run action on pull request
chatton Jul 7, 2022
bff7421
Merge branch 'main' into go-imports-github-action
chatton Jul 8, 2022
16d6d94
Merge branch 'main' into go-imports-github-action
chatton Jul 12, 2022
415dd3e
chore: adding make target to format imports
chatton Jul 12, 2022
3912fba
chore: fixing diff command
chatton Jul 12, 2022
2e95d76
chore: setting fetch-depth to 0
chatton Jul 12, 2022
b96e897
chore: reverting to older way of formatting code
chatton Jul 12, 2022
e9d9044
chore: changing shell to bash instead of sh
chatton Jul 12, 2022
47b92db
Merge branch 'main' into go-imports-github-action
chatton Jul 12, 2022
1588e02
Merge branch 'main' into go-imports-github-action
chatton Jul 13, 2022
ebe9f75
chore: adding newline to go-imports.sh
chatton Jul 13, 2022
bb2d65c
Merge branch 'go-imports-github-action' of https://github.com/cosmos/…
chatton Jul 13, 2022
8e7b6ab
Merge branch 'main' into go-imports-github-action
chatton Jul 13, 2022
73d0988
chore: correcting piping commands in make goimports
chatton Jul 14, 2022
1ec17e7
Merge branch 'main' into go-imports-github-action
chatton Jul 14, 2022
4aa0943
Merge branch 'main' into go-imports-github-action
chatton Jul 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/scripts/go-imports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
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)"

exit_code=0
for f in $formatted_files
do
# we don't care about formatting in pb.go files.
if [ "${f: -5}" == "pb.go" ]; then
continue
fi
exit_code=1
echo "formatted file ${f}..."
done

if [ "${exit_code}" == 1 ]; then
echo "not all files were correctly formated, run the following:"
echo "make goimports"
fi

exit $exit_code
9 changes: 9 additions & 0 deletions .github/workflows/goimports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Goimports
on: pull_request
jobs:
goimports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Go Imports"
run: .github/scripts/go-imports.sh
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
CHANGED_GO_FILES := $(shell git diff --name-only | grep .go$$ | grep -v pb.go)
ALL_GO_FILES := $(shell find . -regex ".*\.go$$" | grep -v pb.go)
VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
Expand Down Expand Up @@ -351,6 +353,12 @@ format:
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
.PHONY: format

goimports:
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(CHANGED_GO_FILES)" &>2 || echo "No changed go files to format"
colin-axner marked this conversation as resolved.
Show resolved Hide resolved

goimports-all:
$(DOCKER) run -v $(CURDIR):/ibc-go --rm -w "/ibc-go" cytopia/goimports -w -local 'github.com/cosmos/ibc-go' "$(ALL_GO_FILES)" &>2

###############################################################################
### Devdoc ###
###############################################################################
Expand Down
3 changes: 2 additions & 1 deletion modules/apps/29-fee/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"

"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
"github.com/spf13/cobra"
)

// GetCmdIncentivizedPacket returns the unrelayed incentivized packet for a given packetID
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
Expand Down
1 change: 1 addition & 0 deletions modules/apps/29-fee/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
)
Expand Down
1 change: 1 addition & 0 deletions modules/apps/29-fee/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v4/testing"
Expand Down
1 change: 1 addition & 0 deletions modules/core/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"

clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
Expand Down
1 change: 1 addition & 0 deletions testing/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"

ibctesting "github.com/cosmos/ibc-go/v4/testing"
)

Expand Down
5 changes: 3 additions & 2 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper"
Expand All @@ -102,7 +103,7 @@ import (
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
ibcmock "github.com/cosmos/ibc-go/v4/testing/mock"
simappparams "github.com/cosmos/ibc-go/v4/testing/simapp/params"
simappparams "github.com/cosmos/ibc-go/v4/testing/simapp/params"

authz "github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
Expand Down Expand Up @@ -164,7 +165,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
ibcmock.ModuleName: nil,
ibcmock.ModuleName: nil,
}
)

Expand Down