Skip to content

Commit

Permalink
Use golangci-lint-action
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Jul 7, 2023
1 parent 56d823a commit 8dfc04a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
branches:
- main
name: Lint
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -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"
22 changes: 11 additions & 11 deletions internal/temporal/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ 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.
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)}
}

Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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
}
Expand All @@ -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)
}
Expand All @@ -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,
Expand Down

0 comments on commit 8dfc04a

Please sign in to comment.