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

Switch to gci, so we can actually auto-group imports #5493

Merged
merged 26 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ff2686
Switch to gofancyimports, so we can actually auto-group imports
Groxx Dec 18, 2023
7665b06
reformatting all files
Groxx Dec 18, 2023
4fa204e
Merge branch 'master' into imports
Groxx Dec 18, 2023
9c7a534
re-formatting
Groxx Dec 18, 2023
19eee6c
flaky test
Groxx Dec 18, 2023
2e9b822
derp
Groxx Dec 18, 2023
1b4a1cc
host integration is also racing in loggers
Groxx Dec 19, 2023
2b657ea
fixing build, largely a guess though tbh
Groxx Dec 19, 2023
a19b6d0
ugh. I always forget that go build ./... does not build tests.
Groxx Dec 19, 2023
991ad4b
well. gofancyimports does not remove unused imports.
Groxx Dec 19, 2023
968093f
Merge branch 'master' into imports
Groxx Dec 19, 2023
d099971
cleanup
Groxx Dec 19, 2023
f4fa916
Switch to gci. A bit more configurable and in golangci-lint
Groxx Dec 19, 2023
ddfc80e
quiet the thrashing on internal/tools
Groxx Dec 19, 2023
1bdd7f8
Merge branch 'master' into imports
Groxx Dec 19, 2023
d95cef7
unrelated change
Groxx Dec 19, 2023
74712e8
undo host/ test reverts, try from master
Groxx Dec 20, 2023
e9db9b5
Merge branch 'master' into imports
Groxx Dec 20, 2023
d65b4f5
fmt
Groxx Dec 20, 2023
b310308
reverting test-revert
Groxx Dec 20, 2023
ba13b03
fix "no changes" linter hopefully
Groxx Dec 20, 2023
35ba535
uh. prefix redirection?
Groxx Dec 20, 2023
554f600
aah. right. needs to be merged before it takes effect.
Groxx Dec 20, 2023
a14c7e2
Merge branch 'master' into imports
Groxx Dec 20, 2023
62528e6
fmt
Groxx Dec 20, 2023
5ccb6ad
Merge branch 'master' into imports
Groxx Dec 21, 2023
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
2 changes: 1 addition & 1 deletion .gen/proto/history/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .gen/proto/indexer/v1/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .gen/proto/matching/v1/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .gen/proto/shared/v1/error.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .gen/proto/shared/v1/history.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 23 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ $(BIN)/mockery: internal/tools/go.mod
$(BIN)/enumer: internal/tools/go.mod
$(call go_build_tool,github.com/dmarkham/enumer)

# organizes imports and reformats
$(BIN)/gci: internal/tools/go.mod
$(call go_build_tool,github.com/daixiang0/gci)

# removes unused imports and reformats
$(BIN)/goimports: internal/tools/go.mod
$(call go_build_tool,golang.org/x/tools/cmd/goimports)

Expand Down Expand Up @@ -352,10 +357,13 @@ $(BUILD)/lint: $(LINT_SRC) $(BIN)/revive | $(BUILD)
# if either changes, this will need to change.
MAYBE_TOUCH_COPYRIGHT=

$(BUILD)/fmt: $(ALL_SRC) $(BIN)/goimports | $(BUILD)
$Q echo "goimports..."
$Q # use FRESH_ALL_SRC so it won't miss any generated files produced earlier
$Q $(BIN)/goimports -local "github.com/uber/cadence" -w $(FRESH_ALL_SRC)
# use FRESH_ALL_SRC so it won't miss any generated files produced earlier.
$(BUILD)/fmt: $(ALL_SRC) $(BIN)/goimports $(BIN)/gci | $(BUILD)
$Q echo "removing unused imports..."
$Q # goimports thrashes on internal/tools, sadly. just hide it.
$Q $(BIN)/goimports -w $(filter-out ./internal/tools/tools.go,$(FRESH_ALL_SRC))
$Q echo "grouping imports..."
$Q $(BIN)/gci write --section standard --section 'Prefix(github.com/uber/cadence/)' --section default --section blank $(FRESH_ALL_SRC)
$Q touch $@
$Q $(MAYBE_TOUCH_COPYRIGHT)

Expand Down Expand Up @@ -386,8 +394,8 @@ endef
lint: ## (re)run the linter
$(call remake,proto-lint lint)

# intentionally not re-making, goimports is slow and it's clear when it's unnecessary
fmt: $(BUILD)/fmt ## run goimports
# intentionally not re-making, it's a bit slow and it's clear when it's unnecessary
fmt: $(BUILD)/fmt ## run gofmt / organize imports / etc

# not identical to the intermediate target, but does provide the same codegen (or more).
copyright: $(BIN)/copyright | $(BUILD) ## update copyright headers
Expand Down Expand Up @@ -463,6 +471,14 @@ release: ## Re-generate generated code and run tests
$(MAKE) --no-print-directory go-generate
$(MAKE) --no-print-directory test

build: ## Build all packages and all tests (ensures everything compiles)
$Q echo 'Building all packages...'
$Q go build ./...
$Q # "tests" by building and then running `true`, and hides test-success output
$Q echo 'Building all tests (~5x slower)...'
$Q # intentionally not -race due to !race build tags
$Q go test -exec /usr/bin/true ./... >/dev/null
Groxx marked this conversation as resolved.
Show resolved Hide resolved

clean: ## Clean build products
rm -f $(BINS)
rm -Rf $(BUILD)
Expand All @@ -472,7 +488,7 @@ clean: ## Clean build products

# v----- not yet cleaned up -----v

.PHONY: git-submodules test bins clean cover cover_ci help
.PHONY: git-submodules test bins build clean cover cover_ci help

TOOLS_CMD_ROOT=./cmd/tools
INTEG_TEST_ROOT=./host
Expand Down
3 changes: 1 addition & 2 deletions canary/crosscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"fmt"
"time"

shared "go.uber.org/cadence/.gen/go/shared"

"github.com/google/uuid"
shared "go.uber.org/cadence/.gen/go/shared"
"go.uber.org/cadence/activity"
"go.uber.org/cadence/workflow"
"go.uber.org/zap"
Expand Down
10 changes: 4 additions & 6 deletions canary/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
package canary

import (
"fmt"
"sync"
"time"

"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"sync"
"time"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
"go.uber.org/cadence/compatibility"
"go.uber.org/yarpc"
Expand All @@ -40,8 +40,6 @@ import (
"go.uber.org/zap"
"google.golang.org/grpc/credentials"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"

"github.com/uber/cadence/common/log/loggerimpl"
)

Expand Down
2 changes: 1 addition & 1 deletion client/admin/grpcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package admin
import (
"context"

adminv1 "github.com/uber/cadence-idl/go/proto/admin/v1"
"go.uber.org/yarpc"

adminv1 "github.com/uber/cadence-idl/go/proto/admin/v1"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/common/types/mapper/proto"
)
Expand Down
6 changes: 2 additions & 4 deletions client/clientfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ package client
import (
"time"

adminv1 "github.com/uber/cadence-idl/go/proto/admin/v1"
apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"go.uber.org/yarpc/api/transport"

"github.com/uber/cadence/.gen/go/admin/adminserviceclient"
"github.com/uber/cadence/.gen/go/cadence/workflowserviceclient"
"github.com/uber/cadence/.gen/go/history/historyserviceclient"
"github.com/uber/cadence/.gen/go/matching/matchingserviceclient"

adminv1 "github.com/uber/cadence-idl/go/proto/admin/v1"
apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
historyv1 "github.com/uber/cadence/.gen/proto/history/v1"
matchingv1 "github.com/uber/cadence/.gen/proto/matching/v1"

"github.com/uber/cadence/client/admin"
"github.com/uber/cadence/client/frontend"
"github.com/uber/cadence/client/history"
Expand Down
2 changes: 1 addition & 1 deletion client/frontend/grpcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ package frontend
import (
"context"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"go.uber.org/yarpc"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/common/types/mapper/proto"
)
Expand Down
3 changes: 1 addition & 2 deletions cmd/server/cadence/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ import (
"strings"
"syscall"

"github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql"

"github.com/urfave/cli"

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/client"
"github.com/uber/cadence/common/config"
"github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql"
"github.com/uber/cadence/common/service"
"github.com/uber/cadence/tools/cassandra"
"github.com/uber/cadence/tools/sql"
Expand Down
13 changes: 5 additions & 8 deletions cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ import (
"log"
"time"

"github.com/startreedata/pinot-client-go/pinot"
apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
"go.uber.org/cadence/compatibility"

apiv1 "github.com/uber/cadence-idl/go/proto/api/v1"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/service/worker"

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/archiver"
"github.com/uber/cadence/common/archiver/provider"
Expand All @@ -46,16 +44,15 @@ import (
"github.com/uber/cadence/common/messaging/kafka"
"github.com/uber/cadence/common/metrics"
"github.com/uber/cadence/common/peerprovider/ringpopprovider"
"github.com/uber/cadence/common/persistence"
pnt "github.com/uber/cadence/common/pinot"
"github.com/uber/cadence/common/resource"
"github.com/uber/cadence/common/rpc"
"github.com/uber/cadence/common/service"
"github.com/uber/cadence/service/frontend"
"github.com/uber/cadence/service/history"
"github.com/uber/cadence/service/matching"

"github.com/startreedata/pinot-client-go/pinot"

pnt "github.com/uber/cadence/common/pinot"
"github.com/uber/cadence/service/worker"
)

type (
Expand Down
5 changes: 3 additions & 2 deletions cmd/server/cadence/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ import (

"github.com/uber/cadence/common"
"github.com/uber/cadence/common/config"
_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra" // needed to load cassandra plugin
"github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql"
_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
"github.com/uber/cadence/common/service"
"github.com/uber/cadence/testflags"
"github.com/uber/cadence/tools/cassandra"

_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra" // needed to load cassandra plugin
_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
)

type ServerSuite struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/uber/cadence/cmd/server/cadence"
"github.com/uber/cadence/common/metrics"

_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra" // needed to load cassandra plugin
_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/mysql" // needed to load mysql plugin
Expand Down
3 changes: 2 additions & 1 deletion cmd/tools/cassandra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ package main
import (
"os"

_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
"github.com/uber/cadence/tools/cassandra"

_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/tools/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"fmt"
"os"

"github.com/uber/cadence/tools/cli"

_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra" // needed to load cassandra plugin
_ "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql/public" // needed to load the default gocql client
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/mysql" // needed to load mysql plugin
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/postgres" // needed to load postgres plugin
"github.com/uber/cadence/tools/cli"
)

// Start using this CLI tool with command
Expand Down
3 changes: 2 additions & 1 deletion cmd/tools/sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ package main
import (
"os"

"github.com/uber/cadence/tools/sql"

_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/mysql" // needed to load mysql plugin
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/postgres" // needed to load postgres plugin
"github.com/uber/cadence/tools/sql"
)

func main() {
Expand Down
4 changes: 1 addition & 3 deletions common/archiver/URI.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

package archiver

import (
"net/url"
)
import "net/url"

type (
// URI identifies the archival resource to which records are written to and read from.
Expand Down
4 changes: 1 addition & 3 deletions common/archiver/archivalMetadata_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

package archiver

import (
"github.com/stretchr/testify/mock"
)
import "github.com/stretchr/testify/mock"

// MockArchivalMetadata is an autogenerated mock type for the ArchivalMetadata type
type MockArchivalMetadata struct {
Expand Down
4 changes: 1 addition & 3 deletions common/archiver/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

package archiver

import (
"errors"
)
import "errors"

const (
// ArchiveNonRetriableErrorMsg is the log message when the Archive() method encounters a non-retriable error
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions common/archiver/gcloud/connector/mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions common/archiver/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
"errors"
"sync"

"github.com/uber/cadence/common/archiver/gcloud"

"github.com/uber/cadence/common/archiver"
"github.com/uber/cadence/common/archiver/filestore"
"github.com/uber/cadence/common/archiver/gcloud"
"github.com/uber/cadence/common/archiver/s3store"
"github.com/uber/cadence/common/config"
)
Expand Down
Loading