From df68fd2e0bc20e6439fe269833eb0caf7447bdba Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Thu, 12 Dec 2024 12:36:48 -0800 Subject: [PATCH 1/7] Lint upstream as a normal unit test --- .ci-mgmt.yaml | 27 ---------------- .github/workflows/master.yml | 27 ---------------- .github/workflows/prerelease.yml | 28 ---------------- .github/workflows/release.yml | 28 ---------------- .github/workflows/run-acceptance-tests.yml | 28 ---------------- provider/upstream_test.go | 37 ++++++++++++++++++++++ 6 files changed, 37 insertions(+), 138 deletions(-) create mode 100644 provider/upstream_test.go diff --git a/.ci-mgmt.yaml b/.ci-mgmt.yaml index be647daf9d1..35fd12a6224 100644 --- a/.ci-mgmt.yaml +++ b/.ci-mgmt.yaml @@ -99,30 +99,3 @@ extraTests: uses: codecov/codecov-action@v4 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - upstream_lint: - name: Run upstream provider-lint - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - swap-storage: false - tool-cache: false - - name: Checkout Repo - uses: actions/checkout@v4 - with: - ref: ${{ env.PR_COMMIT_SHA }} - submodules: true - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: "1.23.x" - cache: false - - name: Prepare local workspace - run: make prepare_local_workspace - - name: upstream lint - run: | - cd upstream - make provider-lint diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index d7c0f9bb82c..bab417e3392 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -100,7 +100,6 @@ jobs: - test - license_check - go_test_shim - - upstream_lint uses: ./.github/workflows/publish.yml secrets: inherit with: @@ -236,32 +235,6 @@ jobs: name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 timeout-minutes: 60 - upstream_lint: - name: Run upstream provider-lint - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - swap-storage: false - tool-cache: false - - name: Checkout Repo - uses: actions/checkout@v4 - with: - ref: ${{ env.PR_COMMIT_SHA }} - submodules: true - - name: Install Go - uses: actions/setup-go@v5 - with: - cache: false - go-version: 1.23.x - - name: Prepare local workspace - run: make prepare_local_workspace - - name: upstream lint - run: | - cd upstream - make provider-lint - timeout-minutes: 60 name: master on: diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 8f65781b374..8d33ba2f4c3 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -60,7 +60,6 @@ jobs: - test - license_check - go_test_shim - - upstream_lint uses: ./.github/workflows/publish.yml secrets: inherit with: @@ -176,33 +175,6 @@ jobs: name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 timeout-minutes: 60 - upstream_lint: - name: Run upstream provider-lint - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - swap-storage: false - tool-cache: false - - name: Checkout Repo - uses: actions/checkout@v4 - with: - ref: ${{ env.PR_COMMIT_SHA }} - submodules: true - - name: Install Go - uses: actions/setup-go@v5 - with: - cache: false - go-version: 1.23.x - - name: Prepare local workspace - run: make prepare_local_workspace - - name: upstream lint - run: | - cd upstream - make provider-lint - timeout-minutes: 60 - name: prerelease on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1005b295a09..39c2a1868e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,7 +66,6 @@ jobs: - test - license_check - go_test_shim - - upstream_lint uses: ./.github/workflows/publish.yml secrets: inherit with: @@ -182,30 +181,3 @@ jobs: name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 timeout-minutes: 60 - upstream_lint: - name: Run upstream provider-lint - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - swap-storage: false - tool-cache: false - - name: Checkout Repo - uses: actions/checkout@v4 - with: - ref: ${{ env.PR_COMMIT_SHA }} - submodules: true - - name: Install Go - uses: actions/setup-go@v5 - with: - cache: false - go-version: 1.23.x - - name: Prepare local workspace - run: make prepare_local_workspace - - name: upstream lint - run: | - cd upstream - make provider-lint - timeout-minutes: 60 - diff --git a/.github/workflows/run-acceptance-tests.yml b/.github/workflows/run-acceptance-tests.yml index 33d110083df..dc8640bf506 100644 --- a/.github/workflows/run-acceptance-tests.yml +++ b/.github/workflows/run-acceptance-tests.yml @@ -95,7 +95,6 @@ jobs: - build_provider - license_check - go_test_shim - - upstream_lint runs-on: ubuntu-latest steps: - uses: guibranco/github-status-action-v2@0849440ec82c5fa69b2377725b9b7852a3977e76 # v1.1.13 @@ -237,30 +236,3 @@ jobs: name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 timeout-minutes: 60 - upstream_lint: - name: Run upstream provider-lint - runs-on: ubuntu-latest - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - swap-storage: false - tool-cache: false - - name: Checkout Repo - uses: actions/checkout@v4 - with: - ref: ${{ env.PR_COMMIT_SHA }} - submodules: true - - name: Install Go - uses: actions/setup-go@v5 - with: - cache: false - go-version: 1.23.x - - name: Prepare local workspace - run: make prepare_local_workspace - - name: upstream lint - run: | - cd upstream - make provider-lint - timeout-minutes: 60 - diff --git a/provider/upstream_test.go b/provider/upstream_test.go new file mode 100644 index 00000000000..1eeef701623 --- /dev/null +++ b/provider/upstream_test.go @@ -0,0 +1,37 @@ +// Copyright 2024, Pulumi Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package provider + +import ( + "os/exec" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestUpstreamLint(t *testing.T) { + cmd := exec.Command("make", "provider-lint") + cmd.Dir = "../upstream" + + buf := &strings.Builder{} + cmd.Stderr = buf + + err := cmd.Start() + require.NoError(t, err) + + err = cmd.Wait() + assert.NoError(t, err, buf.String()) +} From 340fa1755523fadae4ca74844e4e5c2e0b2b012f Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Thu, 12 Dec 2024 16:12:11 -0800 Subject: [PATCH 2/7] logging --- provider/upstream_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/provider/upstream_test.go b/provider/upstream_test.go index 1eeef701623..fbea041962c 100644 --- a/provider/upstream_test.go +++ b/provider/upstream_test.go @@ -14,8 +14,8 @@ package provider import ( + "os" "os/exec" - "strings" "testing" "github.com/stretchr/testify/assert" @@ -26,12 +26,12 @@ func TestUpstreamLint(t *testing.T) { cmd := exec.Command("make", "provider-lint") cmd.Dir = "../upstream" - buf := &strings.Builder{} - cmd.Stderr = buf + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr err := cmd.Start() require.NoError(t, err) err = cmd.Wait() - assert.NoError(t, err, buf.String()) + assert.NoError(t, err) } From a89aa4afe3f307f442bfe4a20268b687ebfb47cf Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Thu, 12 Dec 2024 16:53:34 -0800 Subject: [PATCH 3/7] parallelize --- provider/upstream_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/provider/upstream_test.go b/provider/upstream_test.go index fbea041962c..228970ab5c7 100644 --- a/provider/upstream_test.go +++ b/provider/upstream_test.go @@ -23,6 +23,8 @@ import ( ) func TestUpstreamLint(t *testing.T) { + t.Parallel() + cmd := exec.Command("make", "provider-lint") cmd.Dir = "../upstream" From 562779f03e4d41d868c14026c8d345e9dcbde220 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Fri, 13 Dec 2024 13:03:53 -0800 Subject: [PATCH 4/7] pre-compile --- provider/go.mod | 2 ++ provider/go.sum | 5 +++++ provider/upstream_test.go | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/provider/go.mod b/provider/go.mod index d96d01bf5c1..ac616a68b73 100644 --- a/provider/go.mod +++ b/provider/go.mod @@ -11,6 +11,7 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.28.6 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.43.1 + github.com/bflad/tfproviderlint v0.30.0 github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.59 github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 github.com/hashicorp/terraform-provider-aws v1.60.1-0.20220923175450-ca71523cdc36 @@ -319,6 +320,7 @@ require ( github.com/aws/smithy-go v1.22.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/beevik/etree v1.4.1 // indirect + github.com/bflad/gopaniccheck v0.1.0 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/blang/semver v3.5.1+incompatible // indirect diff --git a/provider/go.sum b/provider/go.sum index 0412607f73c..d4dab8fd0c0 100644 --- a/provider/go.sum +++ b/provider/go.sum @@ -1764,6 +1764,10 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= +github.com/bflad/gopaniccheck v0.1.0 h1:tJftp+bv42ouERmUMWLoUn/5bi/iQZjHPznM00cP/bU= +github.com/bflad/gopaniccheck v0.1.0/go.mod h1:ZCj2vSr7EqVeDaqVsWN4n2MwdROx1YL+LFo47TSWtsA= +github.com/bflad/tfproviderlint v0.30.0 h1:XBbTGPS4ZagSt4Qtnus3Vgh5yOeHNLZhnjcTcsSJ7ZM= +github.com/bflad/tfproviderlint v0.30.0/go.mod h1:eBZHT0r7HKPGw1uZEyGMzcR1/d+GAXq9KzQfw0I7wtY= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -3055,6 +3059,7 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200214201135-548b770e2dfa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= diff --git a/provider/upstream_test.go b/provider/upstream_test.go index 228970ab5c7..5fa1052d57a 100644 --- a/provider/upstream_test.go +++ b/provider/upstream_test.go @@ -18,6 +18,16 @@ import ( "os/exec" "testing" + // Compile these into our test binary directly. Normally these are already + // compiled and cached, but cold boots take a while and we don't want to + // time out during the test if it needs to build providerlint from scratch. + // NB: This is fragile because upstream (and upstream/.ci/providerlint) + // exist in different modules. If our versioning differs we will end up + // re-compiling. It would be beneficial to keep everything in one module. + _ "github.com/bflad/tfproviderlint/passes" + _ "github.com/bflad/tfproviderlint/xpasses" + _ "github.com/hashicorp/aws-sdk-go-base/v2" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) From c6a8e563fc692996c8446fac7e2f86a83603d63c Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Fri, 13 Dec 2024 13:04:28 -0800 Subject: [PATCH 5/7] parallelize --- provider/cmd/pulumi-tfgen-aws/wafv2_test.go | 2 ++ provider/configure_test.go | 6 ++++++ provider/diag_test.go | 2 ++ provider/diff_test.go | 4 ++++ provider/enum_test.go | 4 ++++ provider/fast_test.go | 4 +++- provider/pkg/batch/compute_environment_test.go | 2 ++ provider/pkg/minimalschema/minimalschema_test.go | 2 ++ provider/resources.go | 5 +++++ provider/resources_test.go | 10 +++++++++- provider/shim_test.go | 2 ++ provider/tags_test.go | 8 ++++++++ 12 files changed, 49 insertions(+), 2 deletions(-) diff --git a/provider/cmd/pulumi-tfgen-aws/wafv2_test.go b/provider/cmd/pulumi-tfgen-aws/wafv2_test.go index d6945b082a3..428198cc571 100644 --- a/provider/cmd/pulumi-tfgen-aws/wafv2_test.go +++ b/provider/cmd/pulumi-tfgen-aws/wafv2_test.go @@ -10,6 +10,8 @@ import ( ) func TestReplaceWafV2TypesWithRecursive(t *testing.T) { + t.Parallel() + spec := schema.PackageSpec{ Types: map[string]schema.ComplexTypeSpec{ // Root statement - keep it. diff --git a/provider/configure_test.go b/provider/configure_test.go index ca02069fa44..0d3668d2fbc 100644 --- a/provider/configure_test.go +++ b/provider/configure_test.go @@ -29,6 +29,8 @@ import ( ) func TestCheckConfigWithUnknownKeys(t *testing.T) { + t.Parallel() + // Double checking that this is a failure, but no longer over-fitting the test on the exact // error message. See pulumi/pulumi-terraform-bridge codebase instead for controlling the // generated error message. @@ -57,6 +59,8 @@ func TestCheckConfigWithUnknownKeys(t *testing.T) { } func TestCheckConfigRunsUpstreamValidators(t *testing.T) { + t.Parallel() + replaySequence(t, strings.ReplaceAll(` [{ "method": "/pulumirpc.ResourceProvider/CheckConfig", @@ -84,6 +88,8 @@ func TestCheckConfigRunsUpstreamValidators(t *testing.T) { } func TestCheckConfigFastWithCustomEndpoints(t *testing.T) { + t.Parallel() + time0 := time.Now() replaySequence(t, ` [{ diff --git a/provider/diag_test.go b/provider/diag_test.go index f089801d05c..2138114a811 100644 --- a/provider/diag_test.go +++ b/provider/diag_test.go @@ -10,6 +10,8 @@ import ( ) func TestFormatDiags(t *testing.T) { + t.Parallel() + type testCase struct { name string config diag.Diagnostics diff --git a/provider/diff_test.go b/provider/diff_test.go index 0325caf0bd5..f07e2e6c95e 100644 --- a/provider/diff_test.go +++ b/provider/diff_test.go @@ -27,6 +27,8 @@ import ( // // See also pulumi/pulumi-aws#3650. func TestRegressLandingZoneDiff(t *testing.T) { + t.Parallel() + event := ` [{ "method": "/pulumirpc.ResourceProvider/Diff", @@ -66,6 +68,8 @@ func TestRegressLandingZoneDiff(t *testing.T) { } func TestRegress1738(t *testing.T) { + t.Parallel() + containerDefinitionsOld := ` [ { diff --git a/provider/enum_test.go b/provider/enum_test.go index 6f91df741ab..9f96f64c61c 100644 --- a/provider/enum_test.go +++ b/provider/enum_test.go @@ -9,6 +9,8 @@ import ( ) func TestInstanceTypeName(t *testing.T) { + t.Parallel() + type testCase struct { Value string Name string @@ -34,6 +36,8 @@ func TestInstanceTypeName(t *testing.T) { } func TestInstanceTypeNameErr(t *testing.T) { + t.Parallel() + testCases := []string{ "a1.metal.pc", } diff --git a/provider/fast_test.go b/provider/fast_test.go index cd2c9967d4c..c0814215d6d 100644 --- a/provider/fast_test.go +++ b/provider/fast_test.go @@ -10,7 +10,9 @@ func init() { version.Version = "1.2.4" } -func TestProvider(_ *testing.T) { +func TestProvider(t *testing.T) { + t.Parallel() + Provider() } diff --git a/provider/pkg/batch/compute_environment_test.go b/provider/pkg/batch/compute_environment_test.go index 98be0219c09..c6be1d2a9ec 100644 --- a/provider/pkg/batch/compute_environment_test.go +++ b/provider/pkg/batch/compute_environment_test.go @@ -11,6 +11,8 @@ import ( ) func TestComputeEnvironmentTransformFromState(t *testing.T) { + t.Parallel() + ctx := context.Background() pm := resource.PropertyMap{ "computeResources": resource.NewObjectProperty(resource.PropertyMap{ diff --git a/provider/pkg/minimalschema/minimalschema_test.go b/provider/pkg/minimalschema/minimalschema_test.go index 51d4fbbba84..9ef25897407 100644 --- a/provider/pkg/minimalschema/minimalschema_test.go +++ b/provider/pkg/minimalschema/minimalschema_test.go @@ -17,6 +17,8 @@ const ( ) func TestNoDanglingReferencesInLightSchema(t *testing.T) { + t.Parallel() + // Check that minimal schema has no dangling references. bytes, err := os.ReadFile(minimalSchemaFile) require.NoError(t, err) diff --git a/provider/resources.go b/provider/resources.go index 0213bdd1f58..748befb7f44 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -23,6 +23,7 @@ import ( "path/filepath" "strconv" "strings" + "sync" "sync/atomic" "time" "unicode" @@ -493,9 +494,13 @@ var namespaceMap = map[string]string{ "aws": "Aws", } +var _nslock = sync.Mutex{} + // awsMember manufactures a type token for the AWS package and the given module, file name, and type. func awsMember(moduleTitle string, fn string, mem string) tokens.ModuleMember { moduleName := strings.ToLower(moduleTitle) + _nslock.Lock() + defer _nslock.Unlock() namespaceMap[moduleName] = moduleTitle if fn != "" { moduleName += "/" + fn diff --git a/provider/resources_test.go b/provider/resources_test.go index 2a76cc43203..2601b5d0e00 100644 --- a/provider/resources_test.go +++ b/provider/resources_test.go @@ -4,12 +4,14 @@ import ( "context" "testing" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" + shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/stretchr/testify/assert" ) func TestParseDuration(t *testing.T) { + t.Parallel() + for _, v := range []string{ "1", "60", @@ -29,6 +31,8 @@ func TestParseDuration(t *testing.T) { } func TestHasNonComputedTagsAndTagsAllOptimized(t *testing.T) { + t.Parallel() + p := Provider() p.P.ResourcesMap().Range(func(key string, value shim.Resource) bool { actual := hasNonComputedTagsAndTagsAllOptimized(key, value) @@ -50,6 +54,8 @@ func TestHasNonComputedTagsAndTagsAllOptimized(t *testing.T) { } func TestHasOptionalOrRequiredNamePropertyOptimized(t *testing.T) { + t.Parallel() + p := Provider() p.P.ResourcesMap().Range(func(key string, value shim.Resource) bool { actual := hasOptionalOrRequiredNameProperty(p.P, key) @@ -67,6 +73,8 @@ func TestHasOptionalOrRequiredNamePropertyOptimized(t *testing.T) { } } func TestExtractTags(t *testing.T) { + t.Parallel() + tests := []struct { name string vars resource.PropertyMap diff --git a/provider/shim_test.go b/provider/shim_test.go index e19d73e2989..e96f1f51168 100644 --- a/provider/shim_test.go +++ b/provider/shim_test.go @@ -23,6 +23,8 @@ import ( // This checks that any runtime checks in the underlying provider (with patches) are passed. func TestProviderShim(t *testing.T) { + t.Parallel() + ctx := context.Background() _, err := shim.NewUpstreamProvider(ctx) if err != nil { diff --git a/provider/tags_test.go b/provider/tags_test.go index f7d511eb19c..9edec3b2953 100644 --- a/provider/tags_test.go +++ b/provider/tags_test.go @@ -27,6 +27,8 @@ import ( ) func TestApplyTags(t *testing.T) { + t.Parallel() + ctx := context.Background() type gen = *rapid.Generator[resource.PropertyValue] @@ -221,6 +223,8 @@ func TestApplyTags(t *testing.T) { } func TestApplyTagsOutputs(t *testing.T) { + t.Parallel() + ctx := context.Background() type gen = *rapid.Generator[resource.PropertyValue] @@ -402,6 +406,8 @@ func TestApplyTagsOutputs(t *testing.T) { } func TestAddingEmptyTagProducesChangeDiff(t *testing.T) { + t.Parallel() + replayEvent := ` [ { @@ -498,6 +504,8 @@ func TestAddingEmptyTagProducesChangeDiff(t *testing.T) { } func TestTagsAllNoLongerComputed(t *testing.T) { + t.Parallel() + p := Provider().P p.ResourcesMap().Range(func(key string, res tfshim.Resource) bool { tagsAll, ok := res.Schema().GetOk("tags_all") From 36606aab2735b4a0d97709b274e9b9689a3bf63b Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Fri, 13 Dec 2024 13:51:46 -0800 Subject: [PATCH 6/7] re-use the build cache --- ...rlint-by-re-using-build-cache-and-ig.patch | 24 +++++++++++++++++++ provider/go.mod | 2 -- provider/go.sum | 5 ---- provider/upstream_test.go | 10 -------- 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 patches/0079-Speed-up-providerlint-by-re-using-build-cache-and-ig.patch diff --git a/patches/0079-Speed-up-providerlint-by-re-using-build-cache-and-ig.patch b/patches/0079-Speed-up-providerlint-by-re-using-build-cache-and-ig.patch new file mode 100644 index 00000000000..95a0a05ded9 --- /dev/null +++ b/patches/0079-Speed-up-providerlint-by-re-using-build-cache-and-ig.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bryce Lampe +Date: Fri, 13 Dec 2024 13:44:02 -0800 +Subject: [PATCH] Speed up providerlint by re-using build cache and ignoring + tests + + +diff --git a/GNUmakefile b/GNUmakefile +index 9b4adecff8..32137c8919 100644 +--- a/GNUmakefile ++++ b/GNUmakefile +@@ -326,9 +326,10 @@ prereq-go: ## If $(GO_VER) is not installed, install it + + provider-lint: ## [CI] ProviderLint Checks / providerlint + @echo "make: ProviderLint Checks / providerlint..." +- @cd .ci/providerlint && go install -buildvcs=false . +- @providerlint \ ++ @cd .ci/providerlint && go build -buildvcs=false . ++ @.ci/providerlint/providerlint \ + -c 1 \ ++ -test=false \ + -AT001.ignored-filename-suffixes=_data_source_test.go \ + -AWSAT006=false \ + -AWSR002=false \ diff --git a/provider/go.mod b/provider/go.mod index ac616a68b73..d96d01bf5c1 100644 --- a/provider/go.mod +++ b/provider/go.mod @@ -11,7 +11,6 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.28.6 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.43.1 - github.com/bflad/tfproviderlint v0.30.0 github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.59 github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 github.com/hashicorp/terraform-provider-aws v1.60.1-0.20220923175450-ca71523cdc36 @@ -320,7 +319,6 @@ require ( github.com/aws/smithy-go v1.22.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/beevik/etree v1.4.1 // indirect - github.com/bflad/gopaniccheck v0.1.0 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/blang/semver v3.5.1+incompatible // indirect diff --git a/provider/go.sum b/provider/go.sum index d4dab8fd0c0..0412607f73c 100644 --- a/provider/go.sum +++ b/provider/go.sum @@ -1764,10 +1764,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= -github.com/bflad/gopaniccheck v0.1.0 h1:tJftp+bv42ouERmUMWLoUn/5bi/iQZjHPznM00cP/bU= -github.com/bflad/gopaniccheck v0.1.0/go.mod h1:ZCj2vSr7EqVeDaqVsWN4n2MwdROx1YL+LFo47TSWtsA= -github.com/bflad/tfproviderlint v0.30.0 h1:XBbTGPS4ZagSt4Qtnus3Vgh5yOeHNLZhnjcTcsSJ7ZM= -github.com/bflad/tfproviderlint v0.30.0/go.mod h1:eBZHT0r7HKPGw1uZEyGMzcR1/d+GAXq9KzQfw0I7wtY= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -3059,7 +3055,6 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200214201135-548b770e2dfa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= diff --git a/provider/upstream_test.go b/provider/upstream_test.go index 5fa1052d57a..228970ab5c7 100644 --- a/provider/upstream_test.go +++ b/provider/upstream_test.go @@ -18,16 +18,6 @@ import ( "os/exec" "testing" - // Compile these into our test binary directly. Normally these are already - // compiled and cached, but cold boots take a while and we don't want to - // time out during the test if it needs to build providerlint from scratch. - // NB: This is fragile because upstream (and upstream/.ci/providerlint) - // exist in different modules. If our versioning differs we will end up - // re-compiling. It would be beneficial to keep everything in one module. - _ "github.com/bflad/tfproviderlint/passes" - _ "github.com/bflad/tfproviderlint/xpasses" - _ "github.com/hashicorp/aws-sdk-go-base/v2" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) From 24e6dfb749b4be6ca512a9ae5f0329c2d334ec90 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Mon, 16 Dec 2024 09:19:33 -0800 Subject: [PATCH 7/7] don't parallelize timing test --- provider/configure_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/provider/configure_test.go b/provider/configure_test.go index 0d3668d2fbc..a0988bd5d8e 100644 --- a/provider/configure_test.go +++ b/provider/configure_test.go @@ -88,8 +88,6 @@ func TestCheckConfigRunsUpstreamValidators(t *testing.T) { } func TestCheckConfigFastWithCustomEndpoints(t *testing.T) { - t.Parallel() - time0 := time.Now() replaySequence(t, ` [{