Skip to content

Commit

Permalink
Changed to golangci-lint and introduced LintChanges command
Browse files Browse the repository at this point in the history
Signed-off-by: David Gannon <19214156+dgannon991@users.noreply.github.com>
  • Loading branch information
dgannon991 committed Apr 4, 2024
1 parent 05b1552 commit b6d5ee0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/porter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
run: go run mage.go Vet
shell: bash
- name: Lint
run: go run mage.go Lint
run: go run mage.go LintChanges
shell: bash

Build-docker-images:
Expand Down
12 changes: 9 additions & 3 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,16 @@ func Vet() {
must.RunV("go", "vet", "./...")
}

// Run staticcheck on the project
// Run golangci-lint on the project, but only for the latest changes
func LintChanges() {
mg.Deps(tools.EnsureGolangCILint)

Check failure on line 704 in magefile.go

View workflow job for this annotation

GitHub Actions / Native Compile

undefined: tools.EnsureGolangCILint

Check failure on line 704 in magefile.go

View workflow job for this annotation

GitHub Actions / Unit Test

undefined: tools.EnsureGolangCILint

Check failure on line 704 in magefile.go

View workflow job for this annotation

GitHub Actions / Vet and Lint

undefined: tools.EnsureGolangCILint

Check failure on line 704 in magefile.go

View workflow job for this annotation

GitHub Actions / Cross Compile

undefined: tools.EnsureGolangCILint
must.RunV("golangci-lint", "run", "--new-from-rev=HEAD~1", "--whole-files", "./...")
}

// Run golangci-lint on the project
func Lint() {
mg.Deps(tools.EnsureStaticCheck)
must.RunV("staticcheck", "./...")
mg.Deps(tools.EnsureGolangCILint)

Check failure on line 710 in magefile.go

View workflow job for this annotation

GitHub Actions / Native Compile

undefined: tools.EnsureGolangCILint

Check failure on line 710 in magefile.go

View workflow job for this annotation

GitHub Actions / Unit Test

undefined: tools.EnsureGolangCILint

Check failure on line 710 in magefile.go

View workflow job for this annotation

GitHub Actions / Vet and Lint

undefined: tools.EnsureGolangCILint

Check failure on line 710 in magefile.go

View workflow job for this annotation

GitHub Actions / Cross Compile

undefined: tools.EnsureGolangCILint
must.RunV("golangci-lint", "run", "./...")
}

func getPorterHome() string {
Expand Down
9 changes: 5 additions & 4 deletions pkg/tracing/traceLogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type RootTraceLogger interface {
TraceLogger

// Close the tracer and send data to the telemetry collector
Close()
Close() error
}

var _ TraceLogger = traceLogger{}
Expand All @@ -102,12 +102,13 @@ type traceLogger struct {
}

// Close the root span and send the telemetry data to the collector.
func (l traceLogger) Close() {
func (l traceLogger) Close() error {
l.span.End()

if err := l.tracer.Close(context.Background()); err != nil {
l.Errorf("error closing the Tracer: %w", err)
return l.Errorf("error closing the Tracer: %w", err)
}
return nil
}

// ShouldLog returns if the current log level includes the specified level.
Expand Down Expand Up @@ -151,7 +152,7 @@ func (l traceLogger) EndSpan(opts ...trace.SpanEndOption) {

// If there was a panic, mark the span and include the stack trace
if panicErr := recover(); panicErr != nil {
l.Error(fmt.Errorf("%s", panicErr),
panicErr = l.Error(fmt.Errorf("%s", panicErr),
attribute.Bool("panic", true),
attribute.String("stackTrace", string(debug.Stack())))
panic(panicErr) // rethrow
Expand Down

0 comments on commit b6d5ee0

Please sign in to comment.