Skip to content
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

Add golangci-lint #134

Merged
merged 8 commits into from
Jul 13, 2024
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
13 changes: 4 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,10 @@ jobs:
go-version-file: "go.mod"
id: go

- name: Run lint
run: |
set -xe

go install golang.org/x/lint/golint@latest

make fmtci
make vet
make lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58

- name: Slack Notification (not success)
uses: act10ns/slack@v2
Expand Down
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
linters-settings:
gofmt:
revive:
testifylint:
wrapcheck:

linters:
enable:
- gofmt
- revive
- testifylint
- wrapcheck
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ testrace:
fmt:
go fmt ./...

.PHONY: fmtci
fmtci:
! gofmt -d . | grep '^'

.PHONY: lint
lint:
golint -set_exit_status

.PHONY: vet
vet:
go vet

.PHONY: tag
tag:
git tag -a $(VERSION) -m "Release $(VERSION)"
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package secretmanagerenv

import (
secretmanager "cloud.google.com/go/secretmanager/apiv1"
"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
"context"
"fmt"
"github.com/cockroachdb/errors"
secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
"os"
"strings"
)
Expand Down
9 changes: 4 additions & 5 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package secretmanagerenv

import (
"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
"context"
"fmt"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/sue445/gcp-secretmanagerenv/mock_secretmanagerenv"
secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
"os"
"testing"
)

func setupSecretManagerMock(ctx context.Context, t *testing.T) *mock_secretmanagerenv.MocksecretManagerClient {
func setupSecretManagerMock(_ context.Context, t *testing.T) *mock_secretmanagerenv.MocksecretManagerClient {
ctrl := gomock.NewController(t)
t.Cleanup(func() {
ctrl.Finish()
Expand Down Expand Up @@ -205,9 +206,7 @@ func TestClient_GetSecretManagerValue_IntegrationTest(t *testing.T) {

ctx := context.Background()
c, err := NewClient(ctx, os.Getenv("INTEGRATION_TEST_PROJECT_ID"))
if !assert.NoError(t, err) {
return
}
require.NoError(t, err)

got1, err := c.GetSecretManagerValue("SECRET_MANAGER_KEY", "latest")
if assert.NoError(t, err) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/golang/mock v1.6.0
github.com/googleapis/gax-go/v2 v2.12.5
github.com/stretchr/testify v1.9.0
google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b
)

require (
Expand Down Expand Up @@ -47,6 +46,7 @@ require (
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.188.0 // indirect
google.golang.org/genproto v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b // indirect
google.golang.org/grpc v1.64.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions mock_secretmanagerenv/mock_secret_manager_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion secret_manager_client.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package secretmanagerenv

import (
"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
"context"
"github.com/googleapis/gax-go/v2"
secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
)

type secretManagerClient interface {
Expand Down
Loading