mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-05 06:46:14 +01:00
Add go vet as a check to the Github commit actions (#31461)
* Add go vet as a check to the Github commit actions * deliberately break to test * fix after successful test * Use directly * fix more errors
This commit is contained in:
2
.github/workflows/checks.yml
vendored
2
.github/workflows/checks.yml
vendored
@@ -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
|
||||
|
||||
6
Makefile
6
Makefile
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user