Skip to content

Enable CI failures for linting #164

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

Merged
merged 7 commits into from
Dec 5, 2019
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
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