Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(ci): add goimports sorting lint
Browse files Browse the repository at this point in the history
Signed-off-by: ashing <[email protected]>
  • Loading branch information
ronething committed Apr 20, 2024
1 parent 348d745 commit fa559b3
Show file tree
Hide file tree
Showing 34 changed files with 71 additions and 18 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ jobs:
- name: Lint
run: make lint

sort-import-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
cache: true

- name: Sort Import Lint
run: make sort-import

- name: Check for changes
run: |
git diff --exit-code || { echo "Go imports revisions detected. Please run make sort-import and commit changes."; exit 1; }
integration_tests:
name: Integration tests
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ gen_bindings:
TAIKO_GETH_DIR=${TAIKO_GETH_DIR} \
./scripts/gen_bindings.sh

sort-import:
@./scripts/goimports-reviser.sh

.PHONY: build \
clean \
lint \
test \
dev_net \
gen_bindings
gen_bindings \
sort-import
3 changes: 2 additions & 1 deletion cmd/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"os"

"github.com/ethereum/go-ethereum/log"
"github.com/taikoxyz/taiko-client/cmd/flags"
"github.com/urfave/cli/v2"

"github.com/taikoxyz/taiko-client/cmd/flags"
)

// InitLogger initializes the root logger with the command line flags.
Expand Down
8 changes: 4 additions & 4 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
anchorTxConstructor "github.com/taikoxyz/taiko-client/driver/anchor_tx_constructor"
"github.com/taikoxyz/taiko-client/driver/chain_syncer/beaconsync"
"github.com/taikoxyz/taiko-client/driver/state"
txlistfetcher "github.com/taikoxyz/taiko-client/driver/txlist_fetcher"
"github.com/taikoxyz/taiko-client/internal/metrics"
"github.com/taikoxyz/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-client/pkg/rpc"

anchorTxConstructor "github.com/taikoxyz/taiko-client/driver/anchor_tx_constructor"
txlistfetcher "github.com/taikoxyz/taiko-client/driver/txlist_fetcher"
eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator"
"github.com/taikoxyz/taiko-client/pkg/rpc"
txListValidator "github.com/taikoxyz/taiko-client/pkg/txlist_validator"
)

Expand Down
1 change: 0 additions & 1 deletion driver/chain_syncer/chain_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package chainsyncer
import (
"bytes"
"context"

"os"
"testing"
"time"
Expand Down
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"

chainSyncer "github.com/taikoxyz/taiko-client/driver/chain_syncer"
"github.com/taikoxyz/taiko-client/driver/state"
"github.com/taikoxyz/taiko-client/pkg/rpc"
"github.com/urfave/cli/v2"
)

const (
Expand Down
1 change: 1 addition & 0 deletions driver/txlist_fetcher/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/ethereum/go-ethereum/core/types"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-client/pkg"
Expand Down
1 change: 1 addition & 0 deletions driver/txlist_fetcher/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/ethereum/go-ethereum/core/types"

"github.com/taikoxyz/taiko-client/bindings"
)

Expand Down
1 change: 1 addition & 0 deletions internal/utils/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"

"github.com/taikoxyz/taiko-client/internal/testutils"
"github.com/taikoxyz/taiko-client/internal/utils"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"crypto/rand"
"errors"
"fmt"
"math"

"io"
"math"
"math/big"
"os"
"strings"
Expand Down
3 changes: 2 additions & 1 deletion pkg/flags/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/taikoxyz/taiko-client/cmd/flags"
"github.com/urfave/cli/v2"

"github.com/taikoxyz/taiko-client/cmd/flags"
)

// InitTxmgrConfigsFromCli initializes the transaction manager configs from the command line flags.
Expand Down
1 change: 1 addition & 0 deletions pkg/rpc/blob_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/go-resty/resty/v2"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/blob"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/pkg"
)
Expand Down
1 change: 1 addition & 0 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cenkalti/backoff/v4"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/rpc/methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"

"github.com/taikoxyz/taiko-client/bindings/encoding"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/rpc/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/stretchr/testify/require"

"github.com/taikoxyz/taiko-client/bindings"
)

Expand Down
3 changes: 1 addition & 2 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (

"github.com/taikoxyz/taiko-client/cmd/flags"
"github.com/taikoxyz/taiko-client/internal/utils"
pkgFlags "github.com/taikoxyz/taiko-client/pkg/flags"
"github.com/taikoxyz/taiko-client/pkg/jwt"
"github.com/taikoxyz/taiko-client/pkg/rpc"

pkgFlags "github.com/taikoxyz/taiko-client/pkg/flags"
)

// Config contains all configurations to initialize a Taiko proposer.
Expand Down
2 changes: 1 addition & 1 deletion proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/urfave/cli/v2"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/taikoxyz/taiko-client/pkg/rpc"
selector "github.com/taikoxyz/taiko-client/proposer/prover_selector"
builder "github.com/taikoxyz/taiko-client/proposer/transaction_builder"
"github.com/urfave/cli/v2"
)

var (
Expand Down
1 change: 1 addition & 0 deletions proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/kzg4844"

"github.com/taikoxyz/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-client/pkg/rpc"
selector "github.com/taikoxyz/taiko-client/proposer/prover_selector"
Expand Down
1 change: 1 addition & 0 deletions proposer/transaction_builder/calldata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/ethereum/go-ethereum/common"

"github.com/taikoxyz/taiko-client/bindings/encoding"
)

Expand Down
1 change: 1 addition & 0 deletions proposer/transaction_builder/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"

"github.com/taikoxyz/taiko-client/pkg/rpc"
)

Expand Down
1 change: 1 addition & 0 deletions proposer/transaction_builder/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/ethereum-optimism/optimism/op-service/txmgr"

"github.com/taikoxyz/taiko-client/bindings/encoding"
)

Expand Down
1 change: 0 additions & 1 deletion prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/taikoxyz/taiko-client/cmd/flags"
"github.com/taikoxyz/taiko-client/internal/utils"

pkgFlags "github.com/taikoxyz/taiko-client/pkg/flags"
)

Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/assignment_expired.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/pkg/rpc"
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
Expand Down
6 changes: 3 additions & 3 deletions prover/event_handler/block_proposed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"time"

proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
state "github.com/taikoxyz/taiko-client/prover/shared_state"

"github.com/ethereum/go-ethereum/common"

"github.com/taikoxyz/taiko-client/bindings"
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
state "github.com/taikoxyz/taiko-client/prover/shared_state"
)

func (s *EventHandlerTestSuite) TestBlockProposedHandle() {
Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/block_verified.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/internal/metrics"
)
Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/block_verified_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handler

import (
"github.com/ethereum/go-ethereum/core/types"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/internal/testutils"
)
Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/transition_contested.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/pkg/rpc"
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/transition_proved.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/internal/metrics"
"github.com/taikoxyz/taiko-client/pkg/rpc"
Expand Down
1 change: 1 addition & 0 deletions prover/event_handler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-client/bindings"
"github.com/taikoxyz/taiko-client/bindings/encoding"
"github.com/taikoxyz/taiko-client/internal/testutils"
Expand Down
1 change: 1 addition & 0 deletions prover/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum/go-ethereum/common"

"github.com/taikoxyz/taiko-client/bindings/encoding"
)

Expand Down
1 change: 1 addition & 0 deletions prover/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/go-resty/resty/v2"
"github.com/phayes/freeport"
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-client/pkg/rpc"
proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer"
)
Expand Down
1 change: 1 addition & 0 deletions prover/shared_state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"sync/atomic"

"github.com/ethereum/go-ethereum/core/types"

"github.com/taikoxyz/taiko-client/pkg/rpc"
)

Expand Down
1 change: 1 addition & 0 deletions prover/shared_state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-client/pkg/rpc"
)

Expand Down
11 changes: 11 additions & 0 deletions scripts/goimports-reviser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

go install github.com/incu6us/goimports-reviser/v3@latest

PROJECT_NAME=github.com/taikoxyz/taiko-client

find . -name '*.go' -print0 | while IFS= read -r -d '' file; do
goimports-reviser -project-name "$PROJECT_NAME" "$file"
done

0 comments on commit fa559b3

Please sign in to comment.