Skip to content

Commit

Permalink
Update go hook testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Nov 16, 2023
1 parent e6b45ca commit 04ef180
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
AWS_DEFAULT_REGION: "us-east-1"
AWS_SDK_LOAD_CONFIG: 1
GOPATH: ${{ github.workspace }}
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
Expand All @@ -28,7 +28,7 @@ jobs:
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
go-version: '>=1.21.0'
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
Expand All @@ -41,7 +41,7 @@ jobs:
go install github.com/go-critic/go-critic/cmd/gocritic@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Install plugin
run: |
pip install .
Expand Down
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- goimports
- gocritic
27 changes: 15 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ repos:
# ignore all files, run on hard-coded modules instead
pass_filenames: false
always_run: true
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
- id: go-unit-tests
name: go unit tests
entry: go test ./...
pass_filenames: false
types: [go]
language: system
- id: go-build-mod
name: go build mod
entry: go build ./...
pass_filenames: false
types: [go]
language: system
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: go-fmt
# - id: go-vet
- id: go-imports
- id: go-cyclo
args: [-over=20]
- id: golangci-lint
- id: go-critic
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
- id: golangci-lint-full
2 changes: 1 addition & 1 deletion cfn/logging/cloudwatchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (p *cloudWatchLogsProvider) Write(b []byte) (int, error) {
LogStreamName: aws.String(p.logStreamName),

LogEvents: []*cloudwatchlogs.InputLogEvent{
&cloudwatchlogs.InputLogEvent{
{
Message: aws.String(string(b)),
Timestamp: aws.Int64(time.Now().UnixNano() / int64(time.Millisecond)),
},
Expand Down
8 changes: 4 additions & 4 deletions cfn/logging/cloudwatchlogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) {
DescribeLogGroupsFn: func(input *cloudwatchlogs.DescribeLogGroupsInput) (*cloudwatchlogs.DescribeLogGroupsOutput, error) {
return &cloudwatchlogs.DescribeLogGroupsOutput{
LogGroups: []*cloudwatchlogs.LogGroup{
&cloudwatchlogs.LogGroup{LogGroupName: input.LogGroupNamePrefix},
{LogGroupName: input.LogGroupNamePrefix},
},
}, nil
},
Expand Down
2 changes: 1 addition & 1 deletion cfn/metrics/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (p *Publisher) publishMetric(metricName string, data map[string]string, uni
d = append(d, dim)
}
md := []*cloudwatch.MetricDatum{
&cloudwatch.MetricDatum{
{
MetricName: aws.String(metricName),
Unit: aws.String(unit),
Value: aws.Float64(value),
Expand Down
2 changes: 1 addition & 1 deletion cfn/scheduler/scheduler_notag.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *Scheduler) Reschedule(lambdaCtx context.Context, secsFromNow int64, cal
_, perr := s.client.PutTargets(&cloudwatchevents.PutTargetsInput{
Rule: aws.String(invocationIDS.Handler),
Targets: []*cloudwatchevents.Target{
&cloudwatchevents.Target{
{
Arn: aws.String(lc.InvokedFunctionArn),
Id: aws.String(invocationIDS.Target),
Input: aws.String(string(callbackRequest)),
Expand Down

0 comments on commit 04ef180

Please sign in to comment.