diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..84c5f318 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,35 @@ +name: Check Make Format +# this workflow checks that go files is formated by `make format` +on: + pull_request: + push: + branches: + - main + +jobs: + check-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + - name: Display go version + run: go version + - uses: actions/cache@v3 + id: cache + with: + path: ~/go/bin + key: ${{ runner.os }}-go-v1.20-misspell-v0.3.4-goimports-reviser-v3.4.5 + - name: install misspell + if: steps.cache.outputs.cache-hit != 'true' + run: | + go install github.com/client9/misspell/cmd/misspell@v0.3.4 + - name: install goimports-reviser + if: steps.cache.outputs.cache-hit != 'true' + run: | + go install github.com/incu6us/goimports-reviser/v3@v3.4.5 + - name: Make Format + run: make format + - name: Check Diff + run: git diff --exit-code diff --git a/CHANGELOG.md b/CHANGELOG.md index eabfff55..4612385d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features ### Improvements +* (improvements) [\#230](https://github.com/Finschia/finschia/pull/230) fix Makefile for format and execute make format #230 ### Bug Fixes diff --git a/Makefile b/Makefile index f0a59f25..fc893b66 100644 --- a/Makefile +++ b/Makefile @@ -207,9 +207,9 @@ lint: find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s format: - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/Finschia/finschia-sdk + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs gofmt -w -s + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs misspell -w + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" | xargs -n1 goimports-reviser -rm-unused -set-alias -project-name "github.com/Finschia/finschia/" -company-prefixes "github.com/Finschia/" .PHONY: lint format diff --git a/ante/ante.go b/ante/ante.go index d193953a..b8610ce3 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -1,13 +1,14 @@ package ante import ( + ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" + sdk "github.com/Finschia/finschia-sdk/types" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" "github.com/Finschia/finschia-sdk/x/auth/ante" wasmkeeper "github.com/Finschia/wasmd/x/wasm/keeper" wasmtypes "github.com/Finschia/wasmd/x/wasm/types" - ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" ) // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC diff --git a/ante/ante_test.go b/ante/ante_test.go index 8d451484..9e6a184c 100644 --- a/ante/ante_test.go +++ b/ante/ante_test.go @@ -4,6 +4,9 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/tx" cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" @@ -13,8 +16,6 @@ import ( "github.com/Finschia/finschia-sdk/types/tx/signing" xauthsigning "github.com/Finschia/finschia-sdk/x/auth/signing" ocrand "github.com/Finschia/ostracon/libs/rand" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" linkapp "github.com/Finschia/finschia/v2/app" linkhelpers "github.com/Finschia/finschia/v2/app/helpers" diff --git a/app/app.go b/app/app.go index 5e638c0d..de4833da 100644 --- a/app/app.go +++ b/app/app.go @@ -9,12 +9,24 @@ import ( "os" "path/filepath" + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" + ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" - ocabci "github.com/Finschia/ostracon/abci/types" - "github.com/Finschia/ostracon/libs/log" - ostos "github.com/Finschia/ostracon/libs/os" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -102,33 +114,19 @@ import ( upgradeclient "github.com/Finschia/finschia-sdk/x/upgrade/client" upgradekeeper "github.com/Finschia/finschia-sdk/x/upgrade/keeper" upgradetypes "github.com/Finschia/finschia-sdk/x/upgrade/types" + ocabci "github.com/Finschia/ostracon/abci/types" + "github.com/Finschia/ostracon/libs/log" + ostos "github.com/Finschia/ostracon/libs/os" "github.com/Finschia/wasmd/x/wasm" wasmclient "github.com/Finschia/wasmd/x/wasm/client" wasmkeeper "github.com/Finschia/wasmd/x/wasm/keeper" "github.com/Finschia/wasmd/x/wasmplus" wasmpluskeeper "github.com/Finschia/wasmd/x/wasmplus/keeper" wasmplustypes "github.com/Finschia/wasmd/x/wasmplus/types" - ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" - icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host" - icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper" - icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" - "github.com/cosmos/ibc-go/v4/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v4/modules/core" - ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" - ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" appante "github.com/Finschia/finschia/v2/ante" appparams "github.com/Finschia/finschia/v2/app/params" - - // unnamed import of statik for swagger UI support - _ "github.com/Finschia/finschia/v2/client/docs/statik" + _ "github.com/Finschia/finschia/v2/client/docs/statik" // unnamed import of statik for swagger UI support ) const appName = "Finschia" diff --git a/app/app_test.go b/app/app_test.go index bc5fdc30..c5247f00 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -5,10 +5,10 @@ import ( "os" "testing" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibc "github.com/cosmos/ibc-go/v4/modules/core" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - - "github.com/Finschia/ostracon/libs/log" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" @@ -32,16 +32,14 @@ import ( foundationmodule "github.com/Finschia/finschia-sdk/x/foundation/module" "github.com/Finschia/finschia-sdk/x/genutil" "github.com/Finschia/finschia-sdk/x/gov" - "github.com/Finschia/wasmd/x/wasmplus" - "github.com/Finschia/finschia-sdk/x/mint" "github.com/Finschia/finschia-sdk/x/params" "github.com/Finschia/finschia-sdk/x/slashing" "github.com/Finschia/finschia-sdk/x/staking" tokenmodule "github.com/Finschia/finschia-sdk/x/token/module" "github.com/Finschia/finschia-sdk/x/upgrade" - "github.com/cosmos/ibc-go/v4/modules/apps/transfer" - ibc "github.com/cosmos/ibc-go/v4/modules/core" + "github.com/Finschia/ostracon/libs/log" + "github.com/Finschia/wasmd/x/wasmplus" ) func TestSimAppExportAndBlockedAddrs(t *testing.T) { diff --git a/app/genesis_account_test.go b/app/genesis_account_test.go index f3e3ce7a..268c2b3b 100644 --- a/app/genesis_account_test.go +++ b/app/genesis_account_test.go @@ -4,13 +4,13 @@ import ( "testing" "time" - "github.com/Finschia/ostracon/crypto" "github.com/stretchr/testify/require" "github.com/Finschia/finschia-sdk/crypto/keys/secp256k1" "github.com/Finschia/finschia-sdk/simapp" sdk "github.com/Finschia/finschia-sdk/types" authtypes "github.com/Finschia/finschia-sdk/x/auth/types" + "github.com/Finschia/ostracon/crypto" ) func TestSimGenesisAccountValidate(t *testing.T) { diff --git a/app/helpers/test_helpers.go b/app/helpers/test_helpers.go index 0ec2d176..46388149 100644 --- a/app/helpers/test_helpers.go +++ b/app/helpers/test_helpers.go @@ -5,13 +5,14 @@ import ( "testing" "time" - "github.com/Finschia/ostracon/libs/log" - octypes "github.com/Finschia/ostracon/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + "github.com/Finschia/ostracon/libs/log" + octypes "github.com/Finschia/ostracon/types" + linkapp "github.com/Finschia/finschia/v2/app" ) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 6e5d0706..dacfb154 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -15,6 +15,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "github.com/Finschia/finschia-sdk/client/flags" "github.com/Finschia/finschia-sdk/crypto/keys/ed25519" sdk "github.com/Finschia/finschia-sdk/types" @@ -22,7 +24,6 @@ import ( gov "github.com/Finschia/finschia-sdk/x/gov/types" minttypes "github.com/Finschia/finschia-sdk/x/mint/types" osttypes "github.com/Finschia/ostracon/types" - "github.com/stretchr/testify/require" "github.com/Finschia/finschia/v2/app" ) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 8f33fb53..56c20fad 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -52,14 +52,13 @@ import ( stakingcli "github.com/Finschia/finschia-sdk/x/staking/client/cli" staking "github.com/Finschia/finschia-sdk/x/staking/types" "github.com/Finschia/finschia-sdk/x/stakingplus" - wasmcli "github.com/Finschia/wasmd/x/wasm/client/cli" - ostcmd "github.com/Finschia/ostracon/cmd/ostracon/commands" ostcfg "github.com/Finschia/ostracon/config" "github.com/Finschia/ostracon/libs/log" osthttp "github.com/Finschia/ostracon/rpc/client/http" ostctypes "github.com/Finschia/ostracon/rpc/core/types" osttypes "github.com/Finschia/ostracon/types" + wasmcli "github.com/Finschia/wasmd/x/wasm/client/cli" wasmtypes "github.com/Finschia/wasmd/x/wasm/types" "github.com/Finschia/finschia/v2/app" diff --git a/cmd/fnsad/cmd/genaccounts_test.go b/cmd/fnsad/cmd/genaccounts_test.go index bc9273c4..7981ac4a 100644 --- a/cmd/fnsad/cmd/genaccounts_test.go +++ b/cmd/fnsad/cmd/genaccounts_test.go @@ -3,26 +3,24 @@ package cmd_test import ( "context" "fmt" - "testing" - "github.com/Finschia/finschia-sdk/crypto/hd" - "github.com/Finschia/finschia-sdk/crypto/keyring" - sdk "github.com/Finschia/finschia-sdk/types" - - "github.com/Finschia/ostracon/libs/log" "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/flags" + "github.com/Finschia/finschia-sdk/crypto/hd" + "github.com/Finschia/finschia-sdk/crypto/keyring" "github.com/Finschia/finschia-sdk/server" "github.com/Finschia/finschia-sdk/simapp" simcmd "github.com/Finschia/finschia-sdk/simapp/simd/cmd" "github.com/Finschia/finschia-sdk/testutil/testdata" + sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/types/module" "github.com/Finschia/finschia-sdk/x/genutil" genutiltest "github.com/Finschia/finschia-sdk/x/genutil/client/testutil" + "github.com/Finschia/ostracon/libs/log" ) var testMbm = module.NewBasicManager(genutil.AppModuleBasic{}) diff --git a/cmd/fnsad/cmd/root.go b/cmd/fnsad/cmd/root.go index 131437ea..0abaa1f8 100644 --- a/cmd/fnsad/cmd/root.go +++ b/cmd/fnsad/cmd/root.go @@ -7,6 +7,12 @@ import ( "os" "path/filepath" + "github.com/prometheus/client_golang/prometheus" + "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/spf13/viper" + dbm "github.com/tendermint/tm-db" + "github.com/Finschia/finschia-sdk/baseapp" "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/config" @@ -31,11 +37,6 @@ import ( "github.com/Finschia/ostracon/libs/log" "github.com/Finschia/wasmd/x/wasm" wasmkeeper "github.com/Finschia/wasmd/x/wasm/keeper" - "github.com/prometheus/client_golang/prometheus" - "github.com/spf13/cast" - "github.com/spf13/cobra" - "github.com/spf13/viper" - dbm "github.com/tendermint/tm-db" "github.com/Finschia/finschia/v2/app" "github.com/Finschia/finschia/v2/app/params" diff --git a/cmd/fnsad/cmd/root_test.go b/cmd/fnsad/cmd/root_test.go index b91280da..1fc47373 100644 --- a/cmd/fnsad/cmd/root_test.go +++ b/cmd/fnsad/cmd/root_test.go @@ -4,12 +4,13 @@ import ( "os" "testing" + "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + "github.com/Finschia/finschia-sdk/client/flags" "github.com/Finschia/finschia-sdk/server" "github.com/Finschia/finschia-sdk/store/types" "github.com/Finschia/ostracon/libs/log" - "github.com/stretchr/testify/require" - dbm "github.com/tendermint/tm-db" ) func TestNewApp(t *testing.T) { diff --git a/cmd/fnsad/cmd/testnet.go b/cmd/fnsad/cmd/testnet.go index 85d82862..17f0cec4 100644 --- a/cmd/fnsad/cmd/testnet.go +++ b/cmd/fnsad/cmd/testnet.go @@ -10,12 +10,6 @@ import ( "os" "path/filepath" - "github.com/Finschia/finschia-sdk/testutil" - ostconfig "github.com/Finschia/ostracon/config" - ostos "github.com/Finschia/ostracon/libs/os" - ostrand "github.com/Finschia/ostracon/libs/rand" - "github.com/Finschia/ostracon/types" - osttime "github.com/Finschia/ostracon/types/time" "github.com/spf13/cobra" "github.com/Finschia/finschia-sdk/client" @@ -26,6 +20,7 @@ import ( cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" "github.com/Finschia/finschia-sdk/server" srvconfig "github.com/Finschia/finschia-sdk/server/config" + "github.com/Finschia/finschia-sdk/testutil" sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/types/module" authtypes "github.com/Finschia/finschia-sdk/x/auth/types" @@ -33,6 +28,11 @@ import ( "github.com/Finschia/finschia-sdk/x/genutil" genutiltypes "github.com/Finschia/finschia-sdk/x/genutil/types" stakingtypes "github.com/Finschia/finschia-sdk/x/staking/types" + ostconfig "github.com/Finschia/ostracon/config" + ostos "github.com/Finschia/ostracon/libs/os" + ostrand "github.com/Finschia/ostracon/libs/rand" + "github.com/Finschia/ostracon/types" + osttime "github.com/Finschia/ostracon/types/time" ) var ( diff --git a/cmd/fnsad/cmd/testnet_test.go b/cmd/fnsad/cmd/testnet_test.go index 0caf7e59..d0eae1a9 100644 --- a/cmd/fnsad/cmd/testnet_test.go +++ b/cmd/fnsad/cmd/testnet_test.go @@ -5,6 +5,9 @@ import ( "fmt" "testing" + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/client/flags" "github.com/Finschia/finschia-sdk/server" @@ -12,8 +15,6 @@ import ( genutiltest "github.com/Finschia/finschia-sdk/x/genutil/client/testutil" genutiltypes "github.com/Finschia/finschia-sdk/x/genutil/types" "github.com/Finschia/ostracon/libs/log" - "github.com/spf13/viper" - "github.com/stretchr/testify/require" "github.com/Finschia/finschia/v2/app" )