Skip to content

Commit

Permalink
Merge branch 'master' into async_telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Jul 4, 2022
2 parents e1acb48 + e50b943 commit ea3ab4c
Show file tree
Hide file tree
Showing 109 changed files with 1,222 additions and 425 deletions.
41 changes: 40 additions & 1 deletion DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,14 @@ def go_deps():
sum = "h1:0rkFMAbn5KBKNpJyHQ6Prb95vIKanmAe62KxsrN+sqA=",
version = "v0.0.0-20171016134553-529a34b1c186",
)
go_repository(
name = "com_github_daixiang0_gci",
build_file_proto_mode = "disable",
importpath = "github.com/daixiang0/gci",
sum = "h1:+EZ83znNs73C9ZBTM7xhNagMP6gJs5wlptiFiuce5BM=",
version = "v0.3.4",
)

go_repository(
name = "com_github_danjacques_gofslock",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -934,6 +942,13 @@ def go_deps():
sum = "h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=",
version = "v0.0.0-20190930125516-244bba706f1a",
)
go_repository(
name = "com_github_golangci_misspell",
build_file_proto_mode = "disable",
importpath = "github.com/golangci/misspell",
sum = "h1:pLzmVdl3VxTOncgzHcvLOKirdvcx/TydsClUQXTehjo=",
version = "v0.3.5",
)

go_repository(
name = "com_github_golangci_prealloc",
Expand Down Expand Up @@ -1243,6 +1258,14 @@ def go_deps():
sum = "h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=",
version = "v1.1.2",
)
go_repository(
name = "com_github_hexops_gotextdiff",
build_file_proto_mode = "disable",
importpath = "github.com/hexops/gotextdiff",
sum = "h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=",
version = "v1.0.3",
)

go_repository(
name = "com_github_hpcloud_tail",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -1513,11 +1536,11 @@ def go_deps():
name = "com_github_kisielk_errcheck",
build_file_proto_mode = "disable_global",
importpath = "github.com/kisielk/errcheck",
sum = "h1:cErYo+J4SmEjdXZrVXGwLJCE2sB06s23LpkcyWNrT+s=",
patch_args = ["-p1"],
patches = [
"//build/patches:com_github_kisielk_errcheck.patch",
],
sum = "h1:cErYo+J4SmEjdXZrVXGwLJCE2sB06s23LpkcyWNrT+s=",
version = "v1.6.1",
)
go_repository(
Expand Down Expand Up @@ -1801,6 +1824,14 @@ def go_deps():
sum = "h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=",
version = "v0.0.0-20200227124842-a10e7caefd8e",
)
go_repository(
name = "com_github_nishanths_predeclared",
build_file_proto_mode = "disable",
importpath = "github.com/nishanths/predeclared",
sum = "h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=",
version = "v0.2.2",
)

go_repository(
name = "com_github_nxadm_tail",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -2285,6 +2316,14 @@ def go_deps():
sum = "h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=",
version = "v1.2.0",
)
go_repository(
name = "com_github_tdakkota_asciicheck",
build_file_proto_mode = "disable",
importpath = "github.com/tdakkota/asciicheck",
sum = "h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A=",
version = "v0.1.1",
)

go_repository(
name = "com_github_tiancaiamao_appdash",
build_file_proto_mode = "disable_global",
Expand Down
7 changes: 3 additions & 4 deletions br/pkg/lightning/backend/kv/sql2kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/meta/autoid"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/parser/mysql" //nolint: goimports
// Import tidb/planner/core to initialize expression.RewriteAstExpr
_ "github.com/pingcap/tidb/planner/core"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/table/tables"
Expand All @@ -42,9 +44,6 @@ import (
"github.com/pingcap/tidb/util/chunk"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

// Import tidb/planner/core to initialize expression.RewriteAstExpr
_ "github.com/pingcap/tidb/planner/core"
)

var ExtraHandleColumnInfo = model.NewExtraHandleColInfo()
Expand Down
3 changes: 1 addition & 2 deletions br/pkg/lightning/backend/local/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ import (
"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/sstable"
"github.com/google/uuid"
"github.com/pingcap/tidb/br/pkg/lightning/backend"
"github.com/pingcap/tidb/br/pkg/lightning/log"
"github.com/stretchr/testify/require"

"github.com/pingcap/tidb/br/pkg/lightning/backend"
)

func TestIngestSSTWithClosedEngine(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions br/pkg/lightning/errormanager/errormanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ import (
"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"
"github.com/pingcap/errors"
"go.uber.org/multierr"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

"github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
"github.com/pingcap/tidb/br/pkg/redact"
"github.com/pingcap/tidb/br/pkg/utils"
"go.uber.org/multierr"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
)

const (
Expand Down
5 changes: 2 additions & 3 deletions br/pkg/lightning/errormanager/errormanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import (
"testing"

"github.com/DATA-DOG/go-sqlmock"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"

"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/utils"
)

func TestInit(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions br/pkg/lightning/mydump/charset_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import (
"unicode/utf8"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"golang.org/x/text/encoding"
"golang.org/x/text/encoding/simplifiedchinese"

"github.com/pingcap/tidb/br/pkg/lightning/config"
)

// CharsetConvertor is used to convert a character set to utf8mb4 encoding.
Expand Down
5 changes: 2 additions & 3 deletions br/pkg/lightning/mydump/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
"github.com/pingcap/tidb/util/filter"
"github.com/pingcap/tidb/util/slice"
"go.uber.org/zap"

"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
)

type SourceType int
Expand Down
7 changes: 3 additions & 4 deletions br/pkg/lightning/restore/restore_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import (
"github.com/DATA-DOG/go-sqlmock"
"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
filter "github.com/pingcap/tidb/util/table-filter"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/pingcap/tidb/br/pkg/lightning/backend"
"github.com/pingcap/tidb/br/pkg/lightning/checkpoints"
"github.com/pingcap/tidb/br/pkg/lightning/config"
Expand All @@ -39,6 +35,9 @@ import (
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
tmock "github.com/pingcap/tidb/util/mock"
filter "github.com/pingcap/tidb/util/table-filter"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

type restoreSchemaSuite struct {
Expand Down
3 changes: 1 addition & 2 deletions br/pkg/restore/rawkv_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import (
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/restore"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/util/codec"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/rawkv"

"github.com/pingcap/tidb/util/codec"
)

// fakeRawkvClient is a mock for rawkv.client
Expand Down
5 changes: 2 additions & 3 deletions br/pkg/storage/azblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import (
"path"
"strings"

"github.com/google/uuid"
"github.com/spf13/pflag"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/google/uuid"
"github.com/pingcap/errors"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/log"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/spf13/pflag"
"go.uber.org/zap"
)

Expand Down
1 change: 0 additions & 1 deletion br/pkg/storage/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io"

"github.com/pingcap/errors"

berrors "github.com/pingcap/tidb/br/pkg/errors"
)

Expand Down
5 changes: 2 additions & 3 deletions br/pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ import (
"github.com/pingcap/errors"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/log"
"github.com/spf13/pflag"
"go.uber.org/zap"

berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/logutil"
"github.com/spf13/pflag"
"go.uber.org/zap"
)

const (
Expand Down
5 changes: 2 additions & 3 deletions br/pkg/stream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import (

"github.com/gogo/protobuf/proto"
"github.com/pingcap/errors"
"github.com/pingcap/log"
"go.uber.org/zap"

backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/log"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/redact"
"github.com/pingcap/tidb/kv"
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/zap"
)

// MetaDataClient is the client for operations over metadata.
Expand Down
3 changes: 1 addition & 2 deletions br/pkg/stream/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
"net/url"
"testing"

berrors "github.com/pingcap/tidb/br/pkg/errors"

"github.com/pingcap/errors"
"github.com/pingcap/log"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/br/pkg/stream"
Expand Down
1 change: 0 additions & 1 deletion br/pkg/task/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/pingcap/errors"
backuppb "github.com/pingcap/kvproto/pkg/brpb"

"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/tidb/br/pkg/conn"
"github.com/pingcap/tidb/br/pkg/pdutil"
Expand Down
4 changes: 4 additions & 0 deletions build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,15 @@ nogo(
"@org_golang_x_tools//go/analysis/passes/unreachable:go_default_library",
"@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library",
"@org_golang_x_tools//go/analysis/passes/unusedresult:go_default_library",
"//build/linter/asciicheck:asciicheck",
"//build/linter/durationcheck:durationcheck",
"//build/linter/exportloopref:exportloopref",
"//build/linter/gofmt:gofmt",
"//build/linter/gci:gci",
"//build/linter/ineffassign:ineffassign",
"//build/linter/misspell:misspell",
"//build/linter/prealloc:prealloc",
"//build/linter/predeclared:predeclared",
"//build/linter/unconvert:unconvert",
] + staticcheck_analyzers(STATICHECK_ANALYZERS) +
select({
Expand Down
9 changes: 9 additions & 0 deletions build/linter/asciicheck/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "asciicheck",
srcs = ["analysis.go"],
importpath = "github.com/pingcap/tidb/build/linter/asciicheck",
visibility = ["//visibility:public"],
deps = ["@com_github_tdakkota_asciicheck//:asciicheck"],
)
20 changes: 20 additions & 0 deletions build/linter/asciicheck/analysis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package asciicheck

import "github.com/tdakkota/asciicheck"

// Analyzer is the analyzer struct of asciicheck.
var Analyzer = asciicheck.NewAnalyzer()
13 changes: 13 additions & 0 deletions build/linter/gci/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "gci",
srcs = ["analysis.go"],
importpath = "github.com/pingcap/tidb/build/linter/gci",
visibility = ["//visibility:public"],
deps = [
"@com_github_daixiang0_gci//pkg/configuration",
"@com_github_daixiang0_gci//pkg/gci",
"@org_golang_x_tools//go/analysis",
],
)
Loading

0 comments on commit ea3ab4c

Please sign in to comment.