From e912d5e7cfef90e56a4d73538766ab3a5fc29c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Fri, 7 Jul 2023 09:48:31 +0000 Subject: [PATCH] Use golangci-lint-action --- .github/workflows/lint.yml | 18 +++++++++--------- internal/temporal/logging.go | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f0fc24b4..1cec9de7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,8 @@ on: branches: - main name: Lint +permissions: + contents: read jobs: lint: runs-on: ubuntu-latest @@ -17,12 +19,10 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ steps.go_version.outputs.go_version }} - - name: Install golangci-lint - run: | - echo $(go env GOPATH)/bin >> $GITHUB_PATH - echo $PATH - make bingo - bingo get -l golangci-lint - - name: Lint code - run: echo $(go env GOPATH)/bin >> $GITHUB_PATH - make lint + cache: false + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: "v1.53.3" + args: "--timeout=5m" + install-mode: "binary" diff --git a/internal/temporal/logging.go b/internal/temporal/logging.go index f3cf3080..61b83329 100644 --- a/internal/temporal/logging.go +++ b/internal/temporal/logging.go @@ -5,9 +5,9 @@ import ( "errors" "github.com/go-logr/logr" - "go.temporal.io/sdk/activity" - "go.temporal.io/sdk/interceptor" - "go.temporal.io/sdk/log" + temporalsdk_activity "go.temporal.io/sdk/activity" + temporalsdk_interceptor "go.temporal.io/sdk/interceptor" + temporalsdk_log "go.temporal.io/sdk/log" ) // logrWrapper implements the Temporal logger interface wrapping a logr.Logger. @@ -15,10 +15,10 @@ type logrWrapper struct { logger logr.Logger } -var _ log.Logger = (*logrWrapper)(nil) +var _ temporalsdk_log.Logger = (*logrWrapper)(nil) // Logger returns a logger for the Temporal Go SDK. -func Logger(logger logr.Logger) log.Logger { +func Logger(logger logr.Logger) temporalsdk_log.Logger { return logrWrapper{logger.WithCallDepth(1)} } @@ -39,11 +39,11 @@ func (l logrWrapper) Error(msg string, keyvals ...interface{}) { } type workerInterceptor struct { - interceptor.WorkerInterceptorBase + temporalsdk_interceptor.WorkerInterceptorBase logger logr.Logger } -var _ interceptor.WorkerInterceptor = (*workerInterceptor)(nil) +var _ temporalsdk_interceptor.WorkerInterceptor = (*workerInterceptor)(nil) // NewWorkerInterceptor returns an interceptor that makes the application logger // available to activities via context. @@ -53,7 +53,7 @@ func NewLoggerInterceptor(logger logr.Logger) *workerInterceptor { } } -func (w *workerInterceptor) InterceptActivity(ctx context.Context, next interceptor.ActivityInboundInterceptor) interceptor.ActivityInboundInterceptor { +func (w *workerInterceptor) InterceptActivity(ctx context.Context, next temporalsdk_interceptor.ActivityInboundInterceptor) temporalsdk_interceptor.ActivityInboundInterceptor { i := &activityInboundInterceptor{ root: w, logger: w.logger, @@ -63,7 +63,7 @@ func (w *workerInterceptor) InterceptActivity(ctx context.Context, next intercep } type activityInboundInterceptor struct { - interceptor.ActivityInboundInterceptorBase + temporalsdk_interceptor.ActivityInboundInterceptorBase root *workerInterceptor logger logr.Logger } @@ -72,7 +72,7 @@ type contextKey struct{} var loggerContextKey = contextKey{} -func (a *activityInboundInterceptor) ExecuteActivity(ctx context.Context, in *interceptor.ExecuteActivityInput) (interface{}, error) { +func (a *activityInboundInterceptor) ExecuteActivity(ctx context.Context, in *temporalsdk_interceptor.ExecuteActivityInput) (interface{}, error) { ctx = context.WithValue(ctx, loggerContextKey, a.logger) return a.Next.ExecuteActivity(ctx, in) } @@ -85,7 +85,7 @@ func GetLogger(ctx context.Context) logr.Logger { logger := v.(logr.Logger) - info := activity.GetInfo(ctx) + info := temporalsdk_activity.GetInfo(ctx) return logger.WithValues( "ActivityID", info.ActivityID,