Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use golangci-lint-action #549

Merged
merged 1 commit into from
Jul 7, 2023
Merged
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
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