diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9bf60391349..eaada46461a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM mcr.microsoft.com/devcontainers/go:1-1.22-bookworm +FROM mcr.microsoft.com/devcontainers/go:1-1.24-bookworm ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib:/usr/local/lib/pkgconfig ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 7084ba598eb..87af9217072 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -44,5 +44,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.53.3 + version: v1.64.3 working-directory: ./backend diff --git a/backend/Dockerfile b/backend/Dockerfile index c93b30c6a3f..829d0942db8 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -31,7 +31,7 @@ FROM --platform=linux/arm64 debian:bookworm as debian-arm64 RUN apt-get update RUN apt-get install -y libssh2-1-dev libssl-dev zlib1g-dev -FROM --platform=$BUILDPLATFORM golang:1.20.5-bookworm as builder +FROM --platform=$BUILDPLATFORM golang:1.24-bookworm as builder # docker build --build-arg GOPROXY=https://goproxy.io,direct -t mericodev/lake . ARG GOPROXY= @@ -49,7 +49,7 @@ RUN if [ "$(arch)" != "x86_64" ] ; then \ apt-get install -y gcc-x86-64-linux-gnu binutils-x86-64-linux-gnu ; \ fi -RUN go install github.com/vektra/mockery/v2@v2.20.0 +RUN go install github.com/vektra/mockery/v2@v2.43.0 RUN go install github.com/swaggo/swag/cmd/swag@v1.16.1 COPY --from=debian-amd64 /usr/include /rootfs-amd64/usr/include diff --git a/backend/Makefile b/backend/Makefile index 6a30e8a1347..d2f06e099c6 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -29,7 +29,7 @@ all: build go-dep: go install github.com/vektra/mockery/v2@v2.43.0 go install github.com/swaggo/swag/cmd/swag@v1.16.1 - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.3 go-dev-tools: # go install github.com/atombender/go-jsonschema/cmd/gojsonschema@latest diff --git a/backend/core/migration/linter/main.go b/backend/core/migration/linter/main.go index bf9190b72e1..11aae870ce9 100644 --- a/backend/core/migration/linter/main.go +++ b/backend/core/migration/linter/main.go @@ -51,7 +51,7 @@ func firstLineFromFile(path string) string { for scanner.Scan() { return scanner.Text() } - panic(fmt.Errorf("empty file: " + path)) + panic(fmt.Errorf("empty file: %s", path)) } const ( diff --git a/backend/go.mod b/backend/go.mod index 21f8d4b199e..9371c8567e3 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -1,6 +1,6 @@ module github.com/apache/incubator-devlake -go 1.20 +go 1.24 require ( github.com/aws/aws-sdk-go v1.55.6 diff --git a/backend/helpers/srvhelper/scope_service_helper.go b/backend/helpers/srvhelper/scope_service_helper.go index e0e0d97dc33..544536f01c2 100644 --- a/backend/helpers/srvhelper/scope_service_helper.go +++ b/backend/helpers/srvhelper/scope_service_helper.go @@ -268,39 +268,39 @@ func (scopeSrv *ScopeSrvHelper[C, S, SC]) getAffectedTables() ([]string, errors. if err != nil { return nil, err } - if pluginModel, ok := meta.(plugin.PluginModel); !ok { + pluginModel, ok := meta.(plugin.PluginModel) + if !ok { panic(errors.Default.New(fmt.Sprintf("plugin \"%s\" does not implement listing its tables", scopeSrv.pluginName))) - } else { - // Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated. - // It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here - var allTables []string - if allTables, err = scopeSrv.db.AllTables(); err != nil { - return nil, err - } - // collect raw tables - for _, table := range allTables { - if strings.HasPrefix(table, "_raw_"+scopeSrv.pluginName) { - tables = append(tables, table) - } + } + // Unfortunately, can't cache the tables because Python creates some tables on a per-demand basis, so such a cache would possibly get outdated. + // It's a rare scenario in practice, but might as well play it safe and sacrifice some performance here + var allTables []string + if allTables, err = scopeSrv.db.AllTables(); err != nil { + return nil, err + } + // collect raw tables + for _, table := range allTables { + if strings.HasPrefix(table, "_raw_"+scopeSrv.pluginName) { + tables = append(tables, table) } - // collect tool tables - toolModels := pluginModel.GetTablesInfo() - for _, toolModel := range toolModels { - if !isScopeModel(toolModel) && hasField(toolModel, "RawDataParams") { - tables = append(tables, toolModel.TableName()) - } + } + // collect tool tables + toolModels := pluginModel.GetTablesInfo() + for _, toolModel := range toolModels { + if !isScopeModel(toolModel) && hasField(toolModel, "RawDataParams") { + tables = append(tables, toolModel.TableName()) } - // collect domain tables - for _, domainModel := range domaininfo.GetDomainTablesInfo() { - // we only care about tables with RawOrigin - ok = hasField(domainModel, "RawDataParams") - if ok { - tables = append(tables, domainModel.TableName()) - } + } + // collect domain tables + for _, domainModel := range domaininfo.GetDomainTablesInfo() { + // we only care about tables with RawOrigin + ok = hasField(domainModel, "RawDataParams") + if ok { + tables = append(tables, domainModel.TableName()) } - // additional tables - tables = append(tables, models.CollectorLatestState{}.TableName()) } + // additional tables + tables = append(tables, models.CollectorLatestState{}.TableName()) scopeSrv.log.Debug("Discovered %d tables used by plugin \"%s\": %v", len(tables), scopeSrv.pluginName, tables) return tables, nil } diff --git a/backend/impls/logruslog/init.go b/backend/impls/logruslog/init.go index 17df490f97d..9ed5b8ce583 100644 --- a/backend/impls/logruslog/init.go +++ b/backend/impls/logruslog/init.go @@ -70,16 +70,16 @@ func init() { if basePath == "" { basePath = "./logs" } - if abs, err := filepath.Abs(basePath); err != nil { - panic(err) - } else { - basePath = filepath.Join(abs, "devlake.log") - } - var err errors.Error - Global, err = NewDefaultLogger(inner) + abs, err := filepath.Abs(basePath) if err != nil { panic(err) } + basePath = filepath.Join(abs, "devlake.log") + var errLogger errors.Error + Global, errLogger = NewDefaultLogger(inner) + if errLogger != nil { + panic(errLogger) + } stream, err := GetFileStream(basePath) if err != nil { stream = os.Stdout diff --git a/backend/impls/logruslog/logger.go b/backend/impls/logruslog/logger.go index 857d75ac263..88287c9f553 100644 --- a/backend/impls/logruslog/logger.go +++ b/backend/impls/logruslog/logger.go @@ -72,11 +72,11 @@ func (l *DefaultLogger) Info(format string, a ...interface{}) { } func (l *DefaultLogger) Warn(err error, format string, a ...interface{}) { - l.Log(log.LOG_WARN, formatMessage(err, format, a...)) + l.Log(log.LOG_WARN, "%s", formatMessage(err, format, a...)) } func (l *DefaultLogger) Error(err error, format string, a ...interface{}) { - l.Log(log.LOG_ERROR, formatMessage(err, format, a...)) + l.Log(log.LOG_ERROR, "%s", formatMessage(err, format, a...)) } func (l *DefaultLogger) SetStream(config *log.LoggerStreamConfig) { diff --git a/backend/plugins/github_graphql/tasks/issue_extractor.go b/backend/plugins/github_graphql/tasks/issue_extractor.go index 0ebd28d18c3..e27679c83e9 100644 --- a/backend/plugins/github_graphql/tasks/issue_extractor.go +++ b/backend/plugins/github_graphql/tasks/issue_extractor.go @@ -143,7 +143,7 @@ func convertGithubIssue(milestoneMap map[int]int, issue *GraphqlQueryIssue, conn GithubCreatedAt: issue.CreatedAt, GithubUpdatedAt: issue.UpdatedAt, } - if issue.AssigneeList.Assignees != nil && len(issue.AssigneeList.Assignees) > 0 { + if len(issue.AssigneeList.Assignees) > 0 { githubIssue.AssigneeId = issue.AssigneeList.Assignees[0].Id githubIssue.AssigneeName = issue.AssigneeList.Assignees[0].Login } diff --git a/backend/server/api/shared/api_output.go b/backend/server/api/shared/api_output.go index b213f91e963..b9f16a4a953 100644 --- a/backend/server/api/shared/api_output.go +++ b/backend/server/api/shared/api_output.go @@ -124,7 +124,7 @@ func ApiOutputSuccess(c *gin.Context, body interface{}, status int) { func ApiOutputAbort(c *gin.Context, err error) { if e, ok := err.(errors.Error); ok { logruslog.Global.Error(err, "HTTP %d abort-error", e.GetType().GetHttpCode()) - _ = c.AbortWithError(e.GetType().GetHttpCode(), fmt.Errorf(e.Messages().Format())) + _ = c.AbortWithError(e.GetType().GetHttpCode(), fmt.Errorf("%s", e.Messages().Format())) } else { logruslog.Global.Error(err, "HTTP %d abort-error (native)", http.StatusInternalServerError) _ = c.AbortWithError(http.StatusInternalServerError, err) diff --git a/backend/server/services/remote/plugin/plugin_impl.go b/backend/server/services/remote/plugin/plugin_impl.go index 6242b160053..1b338399f73 100644 --- a/backend/server/services/remote/plugin/plugin_impl.go +++ b/backend/server/services/remote/plugin/plugin_impl.go @@ -186,7 +186,7 @@ func (p *remotePluginImpl) PrepareTaskData(taskCtx plugin.TaskContext, options m }, nil } -func (p *remotePluginImpl) getScopeAndConfig(db dal.Dal, connectionId uint64, scopeId string) (interface{}, interface{}, errors.Error) { +func (p *remotePluginImpl) getScopeAndConfig(db dal.Dal, connectionId uint64, scopeId string) (resultScope interface{}, resultScopeConfig interface{}, resultErr errors.Error) { wrappedScope := p.scopeTabler.New() err := api.CallDB(db.First, wrappedScope, dal.Where("connection_id = ? AND id = ?", connectionId, scopeId)) if err != nil { diff --git a/devops/docker/lake-builder/Dockerfile b/devops/docker/lake-builder/Dockerfile index 61363f0bcff..c5bd449bd3a 100644 --- a/devops/docker/lake-builder/Dockerfile +++ b/devops/docker/lake-builder/Dockerfile @@ -18,7 +18,7 @@ FROM --platform=linux/amd64 debian:bullseye as debian-amd64 RUN apt-get -y update && apt -y upgrade &&\ apt-get install -y libssh2-1-dev libssl-dev zlib1g-dev -FROM golang:1.20.4-bullseye as builder +FROM golang:1.24-bullseye as builder # Base dependencies RUN apt-get -y update && apt -y upgrade &&\ @@ -55,14 +55,14 @@ COPY --from=builder /tmp/deps/include/ /usr/include/ ENV PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig # Install Golang -RUN curl -L https://git.io/vQhTU | bash -s -- --version 1.20.4 +RUN curl -L https://git.io/vQhTU | bash -s -- --version 1.24.0 RUN mv /root/go /go &&\ mv /root/.go /usr/local/go &&\ ln -sf /usr/local/go/bin/* /usr/bin # Install Golang Tools RUN export GOPATH=/go && \ - go install github.com/vektra/mockery/v2@v2.20.0 && \ + go install github.com/vektra/mockery/v2@v2.43.0 && \ go install github.com/swaggo/swag/cmd/swag@v1.16.1 # Golang Env