Skip to content

Commit

Permalink
Enable CI failures for linting (#164)
Browse files Browse the repository at this point in the history
* use golangci-lint

* enable dead firehose event tests

* add some ignore for files that I won't be fixing right now

* fix errcheck problems in cfn/wrap_test.go

* fix errcheck for cfn/wrap.go

* fix previously dead kinesis firehose tests
  • Loading branch information
bmoffatt authored Dec 5, 2019
1 parent b6af4bf commit 6625202
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
run:
skip-files:
# These were code-generated, and cannot be changed without breaking RPC compatability.
- lambda/messages/*.go

# FIXME
# events/codebuild.go:18:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeBuildPhaseStatusFailed CodeBuildPhaseStatus = "FAILED"
# ^
# events/codebuild.go:31:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeBuildPhaseTypeSubmitted CodeBuildPhaseType = "SUBMITTED"
# ^
- events/codebuild.go

# FIXME
# events/codedeploy.go:16:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeDeployDeploymentStateFailure CodeDeployDeploymentState = "FAILURE"
# ^
- events/codedeploy.go
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ before_install:
- go mod download

install:
- go get golang.org/x/lint/golint
- go get github.com/haya14busa/goverage
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0

matrix:
allow_failures:
Expand All @@ -24,13 +24,12 @@ notifications:

before_script:
- PKGS=$(go list ./...)
- LINT_PKGS=$(go list ./... | grep -Ev 'aws-lambda-go/lambda')

script:
- diff -u <(echo -n) <(gofmt -d ./) # Fail if a .go file hasn't been formatted with gofmt
- goverage -v -race -covermode=atomic -coverprofile=coverage.txt $PKGS # Run all tests with coverage
- go vet -v ./... # static analyisis
- golint $LINT_PKGS # lint - ignore failures for now
- golangci-lint run ./...

after_success:
- bash <(curl -s https://codecov.io/bash)
3 changes: 2 additions & 1 deletion cfn/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClie
if funcDidPanic {
r.Status = StatusFailed
r.Reason = "Function panicked, see log stream for details"
r.sendWith(client)
// FIXME: something should be done if an error is returned here
_ = r.sendWith(client)
}
}()

Expand Down
12 changes: 8 additions & 4 deletions cfn/wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func TestCopyLambdaLogStream(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
lambdacontext.LogStreamName = lgs
}

Expand All @@ -72,7 +73,8 @@ func TestPanicSendsFailure(t *testing.T) {
}

assert.Panics(t, func() {
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
})

assert.True(t, didSendStatus, "FAILED should be sent to CloudFormation service")
Expand All @@ -99,7 +101,8 @@ func TestDontCopyLogicalResourceId(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
}

func TestWrappedError(t *testing.T) {
Expand All @@ -123,7 +126,8 @@ func TestWrappedError(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
}

func TestWrappedSendFailure(t *testing.T) {
Expand Down

0 comments on commit 6625202

Please sign in to comment.