Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion .github/workflows/pr_build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go environment
uses: actions/setup-go@v6
Expand All @@ -50,7 +52,7 @@ jobs:
key: ubuntu-latest-ticdc-tools-${{ hashFiles('tools/check/go.sum') }}

- name: Check
run: make check
run: make check LINT_NEW_FROM_REV="${{ github.event.pull_request.base.sha }}"

classic_build_and_test:
if: >-
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ check-copyright:
@./scripts/check-copyright.sh

check-static: tools/bin/golangci-lint
tools/bin/golangci-lint run --timeout 10m0s --exclude-dirs "^tests/"
ifneq ($(LINT_NEW_FROM_REV),)
tools/bin/golangci-lint run --timeout 10m0s --new-from-rev=$(LINT_NEW_FROM_REV)
else
tools/bin/golangci-lint run --timeout 10m0s
endif
Comment on lines +313 to +317
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The --exclude-dirs "^tests/" flag was removed in this change. This might cause the linter to run on the tests/ directory, which was previously excluded. If the tests do not yet pass the linting rules, this will break the build. It is recommended to keep the exclusion unless you intended to enable linting for tests.

ifneq ($(LINT_NEW_FROM_REV),)
	tools/bin/golangci-lint run --timeout 10m0s --exclude-dirs "^tests/" --new-from-rev=$(LINT_NEW_FROM_REV)
else
	tools/bin/golangci-lint run --timeout 10m0s --exclude-dirs "^tests/"
endif


check-ticdc-dashboard:
@echo "check-ticdc-dashboard"
Expand All @@ -328,7 +332,7 @@ check-makefiles: format-makefiles
format-makefiles: $(MAKE_FILES)
$(SED_IN_PLACE) -e 's/^\(\t*\) /\1\t/g' -e 's/^\(\t*\) /\1/' -- $?

check: check-copyright fmt tidy generate_mock go-generate check-diff-line-width check-ticdc-dashboard check-makefiles
check: check-copyright fmt tidy generate_mock go-generate check-diff-line-width check-ticdc-dashboard check-makefiles check-static
@git --no-pager diff --exit-code || (echo "Please add changed files!" && false)

clean:
Expand Down
10 changes: 5 additions & 5 deletions api/v2/failpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/pingcap/failpoint"
"github.com/pingcap/ticdc/pkg/api"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
)

type FailpointRequest struct {
Expand Down Expand Up @@ -74,13 +74,13 @@ var failpointState = newFailpointRegistry()
func (h *OpenAPIV2) EnableFailpoint(c *gin.Context) {
req := &FailpointRequest{}
if err := c.BindJSON(req); err != nil {
_ = c.Error(cerror.ErrAPIInvalidParam.GenWithStack("invalid request: %s", err.Error()))
_ = c.Error(errors.ErrAPIInvalidParam.GenWithStack("invalid request: %s", err.Error()))
return
}
req.Name = strings.TrimSpace(req.Name)
req.Expr = strings.TrimSpace(req.Expr)
if req.Name == "" || req.Expr == "" {
_ = c.Error(cerror.ErrAPIInvalidParam.GenWithStackByArgs("name and expr are required"))
_ = c.Error(errors.ErrAPIInvalidParam.GenWithStackByArgs("name and expr are required"))
return
}

Expand All @@ -98,13 +98,13 @@ func (h *OpenAPIV2) DisableFailpoint(c *gin.Context) {
if name == "" {
req := &FailpointRequest{}
if err := c.BindJSON(req); err != nil {
_ = c.Error(cerror.ErrAPIInvalidParam.GenWithStack("invalid request: %s", err.Error()))
_ = c.Error(errors.ErrAPIInvalidParam.GenWithStack("invalid request: %s", err.Error()))
return
}
name = strings.TrimSpace(req.Name)
}
if name == "" {
_ = c.Error(cerror.ErrAPIInvalidParam.GenWithStackByArgs("name is required"))
_ = c.Error(errors.ErrAPIInvalidParam.GenWithStackByArgs("name is required"))
return
}

Expand Down
2 changes: 1 addition & 1 deletion api/v2/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"strings"

"github.com/gin-gonic/gin"
perrors "github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/ticdc/pkg/errors"
perrors "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/logger"
"github.com/pingcap/ticdc/pkg/util"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion api/v2/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"

"github.com/gin-gonic/gin"
perrors "github.com/pingcap/errors"
perrors "github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down
8 changes: 4 additions & 4 deletions api/v2/unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/pingcap/log"
"github.com/pingcap/ticdc/api/middleware"
"github.com/pingcap/ticdc/logservice/txnutil"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/txnutil/gc"
"go.uber.org/zap"
)
Expand All @@ -47,7 +47,7 @@ func (h *OpenAPIV2) CDCMetaData(c *gin.Context) {
func (h *OpenAPIV2) ResolveLock(c *gin.Context) {
var resolveLockReq ResolveLockReq
if err := c.BindJSON(&resolveLockReq); err != nil {
_ = c.Error(cerror.ErrAPIInvalidParam.Wrap(err))
_ = c.Error(errors.ErrAPIInvalidParam.Wrap(err))
return
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func (h *OpenAPIV2) ResolveLock(c *gin.Context) {
func (h *OpenAPIV2) DeleteServiceGcSafePoint(c *gin.Context) {
upstreamConfig := &UpstreamConfig{}
if err := c.BindJSON(upstreamConfig); err != nil {
_ = c.Error(cerror.WrapError(cerror.ErrAPIInvalidParam, err))
_ = c.Error(errors.WrapError(errors.ErrAPIInvalidParam, err))
return
}
pdClient := h.server.GetPdClient()
Expand All @@ -91,7 +91,7 @@ func (h *OpenAPIV2) DeleteServiceGcSafePoint(c *gin.Context) {
h.server.GetEtcdClient().GetGCServiceID(),
)
if err != nil {
_ = c.Error(cerror.WrapError(cerror.ErrInternalServerError, err))
_ = c.Error(errors.WrapError(errors.ErrInternalServerError, err))
}
c.JSON(http.StatusOK, &EmptyResponse{})
}
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_changefeed_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"strings"

"github.com/fatih/color"
"github.com/pingcap/errors"
"github.com/pingcap/log"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
apiv2client "github.com/pingcap/ticdc/pkg/api/v2"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/filter"
putil "github.com/pingcap/ticdc/pkg/util"
"github.com/spf13/cobra"
Expand Down
8 changes: 4 additions & 4 deletions cmd/cdc/cli/cli_changefeed_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"time"

v2 "github.com/pingcap/ticdc/api/v2"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/spf13/cobra"
"github.com/tikv/client-go/v2/oracle"
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func confirmLargeDataGap(cmd *cobra.Command, currentPhysical int64, startTs uint
confirmed := readYOrN(cmd)
if !confirmed {
cmd.Printf("Abort changefeed %s.\n", command)
return cerror.ErrCliAborted.FastGenByArgs(fmt.Sprintf("cli changefeed %s", command))
return errors.ErrCliAborted.FastGenByArgs(fmt.Sprintf("cli changefeed %s", command))
}
}

Expand All @@ -84,7 +84,7 @@ func confirmOverwriteCheckpointTs(
confirmed := readYOrN(cmd)
if !confirmed {
cmd.Printf("Abort changefeed resume.\n")
return cerror.ErrCliAborted.FastGenByArgs("cli changefeed resume")
return errors.ErrCliAborted.FastGenByArgs("cli changefeed resume")
}

return nil
Expand All @@ -99,7 +99,7 @@ func confirmIgnoreIneligibleTables(cmd *cobra.Command) (bool, error) {
confirmed := readYOrN(cmd)
if !confirmed {
cmd.Printf("No changefeed is created because you don't want to ignore some tables.\n")
return false, cerror.ErrCliAborted.FastGenByArgs("cli changefeed create")
return false, errors.ErrCliAborted.FastGenByArgs("cli changefeed create")
}

return true, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_changefeed_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/pkg/api"
"github.com/pingcap/ticdc/pkg/api/v2/mock"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_changefeed_pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
"github.com/pingcap/ticdc/pkg/api/v2/mock"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down
5 changes: 2 additions & 3 deletions cmd/cdc/cli/cli_changefeed_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
package cli

import (
"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
"github.com/pingcap/ticdc/pkg/api"
apiv2client "github.com/pingcap/ticdc/pkg/api/v2"
"github.com/pingcap/ticdc/pkg/config"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -91,7 +90,7 @@ func (o *queryChangefeedOptions) run(cmd *cobra.Command) error {
return util.JSONPrint(cmd, info)
}
}
return cerror.ErrChangeFeedNotExists.GenWithStackByArgs(o.changefeedID)
return errors.ErrChangeFeedNotExists.GenWithStackByArgs(o.changefeedID)
}

detail, err := o.apiClientV2.Changefeeds().Get(ctx, o.keyspace, o.changefeedID)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_changefeed_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/pkg/api"
"github.com/pingcap/ticdc/pkg/api/v2/mock"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/cdc/cli/cli_changefeed_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
apiv2client "github.com/pingcap/ticdc/pkg/api/v2"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -84,7 +84,7 @@ func (o *removeChangefeedOptions) run(cmd *cobra.Command) error {
// Tick and in that Tick, the in-memory data structure and the metadata stored in
// etcd is already deleted.
if err == nil {
err = cerror.ErrChangeFeedDeletionUnfinished.GenWithStackByArgs(o.changefeedID)
err = errors.ErrChangeFeedDeletionUnfinished.GenWithStackByArgs(o.changefeedID)
}

if strings.Contains(err.Error(), "ErrChangeFeedNotExists") {
Expand Down
7 changes: 3 additions & 4 deletions cmd/cdc/cli/cli_changefeed_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/pkg/api/v2/mock"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
)

Expand All @@ -36,11 +35,11 @@ func TestChangefeedRemoveCli(t *testing.T) {
cf.EXPECT().Get(gomock.Any(), "test", "abc").Return(&v2.ChangeFeedInfo{}, nil)
cf.EXPECT().Delete(gomock.Any(), "test", "abc").Return(nil)
cf.EXPECT().Get(gomock.Any(), "test", "abc").Return(nil,
cerror.ErrChangeFeedNotExists.GenWithStackByArgs("abc"))
errors.ErrChangeFeedNotExists.GenWithStackByArgs("abc"))
os.Args = []string{"remove", "--changefeed-id=abc", "--keyspace=test"}
require.Nil(t, cmd.Execute())
cf.EXPECT().Get(gomock.Any(), "default", "abc").Return(nil,
cerror.ErrChangeFeedNotExists.GenWithStackByArgs("abc"))
errors.ErrChangeFeedNotExists.GenWithStackByArgs("abc"))
os.Args = []string{"remove", "--changefeed-id=abc", "--keyspace=default"}
require.Nil(t, cmd.Execute())

Expand Down
8 changes: 4 additions & 4 deletions cmd/cdc/cli/cli_changefeed_resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
apiClient "github.com/pingcap/ticdc/pkg/api/v2"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
putil "github.com/pingcap/ticdc/pkg/util"
"github.com/spf13/cobra"
"github.com/tikv/client-go/v2/oracle"
Expand Down Expand Up @@ -180,15 +180,15 @@ func (o *resumeChangefeedOptions) validateParams(ctx context.Context) error {

checkpointTs, err := strconv.ParseUint(o.overwriteCheckpointTs, 10, 64)
if err != nil {
return cerror.ErrCliInvalidCheckpointTs.GenWithStackByArgs(o.overwriteCheckpointTs)
return errors.ErrCliInvalidCheckpointTs.GenWithStackByArgs(o.overwriteCheckpointTs)
}

if checkpointTs == 0 {
return cerror.ErrCliInvalidCheckpointTs.GenWithStackByArgs(o.overwriteCheckpointTs)
return errors.ErrCliInvalidCheckpointTs.GenWithStackByArgs(o.overwriteCheckpointTs)
}

if checkpointTs > oracle.ComposeTS(tso.Timestamp, tso.LogicTime) {
return cerror.ErrCliCheckpointTsIsInFuture.GenWithStackByArgs(checkpointTs)
return errors.ErrCliCheckpointTsIsInFuture.GenWithStackByArgs(checkpointTs)
}

o.checkpointTs = checkpointTs
Expand Down
5 changes: 2 additions & 3 deletions cmd/cdc/cli/cli_changefeed_resume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/pkg/api"
cerror "github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/oracle"
)
Expand Down Expand Up @@ -176,7 +175,7 @@ func TestChangefeedResumeWithNewCheckpointTs(t *testing.T) {
f.changefeeds.EXPECT().Resume(gomock.Any(), &v2.ResumeChangefeedConfig{
OverwriteCheckpointTs: 262144,
}, gomock.Any(), "abc").
Return(cerror.ErrStartTsBeforeGC)
Return(errors.ErrStartTsBeforeGC)
o.overwriteCheckpointTs = "262144"
require.NotNil(t, o.run(cmd))
}
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_changefeed_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/pingcap/errors"
"github.com/pingcap/log"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/errors"
putil "github.com/pingcap/ticdc/pkg/util"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package cli

import (
"github.com/pingcap/errors"
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_unsafe_delete_service_gc_safepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package cli
import (
"strings"

"github.com/pingcap/errors"
v2 "github.com/pingcap/ticdc/api/v2"
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
apiv2client "github.com/pingcap/ticdc/pkg/api/v2"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/cdc/cli/cli_unsafe_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package cli
import (
"context"

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/ticdc/cmd/cdc/factory"
"github.com/pingcap/ticdc/cmd/util"
"github.com/pingcap/ticdc/pkg/config/kerneltype"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/etcd"
"github.com/pingcap/ticdc/pkg/txnutil/gc"
"github.com/spf13/cobra"
Expand Down
Loading
Loading