Skip to content

Commit

Permalink
Add go vet as a check to the Github commit actions (#31461)
Browse files Browse the repository at this point in the history
* Add go vet as a check to the Github commit actions

* deliberately break to test

* fix after successful test

* Use  directly

* fix more errors
  • Loading branch information
liamcervante authored Nov 7, 2024
1 parent dacd04c commit eeacced
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
- name: "Code consistency checks"
run: |
make fmtcheck importscheck copyright generate staticcheck exhaustive protobuf
make fmtcheck importscheck vetcheck copyright generate staticcheck exhaustive protobuf
if [[ -n "$(git status --porcelain)" ]]; then
echo >&2 "ERROR: Generated files are inconsistent. Run 'make generate' and 'make protobuf' locally and then commit the updated files."
git >&2 status --porcelain
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ fmtcheck:
importscheck:
"$(CURDIR)/scripts/goimportscheck.sh"

vetcheck:
@echo "==> Checking that the code complies with go vet requirements"
@go vet ./...

staticcheck:
"$(CURDIR)/scripts/staticcheck.sh"

Expand Down Expand Up @@ -52,4 +56,4 @@ website/build-local:
# under parallel conditions.
.NOTPARALLEL:

.PHONY: fmtcheck importscheck generate protobuf staticcheck syncdeps website website/local website/build-local
.PHONY: fmtcheck importscheck vetcheck generate protobuf staticcheck syncdeps website website/local website/build-local
4 changes: 2 additions & 2 deletions internal/addrs/module_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ func TestModuleInstanceEqual_false(t *testing.T) {
func BenchmarkStringShort(b *testing.B) {
addr, _ := ParseModuleInstanceStr(`module.foo`)
for n := 0; n < b.N; n++ {
addr.String()
_ = addr.String()
}
}

func BenchmarkStringLong(b *testing.B) {
addr, _ := ParseModuleInstanceStr(`module.southamerica-brazil-region.module.user-regional-desktops.module.user-name`)
for n := 0; n < b.N; n++ {
addr.String()
_ = addr.String()
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/addrs/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func TestModuleString(t *testing.T) {
func BenchmarkModuleStringShort(b *testing.B) {
module := Module{"a", "b"}
for n := 0; n < b.N; n++ {
module.String()
_ = module.String()
}
}

func BenchmarkModuleStringLong(b *testing.B) {
module := Module{"southamerica-brazil-region", "user-regional-desktop", "user-name"}
for n := 0; n < b.N; n++ {
module.String()
_ = module.String()
}
}
4 changes: 4 additions & 0 deletions internal/command/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ func TestApply_parallelism(t *testing.T) {
// to proceed in unison.
beginCtx, begin := context.WithCancel(context.Background())

// This just makes go vet happy, in reality the function will never exit if
// begin() isn't called inside ApplyResourceChangeFn.
defer begin()

// Since our mock provider has its own mutex preventing concurrent calls
// to ApplyResourceChange, we need to use a number of separate providers
// here. They will all have the same mock implementation function assigned
Expand Down
4 changes: 4 additions & 0 deletions internal/command/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,10 @@ func TestPlan_parallelism(t *testing.T) {
// to proceed in unison.
beginCtx, begin := context.WithCancel(context.Background())

// This just makes go vet happy, in reality the function will never exit if
// begin() isn't called inside ApplyResourceChangeFn.
defer begin()

// Since our mock provider has its own mutex preventing concurrent calls
// to ApplyResourceChange, we need to use a number of separate providers
// here. They will all have the same mock implementation function assigned
Expand Down
1 change: 0 additions & 1 deletion internal/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func (c *Config) TargetExists(target addrs.Targetable) bool {
default:
panic(fmt.Errorf("unrecognized targetable type: %d", target.AddrType()))
}
return true
}

// EntersNewPackage returns true if this call is to an external module, either
Expand Down
1 change: 0 additions & 1 deletion internal/grpcwrap/provider6.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ func (p *provider6) CloseEphemeralResource(_ context.Context, req *tfplugin6.Clo

func (p *provider6) GetFunctions(context.Context, *tfplugin6.GetFunctions_Request) (*tfplugin6.GetFunctions_Response, error) {
panic("unimplemented")
return nil, nil
}

func (p *provider6) CallFunction(_ context.Context, req *tfplugin6.CallFunction_Request) (*tfplugin6.CallFunction_Response, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/moduletest/hcl/variable_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestFileVariables(t *testing.T) {
FileVariables: func() map[string]hcl.Expression {
vars := make(map[string]hcl.Expression)
for name, value := range tc.Values {
expr, diags := hclsyntax.ParseExpression([]byte(value), "test.tf", hcl.Pos{0, 0, 0})
expr, diags := hclsyntax.ParseExpression([]byte(value), "test.tf", hcl.Pos{Line: 0, Column: 0, Byte: 0})
if len(diags) > 0 {
t.Fatalf("unexpected errors: %v", diags)
}
Expand Down

0 comments on commit eeacced

Please sign in to comment.