Skip to content

Commit 6625202

Browse files
authored
Enable CI failures for linting (#164)
* 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
1 parent b6af4bf commit 6625202

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

.golangci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
run:
2+
skip-files:
3+
# These were code-generated, and cannot be changed without breaking RPC compatability.
4+
- lambda/messages/*.go
5+
6+
# FIXME
7+
# events/codebuild.go:18:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
8+
# CodeBuildPhaseStatusFailed CodeBuildPhaseStatus = "FAILED"
9+
# ^
10+
# events/codebuild.go:31:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
11+
# CodeBuildPhaseTypeSubmitted CodeBuildPhaseType = "SUBMITTED"
12+
# ^
13+
- events/codebuild.go
14+
15+
# FIXME
16+
# events/codedeploy.go:16:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
17+
# CodeDeployDeploymentStateFailure CodeDeployDeploymentState = "FAILURE"
18+
# ^
19+
- events/codedeploy.go

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ before_install:
1111
- go mod download
1212

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

1717
matrix:
1818
allow_failures:
@@ -24,13 +24,12 @@ notifications:
2424

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

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

3534
after_success:
3635
- bash <(curl -s https://codecov.io/bash)

cfn/wrap.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClie
3434
if funcDidPanic {
3535
r.Status = StatusFailed
3636
r.Reason = "Function panicked, see log stream for details"
37-
r.sendWith(client)
37+
// FIXME: something should be done if an error is returned here
38+
_ = r.sendWith(client)
3839
}
3940
}()
4041

cfn/wrap_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ func TestCopyLambdaLogStream(t *testing.T) {
4646
return
4747
}
4848

49-
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
49+
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
50+
assert.NoError(t, err)
5051
lambdacontext.LogStreamName = lgs
5152
}
5253

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

7475
assert.Panics(t, func() {
75-
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
76+
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
77+
assert.NoError(t, err)
7678
})
7779

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

102-
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
104+
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
105+
assert.NoError(t, err)
103106
}
104107

105108
func TestWrappedError(t *testing.T) {
@@ -123,7 +126,8 @@ func TestWrappedError(t *testing.T) {
123126
return
124127
}
125128

126-
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
129+
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
130+
assert.NoError(t, err)
127131
}
128132

129133
func TestWrappedSendFailure(t *testing.T) {

0 commit comments

Comments
 (0)