pulumi/pkg/codegen/testing/test/program_driver.go

823 lines
26 KiB
Go
Raw Permalink Normal View History

// Copyright 2021-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 test
import (
"bufio"
"bytes"
2022-10-10 23:01:53 +00:00
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
[go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs (#16267) # Description Partially addressing https://github.com/pulumi/pulumi-azure-native/issues/3308 Implementing a new go language option called `importPathPattern` which can be used to override how the base import path and modules are concatenated to create imports in generated Go programs. By convention this used to be `{baseImportPath}/{module}` which has worked for all of our providers. However, azure-native v2 has introduced a new import scheme where the convention above causes incorrect import paths to be generated. This is where `importPathPattern` comes into play and allows for a different convention. In the case the of azure-native v2, the pattern _must_ be `github.com/pulumi/pulumi-azure-native-sdk/{module}/v2`. This PR implements `importPathPattern` and tests it using a squashed down azure-native v2 schema containing only contents from the `eventgrid` module. This schema sets the option like this: ```json "importPathPattern": "github.com/pulumi/pulumi-azure-native-sdk/{module}/v2" ``` This schema also modifies `packageImportAliases` from the current azure-native v2 schema to exclude /v2 before the module path (see the file below). This change is needed in the actual azure-native v2 provider cc @danielrbradley and it is the second part of fully fixing https://github.com/pulumi/pulumi-azure-native/issues/3308 > We cannot just use `{baseImportPath}/{module}` because the base import path for azure-native v2 has a suffix v2 (it's required) Also implemented a small feature in ProgramTest to allow overriding the used plugin host for the specific program test, this is because I wanted to test the program against the simplified azure-native v2 schema without changing how other test load the previous azure-native v1.x schemas (I tested that without this, binding programs fails) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-05-30 19:51:12 +00:00
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
"github.com/blang/semver"
"github.com/hashicorp/hcl/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/pulumi/pulumi/pkg/v3/codegen"
"github.com/pulumi/pulumi/pkg/v3/codegen/hcl2/syntax"
"github.com/pulumi/pulumi/pkg/v3/codegen/pcl"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/utils"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
)
2022-10-20 20:37:10 +00:00
const (
transpiledExamplesDir = "transpiled_examples"
)
func transpiled(dir string) string {
return filepath.Join(transpiledExamplesDir, dir)
}
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
var allProgLanguages = codegen.NewStringSet(TestDotnet, TestPython, TestGo, TestNodeJS)
type ProgramTest struct {
Directory string
Description string
Skip codegen.StringSet
ExpectNYIDiags codegen.StringSet
SkipCompile codegen.StringSet
2022-10-10 23:01:53 +00:00
BindOptions []pcl.BindOption
MockPluginVersions map[string]string
[go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs (#16267) # Description Partially addressing https://github.com/pulumi/pulumi-azure-native/issues/3308 Implementing a new go language option called `importPathPattern` which can be used to override how the base import path and modules are concatenated to create imports in generated Go programs. By convention this used to be `{baseImportPath}/{module}` which has worked for all of our providers. However, azure-native v2 has introduced a new import scheme where the convention above causes incorrect import paths to be generated. This is where `importPathPattern` comes into play and allows for a different convention. In the case the of azure-native v2, the pattern _must_ be `github.com/pulumi/pulumi-azure-native-sdk/{module}/v2`. This PR implements `importPathPattern` and tests it using a squashed down azure-native v2 schema containing only contents from the `eventgrid` module. This schema sets the option like this: ```json "importPathPattern": "github.com/pulumi/pulumi-azure-native-sdk/{module}/v2" ``` This schema also modifies `packageImportAliases` from the current azure-native v2 schema to exclude /v2 before the module path (see the file below). This change is needed in the actual azure-native v2 provider cc @danielrbradley and it is the second part of fully fixing https://github.com/pulumi/pulumi-azure-native/issues/3308 > We cannot just use `{baseImportPath}/{module}` because the base import path for azure-native v2 has a suffix v2 (it's required) Also implemented a small feature in ProgramTest to allow overriding the used plugin host for the specific program test, this is because I wanted to test the program against the simplified azure-native v2 schema without changing how other test load the previous azure-native v1.x schemas (I tested that without this, binding programs fails) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-05-30 19:51:12 +00:00
PluginHost plugin.Host
}
var testdataPath = filepath.Join("..", "testing", "test", "testdata")
// Get batch number k (base-1 indexed) of tests out of n batches total.
func ProgramTestBatch(k, n int) []ProgramTest {
start := ((k - 1) * len(PulumiPulumiProgramTests)) / n
end := ((k) * len(PulumiPulumiProgramTests)) / n
return PulumiPulumiProgramTests[start:end]
}
// Useful when debugging a single test case.
func SingleTestCase(directoryName string) []ProgramTest {
output := make([]ProgramTest, 0)
for _, t := range PulumiPulumiProgramTests {
if t.Directory == directoryName {
output = append(output, t)
}
}
return output
}
var PulumiPulumiProgramTests = []ProgramTest{
{
Directory: "assets-archives",
Description: "Assets and archives",
},
{
Directory: "synthetic-resource-properties",
Description: "Synthetic resource properties",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestNodeJS, TestDotnet, TestGo), // not a real package
},
{
Directory: "aws-s3-folder",
Description: "AWS S3 Folder",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
// Blocked on go:
// TODO[pulumi/pulumi#8064]
// TODO[pulumi/pulumi#8065]
},
{
Directory: "aws-eks",
Description: "AWS EKS",
},
{
Directory: "aws-fargate",
Description: "AWS Fargate",
},
[program-gen] Fix panic when generating programs for MLC packages using external types (#15605) # Description For an MLC package such as `aws-static-website`, it has some types which are referenced from the `aws` package. Program-gen assumes packages are inferred from resources and invokes, not types which caused panics in Go (#15597), dotnet and python (https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2) This PR fixes those panics. In Go the panic was due to using package name instead of the package reference from the imported type. In dotnet and python was due to assuming no external type references. Now we generate nice code for all these languages. That said, there is still an issue of resolving imports for the packages of these external types. It works in Go, TypeScript doesn't need it but dotnet and python do. That is why the latter are added in `SkipCompile` in the test program. Fixes #15597 Fixes https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/3 Fixes https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2 ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-10 17:23:15 +00:00
{
Directory: "aws-static-website",
Description: "an example resource from AWS static website multi-language component",
// TODO: blocked on resolving imports (python) / using statements (C#) for types from external packages
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestDotnet, TestPython),
[program-gen] Fix panic when generating programs for MLC packages using external types (#15605) # Description For an MLC package such as `aws-static-website`, it has some types which are referenced from the `aws` package. Program-gen assumes packages are inferred from resources and invokes, not types which caused panics in Go (#15597), dotnet and python (https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2) This PR fixes those panics. In Go the panic was due to using package name instead of the package reference from the imported type. In dotnet and python was due to assuming no external type references. Now we generate nice code for all these languages. That said, there is still an issue of resolving imports for the packages of these external types. It works in Go, TypeScript doesn't need it but dotnet and python do. That is why the latter are added in `SkipCompile` in the test program. Fixes #15597 Fixes https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/3 Fixes https://github.com/pulumi/pulumi-converter-constructor-syntax/issues/2 ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-10 17:23:15 +00:00
},
{
Directory: "aws-fargate-output-versioned",
Description: "AWS Fargate Using Output-versioned invokes for python and typescript",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet),
BindOptions: []pcl.BindOption{pcl.PreferOutputVersionedInvokes},
},
{
Directory: "aws-s3-logging",
Description: "AWS S3 with logging",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
// Blocked on nodejs: TODO[pulumi/pulumi#8068]
2021-11-15 20:17:20 +00:00
// Flaky in go: TODO[pulumi/pulumi#8123]
},
{
Directory: "aws-iam-policy",
Description: "AWS IAM Policy",
},
{
Directory: "read-file-func",
Description: "ReadFile function translation works",
},
2022-10-06 17:02:30 +00:00
{
Directory: "python-regress-10914",
Description: "Python regression test for #10914",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestPython),
2022-10-06 17:02:30 +00:00
},
{
Directory: "simplified-invokes",
Description: "Simplified invokes",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestPython, TestGo),
SkipCompile: codegen.NewStringSet(TestDotnet, TestNodeJS),
},
{
Directory: "aws-optionals",
Description: "AWS get invoke with nested object constructor that takes an optional string",
// Testing Go behavior exclusively:
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestGo),
},
{
Directory: "aws-webserver",
Description: "AWS Webserver",
},
{
Directory: "simple-range",
Description: "Simple range as int expression translation",
},
{
Directory: "azure-native",
Description: "Azure Native",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo, TestDotnet),
// Blocked on go:
// TODO[pulumi/pulumi#8073]
// TODO[pulumi/pulumi#8074]
},
[go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs (#16267) # Description Partially addressing https://github.com/pulumi/pulumi-azure-native/issues/3308 Implementing a new go language option called `importPathPattern` which can be used to override how the base import path and modules are concatenated to create imports in generated Go programs. By convention this used to be `{baseImportPath}/{module}` which has worked for all of our providers. However, azure-native v2 has introduced a new import scheme where the convention above causes incorrect import paths to be generated. This is where `importPathPattern` comes into play and allows for a different convention. In the case the of azure-native v2, the pattern _must_ be `github.com/pulumi/pulumi-azure-native-sdk/{module}/v2`. This PR implements `importPathPattern` and tests it using a squashed down azure-native v2 schema containing only contents from the `eventgrid` module. This schema sets the option like this: ```json "importPathPattern": "github.com/pulumi/pulumi-azure-native-sdk/{module}/v2" ``` This schema also modifies `packageImportAliases` from the current azure-native v2 schema to exclude /v2 before the module path (see the file below). This change is needed in the actual azure-native v2 provider cc @danielrbradley and it is the second part of fully fixing https://github.com/pulumi/pulumi-azure-native/issues/3308 > We cannot just use `{baseImportPath}/{module}` because the base import path for azure-native v2 has a suffix v2 (it's required) Also implemented a small feature in ProgramTest to allow overriding the used plugin host for the specific program test, this is because I wanted to test the program against the simplified azure-native v2 schema without changing how other test load the previous azure-native v1.x schemas (I tested that without this, binding programs fails) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-05-30 19:51:12 +00:00
{
Directory: "azure-native-v2-eventgrid",
Description: "Azure Native V2 basic example to ensure that importPathPatten works",
// Specifically use a simplified azure-native v2.x schema when testing this program
// this schema only contains content from the eventgrid module which is sufficient to test with
PluginHost: utils.NewHostWithProviders(testdataPath,
utils.NewSchemaProvider("azure-native", "2.41.0")),
},
{
Directory: "azure-sa",
Description: "Azure SA",
},
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
{
Directory: "string-enum-union-list",
Description: "Contains resource which has a property of type List<Union<String, Enum>>",
// skipping compiling on Go because it doesn't know to handle unions in lists
// and instead generates pulumi.StringArray
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
},
[program-gen/go,dotnet] Fixes emited code for object expressions assigned to properties of type Any (#15770) # Description Fixes #15769 by specifically handling object expressions that are annotated as `Any` and emitting the correct code. - In case of Go, expression `X` is emitted as `pulumi.Any(X)` where the type name here is `map[string]interface{}`. - In case of C#, we generate `Dictionary<string, object?>` expressions (similar to what we do inside `toJSON` calls) - Updates the test aws-native schema from 0.13.0 to 0.99.0 ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-24 00:06:57 +00:00
{
Directory: "using-object-as-input-for-any",
Description: "Tests using object as input for a property of type 'any'",
},
{
Directory: "kubernetes-operator",
Description: "K8s Operator",
},
{
Directory: "kubernetes-pod",
Description: "K8s Pod",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
// Blocked on go:
// TODO[pulumi/pulumi#8073]
// TODO[pulumi/pulumi#8074]
},
{
Directory: "kubernetes-template",
Description: "K8s Template",
},
[program-gen/pcl] Fixes type-annotating nested resource properties when these have quoted keys (#15001) # Description When binding resource properties and annotating these with types from their schemas, we seem to skip this annotation process when resource properties and their nested objects use _quoted_ keys `{ "key" = <value> }` rather than using _literal_ keys `{ key = <value> }`. This results in issues such as https://github.com/pulumi/kube2pulumi/issues/60 where a csharp property name override was not correctly applied because 1) kube2pulumi generated properties for resources that are quoted (this should be fine) 2) binding the resource properties skipped annotating the nested object with its corresponding schema type 3) program-gen in dotnet didn't have access to the schema type of the nested object to correctly apply the property override This PR fixes this issue by extending PCL resource binding to also check for properties which have quoted keys. Fixes https://github.com/pulumi/kube2pulumi/issues/60 and potentially other issues that arise from converters generating PCL with quoted keys. ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-27 12:42:52 +00:00
{
Directory: "kubernetes-template-quoted",
Description: "K8s Template with quoted string property keys to ensure that resource binding works here",
},
{
Directory: "random-pet",
Description: "Random Pet",
},
{
Directory: "aws-secret",
Description: "Secret",
},
{
Directory: "functions",
Description: "Functions",
},
{
Directory: "output-funcs-aws",
Description: "Output Versioned Functions",
},
{
Directory: "third-party-package",
Description: "Ensuring correct imports for third party packages",
// compiling and type checking involves downloading the real package to
// check against. Because we are checking against the "other" package
// (which doesn't exist), this does not work.
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestNodeJS, TestDotnet, TestGo),
},
{
Directory: "invalid-go-sprintf",
Description: "Regress invalid Go",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestPython, TestNodeJS, TestDotnet),
},
{
Directory: "typed-enum",
Description: "Supply strongly typed enums",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo),
},
2022-08-19 17:27:05 +00:00
{
Directory: "pulumi-stack-reference",
Description: "StackReference as resource",
},
{
Directory: "python-resource-names",
Description: "Repro for #9357",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
},
{
Directory: "logical-name",
Description: "Logical names",
},
{
Directory: "aws-lambda",
Description: "AWS Lambdas",
// We have special testing for this case because lambda is a python keyword.
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
},
{
[program-gen/tests] Replace discriminated unions test program with a program from a synthetic schema of basic unions (#15771) # Description This PR replaces the test program `discriminated-unions` with a new program `basic-unions` that uses a synthetic schema that has basic union definitions. The former program was failing compilation with Go because of a **faulty** azure-native SDK (tests using v1.56.0). It didn't generate the extra types for union objects (those with suffix `Args`). Those missing extra types are added in newer versions of azure-native SDK but the shape of the same resource doesn't have unions anymore so we can't just upgrade the version of the azure-native sdk we are testing with. I decided not to depend on a specific azure-native SDK and instead use a synthetic schema with the sole purpose of showing that we can emit correct code for fields assigned to object which are bound to different union cases. The downside here is that we can't compile the example for any language since it is a synthetic schema with no generated SDK (conformance tests in Go would make this possible but we are far away from that 😢) Closes #10834 since the original issue was due to faulty SDK, not program-gen. ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-28 10:49:27 +00:00
Directory: "basic-unions",
Description: "Tests program generation of fields of type union",
SkipCompile: allProgLanguages, // because the schema is synthetic
},
{
Directory: "traverse-union-repro",
Description: `Handling the error "cannot traverse value of type union(...)"`,
BindOptions: []pcl.BindOption{
pcl.SkipResourceTypechecking,
pcl.AllowMissingVariables,
pcl.AllowMissingProperties,
},
// The example is known to be invalid. Specifically it hands a
// `[aws_subnet.test1.id]` to a `string` attribute, where `aws_subnet` is not in
// scope.
//
// The example is invalid in two ways:
// 1. `aws_subnet` is a missing variable.
// 2. `[...]` is a tuple, which can never be a string.
//
// Even though the generated code will not type check, it should still be
// directionally correct.
SkipCompile: allProgLanguages,
},
{
Directory: "components",
Description: "Components",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
},
{
Directory: "entries-function",
Description: "Using the entries function",
// go and dotnet do fully not support GenForExpression yet
// Todo: https://github.com/pulumi/pulumi/issues/12606
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: allProgLanguages.Except(TestNodeJS).Except(TestPython),
},
{
Directory: "retain-on-delete",
Description: "Generate RetainOnDelete option",
},
{
Directory: "depends-on-array",
Description: "Using DependsOn resource option with an array of resources",
},
{
Directory: "multiline-string",
Description: "Multiline string literals",
},
[program-gen/go] Fix required config variables of type bool and number (#14958) # Description While covering more parts of go codegen, I've seen that config variables are broken 😓 specifically when requiring config variables using `RequireFloat` it should be `RequireFloat64` and `RequireBoolean` should be `RequireBool`. Moreover, it seems that `RequireObject` doesn't work at all since the function signature doesn't match the way it was generated (see #14957) C# has a similar issue with optional untyped objects as config variables. For now have skipped compilation for those. ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-20 13:16:37 +00:00
{
Directory: "config-variables",
Description: "Basic program with a bunch of config variables",
// TODO[https://github.com/pulumi/pulumi/issues/14957] - object config variables are broken here
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo, TestDotnet),
[program-gen/go] Fix required config variables of type bool and number (#14958) # Description While covering more parts of go codegen, I've seen that config variables are broken 😓 specifically when requiring config variables using `RequireFloat` it should be `RequireFloat64` and `RequireBoolean` should be `RequireBool`. Moreover, it seems that `RequireObject` doesn't work at all since the function signature doesn't match the way it was generated (see #14957) C# has a similar issue with optional untyped objects as config variables. For now have skipped compilation for those. ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-12-20 13:16:37 +00:00
},
{
Directory: "regress-11176",
Description: "Regression test for https://github.com/pulumi/pulumi/issues/11176",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestGo),
},
{
Directory: "throw-not-implemented",
Description: "Function notImplemented is compiled to a runtime error at call-site",
},
{
Directory: "python-reserved",
Description: "Test python reserved words aren't used",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestPython),
},
{
Directory: "iterating-optional-range-expressions",
Description: "Test that we can iterate over range expression that are option(iterator)",
// TODO: dotnet and go
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS).Except(TestPython),
// We are using a synthetic schema defined in range-1.0.0.json so we can't compile all the way
SkipCompile: allProgLanguages,
},
{
Directory: "output-literals",
Description: "Tests that we can return various literal values via stack outputs",
},
{
Directory: "dynamic-entries",
Description: "Testing iteration of dynamic entries in TypeScript",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS),
SkipCompile: allProgLanguages,
},
{
Directory: "single-or-none",
Description: "Tests using the singleOrNone function",
},
{
Directory: "simple-splat",
Description: "An example that shows we can compile splat expressions from array of objects",
// Skip compiling because we are using a test schema without a corresponding real package
SkipCompile: allProgLanguages,
},
{
Directory: "invoke-inside-conditional-range",
Description: "Using the result of an invoke inside a conditional range expression of a resource",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS).Except(TestDotnet),
SkipCompile: allProgLanguages,
},
{
Directory: "output-name-conflict",
Description: "Tests whether we are able to generate programs where output variables have same id as config var",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
},
{
Directory: "snowflake-python-12998",
Description: "Tests regression for issue https://github.com/pulumi/pulumi/issues/12998",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestPython),
SkipCompile: allProgLanguages,
BindOptions: []pcl.BindOption{pcl.AllowMissingVariables, pcl.AllowMissingProperties},
},
{
Directory: "unknown-resource",
Description: "Tests generating code for unknown resources when skipping resource type-checking",
SkipCompile: allProgLanguages,
BindOptions: []pcl.BindOption{pcl.SkipResourceTypechecking},
},
{
Directory: "using-dashes",
Description: "Test program generation on packages with a dash in the name",
SkipCompile: allProgLanguages, // since we are using a synthetic schema
},
{
Directory: "unknown-invoke",
Description: "Tests generating code for unknown invokes when skipping invoke type checking",
SkipCompile: allProgLanguages,
BindOptions: []pcl.BindOption{pcl.SkipInvokeTypechecking},
},
{
Directory: "optional-complex-config",
Description: "Tests generating code for optional and complex config values",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS).Except(TestDotnet),
SkipCompile: allProgLanguages.Except(TestNodeJS).Except(TestDotnet),
},
{
Directory: "interpolated-string-keys",
Description: "Tests that interpolated string keys are supported in maps. ",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS).Except(TestPython),
},
{
Directory: "regress-node-12507",
Description: "Regression test for https://github.com/pulumi/pulumi/issues/12507",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestNodeJS),
BindOptions: []pcl.BindOption{pcl.PreferOutputVersionedInvokes},
},
{
Directory: "csharp-plain-lists",
Description: "Tests that plain lists are supported in C#",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestDotnet),
},
{
Directory: "csharp-typed-for-expressions",
Description: "Testing for expressions with typed target expressions in csharp",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestDotnet),
},
{
Directory: "empty-list-property",
Description: "Tests compiling empty list expressions of object properties",
},
{
Directory: "python-regress-14037",
Description: "Regression test for rewriting qoutes in python",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: allProgLanguages.Except(TestPython),
},
[go/program-gen] Fix using inline invoke expressions inside resources, objects and arrays (#14484) # Description This PR fixes an issue in Go program where if users are writing invoke expressions inline inside other expressions, then that invoke is extracted into a temporary variable and then later referenced the same way it was used. This is because non-output-versioned invokes cannot be used directly since they return a tuple (InvokeResult, err) so we need to check for the error before proceeding. Fixes #14064 ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-11-03 14:22:43 +00:00
{
Directory: "inline-invokes",
Description: "Tests whether using inline invoke expressions works",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
SkipCompile: codegen.NewStringSet(TestGo),
[go/program-gen] Fix using inline invoke expressions inside resources, objects and arrays (#14484) # Description This PR fixes an issue in Go program where if users are writing invoke expressions inline inside other expressions, then that invoke is extracted into a temporary variable and then later referenced the same way it was used. This is because non-output-versioned invokes cannot be used directly since they return a tuple (InvokeResult, err) so we need to check for the error before proceeding. Fixes #14064 ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-11-03 14:22:43 +00:00
},
2022-10-27 18:01:05 +00:00
}
var PulumiPulumiYAMLProgramTests = []ProgramTest{
2022-10-20 20:37:10 +00:00
// PCL files from pulumi/yaml transpiled examples
{
Directory: transpiled("aws-eks"),
Description: "AWS EKS",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("aws-static-website"),
Description: "AWS static website",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
BindOptions: []pcl.BindOption{pcl.SkipResourceTypechecking},
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("awsx-fargate"),
Description: "AWSx Fargate",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestDotnet, TestNodeJS, TestGo),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("azure-app-service"),
Description: "Azure App Service",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("azure-container-apps"),
Description: "Azure Container Apps",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet, TestPython),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("azure-static-website"),
Description: "Azure static website",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet, TestPython),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("cue-eks"),
Description: "Cue EKS",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("cue-random"),
Description: "Cue random",
},
{
Directory: transpiled("getting-started"),
Description: "Getting started",
},
{
Directory: transpiled("kubernetes"),
Description: "Kubernetes",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("pulumi-variable"),
Description: "Pulumi variable",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("random"),
Description: "Random",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestNodeJS),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("readme"),
Description: "README",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("stackreference-consumer"),
Description: "Stack reference consumer",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestNodeJS, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("stackreference-producer"),
Description: "Stack reference producer",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("webserver-json"),
Description: "Webserver JSON",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet, TestPython),
2022-10-20 20:37:10 +00:00
},
{
Directory: transpiled("webserver"),
Description: "Webserver",
Don't publish test code in `pkg/codegen` (#17517) Presently, we implement code generation (e.g. for SDKs and programs/`pulumi convert`) on a per-language basis in `pkg/codegen`. Alongside these implementations, we have a set of tests built using a common framework that use snapshots to verify that code generation doesn't break when changes are made. Unfortunately, due to the way things are currently laid out in our repository, these tests and their dependencies are shipped as part of the `pkg/codegen` package. This commit brings @blampe's work in https://github.com/pulumi/pulumi/pull/16011 up to date and fixes this by taking the following actions: * Test harnesses that were previously located in `pkg/codegen/<language>/test.go` are moved to `pkg/codegen/testing/test/<language>.go`. By default, Go excludes files ending in `_test.go`, but *not* files named e.g. `test.go`. It might seem logical therefore to just rename these files (e.g. to `codegen_test.go`), so that they can continue to live alongside their language implementations. Unfortunately, while this fixes one problem (dependencies pulling in test code), it introduces another -- the existing `test.go` files actually exist to implement an interface which is used by the common codegen-test framework we have. Moving to `*_test.go` files would make them invisible to the actual modules which run the tests through that framework. * Test code is consequently refactored to clean up the separation of test details (e.g. relevant fixtures) and execution implementation (working directory, means of program generation). * The `gen_program_test/generate.go` program, which we use to generate the "batch tests", has been updated so that it respects the new code layout and organisation. As laid out by @blampe in #16011 (and shamelessly copied here), this brings a number of benefits. Test dependencies are no longer included in non-test packages that are consumed downstream. As an example, this takes the `pulumi-language-go` binary from ~61MB down to ~36MB, and speeds up build times: ``` go clean -cache && time go build . (master) go build . 81.06s user 17.36s system 470% cpu 20.933 total (PR) go build . 47.77s user 9.20s system 530% cpu 10.737 total ``` This doesn't completely remove these dependencies from downstream because most also include `pkg/v3/testing/integration` in tests. It does only compile these dependencies into the test binary, though. Before: ``` ❯ go mod why github.com/aws/aws-sdk-go-v2/service/sts github.com/pulumi/pulumi-random/provider/v4/cmd/pulumi-tfgen-random github.com/pulumi/pulumi-terraform-bridge/pf/tfgen github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen github.com/pulumi/pulumi/pkg/v3/codegen/dotnet github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` After: ``` github.com/pulumi/pulumi-random/provider/v4 github.com/pulumi/pulumi-random/provider/v4.test <- expected github.com/pulumi/providertest github.com/pulumi/pulumi/pkg/v3/testing/integration github.com/pulumi/pulumi/pkg/v3/resource/stack github.com/pulumi/pulumi/pkg/v3/secrets/cloud github.com/pulumi/pulumi/pkg/v3/secrets/cloud.test github.com/aws/aws-sdk-go-v2/service/sts ``` Note: this PR has been split into a number of commits, roughly one per language, to make reviewing a bit easier. The commits *do not build individually* due to the nature of the changes, but hopefully it makes understanding the work a bit more feasible. Closes #16011 --------- Co-authored-by: Bryce Lampe <bryce@pulumi.com>
2024-10-09 11:09:54 +00:00
Skip: codegen.NewStringSet(TestGo, TestDotnet, TestPython),
2022-10-20 20:37:10 +00:00
},
}
// Checks that a generated program is correct
//
// The arguments are to be read:
// (Testing environment, path to generated code, set of dependencies)
type CheckProgramOutput = func(*testing.T, string, codegen.StringSet)
// Generates a program from a pcl.Program
type GenProgram = func(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)
// Generates a project from a pcl.Program
type GenProject = func(
directory string, project workspace.Project,
program *pcl.Program, localDependencies map[string]string,
) error
type ProgramCodegenOptions struct {
Language string
Extension string
OutputFile string
Check CheckProgramOutput
GenProgram GenProgram
TestCases []ProgramTest
// For generating a full project
IsGenProject bool
GenProject GenProject
// Maps a test file (i.e. "aws-resource-options") to a struct containing a package
// (i.e. "github.com/pulumi/pulumi-aws/sdk/v5", "pulumi-aws) and its
// version prefixed by an operator (i.e. " v5.11.0", ==5.11.0")
ExpectedVersion map[string]PkgVersionInfo
DependencyFile string
}
type PkgVersionInfo struct {
Pkg string
OpAndVersion string
}
// TestProgramCodegen runs the complete set of program code generation tests against a particular
// language's code generator.
//
// A program code generation test consists of a PCL file (.pp extension) and a set of expected outputs
// for each language.
//
// The PCL file is the only piece that must be manually authored. Once the schema has been written, the expected outputs
// can be generated by running `PULUMI_ACCEPT=true go test ./..." from the `pkg/codegen` directory.
sdk/go: Remove 'nolint' directives from package docs Go treats comments that match the following regex as directives. //[a-z0-9]+:[a-z0-9] Comments that are directives don't show in an entity's documentation. https://github.com/golang/go/commit/5a550b695117f07a4f2454039a4871250cd3ed09#diff-f56160fd9fcea272966a8a1d692ad9f49206fdd8dbcbfe384865a98cd9bc2749R165 Our code has `//nolint` directives that now show in the API Reference. This is because these directives are in one of the following forms, which don't get this special treatment. // nolint:foo //nolint: foo This change fixes all such directives found by the regex: `// nolint|//nolint: `. See bottom of commit for command used for the fix. Verification: Here's the output of `go doc` on some entities before and after this change. Before ``` % go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8 package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi" nolint: lll, interfacer nolint: lll, interfacer const EnvOrganization = "PULUMI_ORGANIZATION" ... var ErrPlugins = errors.New("pulumi: plugins requested") ``` After ``` % go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi | head -n8 package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi" const EnvOrganization = "PULUMI_ORGANIZATION" ... var ErrPlugins = errors.New("pulumi: plugins requested") func BoolRef(v bool) *bool func Float64Ref(v float64) *float64 func IntRef(v int) *int func IsSecret(o Output) bool ``` Before ``` % go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_ package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi" func URN_(o string) ResourceOption URN_ is an optional URN of a previously-registered resource of this type to read from the engine. nolint: revive ``` After: ``` % go doc github.com/pulumi/pulumi/sdk/v3/go/pulumi URN_ package pulumi // import "github.com/pulumi/pulumi/sdk/v3/go/pulumi" func URN_(o string) ResourceOption URN_ is an optional URN of a previously-registered resource of this type to read from the engine. ``` Note that golangci-lint offers a 'nolintlint' linter that finds such miuses of nolint, but it also finds other issues so I've deferred that to a follow up PR. Resolves #11785 Related: https://github.com/golangci/golangci-lint/issues/892 [git-generate] FILES=$(mktemp) rg -l '// nolint|//nolint: ' | tee "$FILES" | xargs perl -p -i -e ' s|// nolint|//nolint|g; s|//nolint: |//nolint:|g; ' rg '.go$' < "$FILES" | xargs gofmt -w -s
2023-01-06 00:07:45 +00:00
//
//nolint:revive
func TestProgramCodegen(
t *testing.T,
testcase ProgramCodegenOptions,
) {
if runtime.GOOS == "windows" {
t.Skip("TestProgramCodegen is skipped on Windows")
}
assert.NotNil(t, testcase.TestCases, "Caller must provide test cases")
pulumiAccept := cmdutil.IsTruthy(os.Getenv("PULUMI_ACCEPT"))
skipCompile := cmdutil.IsTruthy(os.Getenv("PULUMI_SKIP_COMPILE_TEST"))
2022-10-20 20:37:10 +00:00
for _, tt := range testcase.TestCases {
tt := tt // avoid capturing loop variable
t.Run(tt.Directory, func(t *testing.T) {
// These tests should not run in parallel.
// They take up a fair bit of memory
// and can OOM in CI with too many running.
var err error
if tt.Skip.Has(testcase.Language) {
t.Skip()
return
}
expectNYIDiags := tt.ExpectNYIDiags.Has(testcase.Language)
testDir := filepath.Join(testdataPath, tt.Directory+"-pp")
pclFile := filepath.Join(testDir, tt.Directory+".pp")
2022-10-20 20:37:10 +00:00
if strings.HasPrefix(tt.Directory, transpiledExamplesDir) {
pclFile = filepath.Join(testDir, filepath.Base(tt.Directory)+".pp")
}
testDir = filepath.Join(testDir, testcase.Language)
all: Reformat with gofumpt Per team discussion, switching to gofumpt. [gofumpt][1] is an alternative, stricter alternative to gofmt. It addresses other stylistic concerns that gofmt doesn't yet cover. [1]: https://github.com/mvdan/gofumpt See the full list of [Added rules][2], but it includes: - Dropping empty lines around function bodies - Dropping unnecessary variable grouping when there's only one variable - Ensuring an empty line between multi-line functions - simplification (`-s` in gofmt) is always enabled - Ensuring multi-line function signatures end with `) {` on a separate line. [2]: https://github.com/mvdan/gofumpt#Added-rules gofumpt is stricter, but there's no lock-in. All gofumpt output is valid gofmt output, so if we decide we don't like it, it's easy to switch back without any code changes. gofumpt support is built into the tooling we use for development so this won't change development workflows. - golangci-lint includes a gofumpt check (enabled in this PR) - gopls, the LSP for Go, includes a gofumpt option (see [installation instrutions][3]) [3]: https://github.com/mvdan/gofumpt#installation This change was generated by running: ```bash gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error) ``` The following files were manually tweaked afterwards: - pkg/cmd/pulumi/stack_change_secrets_provider.go: one of the lines overflowed and had comments in an inconvenient place - pkg/cmd/pulumi/destroy.go: `var x T = y` where `T` wasn't necessary - pkg/cmd/pulumi/policy_new.go: long line because of error message - pkg/backend/snapshot_test.go: long line trying to assign three variables in the same assignment I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 16:36:39 +00:00
err = os.MkdirAll(testDir, 0o700)
if err != nil && !os.IsExist(err) {
t.Fatalf("Failed to create %q: %s", testDir, err)
}
2022-10-20 20:37:10 +00:00
contents, err := os.ReadFile(pclFile)
if err != nil {
t.Fatalf("could not read %v: %v", pclFile, err)
}
expectedFile := filepath.Join(testDir, tt.Directory+"."+testcase.Extension)
2022-10-20 20:37:10 +00:00
if strings.HasPrefix(tt.Directory, transpiledExamplesDir) {
expectedFile = filepath.Join(testDir, filepath.Base(tt.Directory)+"."+testcase.Extension)
}
expected, err := os.ReadFile(expectedFile)
if err != nil && !pulumiAccept {
t.Fatalf("could not read %v: %v", expectedFile, err)
}
parser := syntax.NewParser()
err = parser.ParseFile(bytes.NewReader(contents), tt.Directory+".pp")
if err != nil {
t.Fatalf("could not read %v: %v", pclFile, err)
}
if parser.Diagnostics.HasErrors() {
t.Fatalf("failed to parse files: %v", parser.Diagnostics)
}
hclFiles := map[string]*hcl.File{
all: Reformat with gofumpt Per team discussion, switching to gofumpt. [gofumpt][1] is an alternative, stricter alternative to gofmt. It addresses other stylistic concerns that gofmt doesn't yet cover. [1]: https://github.com/mvdan/gofumpt See the full list of [Added rules][2], but it includes: - Dropping empty lines around function bodies - Dropping unnecessary variable grouping when there's only one variable - Ensuring an empty line between multi-line functions - simplification (`-s` in gofmt) is always enabled - Ensuring multi-line function signatures end with `) {` on a separate line. [2]: https://github.com/mvdan/gofumpt#Added-rules gofumpt is stricter, but there's no lock-in. All gofumpt output is valid gofmt output, so if we decide we don't like it, it's easy to switch back without any code changes. gofumpt support is built into the tooling we use for development so this won't change development workflows. - golangci-lint includes a gofumpt check (enabled in this PR) - gopls, the LSP for Go, includes a gofumpt option (see [installation instrutions][3]) [3]: https://github.com/mvdan/gofumpt#installation This change was generated by running: ```bash gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error) ``` The following files were manually tweaked afterwards: - pkg/cmd/pulumi/stack_change_secrets_provider.go: one of the lines overflowed and had comments in an inconvenient place - pkg/cmd/pulumi/destroy.go: `var x T = y` where `T` wasn't necessary - pkg/cmd/pulumi/policy_new.go: long line because of error message - pkg/backend/snapshot_test.go: long line trying to assign three variables in the same assignment I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 16:36:39 +00:00
tt.Directory + ".pp": {Body: parser.Files[0].Body, Bytes: parser.Files[0].Bytes},
}
[go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs (#16267) # Description Partially addressing https://github.com/pulumi/pulumi-azure-native/issues/3308 Implementing a new go language option called `importPathPattern` which can be used to override how the base import path and modules are concatenated to create imports in generated Go programs. By convention this used to be `{baseImportPath}/{module}` which has worked for all of our providers. However, azure-native v2 has introduced a new import scheme where the convention above causes incorrect import paths to be generated. This is where `importPathPattern` comes into play and allows for a different convention. In the case the of azure-native v2, the pattern _must_ be `github.com/pulumi/pulumi-azure-native-sdk/{module}/v2`. This PR implements `importPathPattern` and tests it using a squashed down azure-native v2 schema containing only contents from the `eventgrid` module. This schema sets the option like this: ```json "importPathPattern": "github.com/pulumi/pulumi-azure-native-sdk/{module}/v2" ``` This schema also modifies `packageImportAliases` from the current azure-native v2 schema to exclude /v2 before the module path (see the file below). This change is needed in the actual azure-native v2 provider cc @danielrbradley and it is the second part of fully fixing https://github.com/pulumi/pulumi-azure-native/issues/3308 > We cannot just use `{baseImportPath}/{module}` because the base import path for azure-native v2 has a suffix v2 (it's required) Also implemented a small feature in ProgramTest to allow overriding the used plugin host for the specific program test, this is because I wanted to test the program against the simplified azure-native v2 schema without changing how other test load the previous azure-native v1.x schemas (I tested that without this, binding programs fails) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-05-30 19:51:12 +00:00
var pluginHost plugin.Host
if tt.PluginHost != nil {
pluginHost = tt.PluginHost
} else {
pluginHost = utils.NewHost(testdataPath)
}
opts := append(tt.BindOptions, pcl.PluginHost(pluginHost))
rootProgramPath := filepath.Join(testdataPath, tt.Directory+"-pp")
absoluteProgramPath, err := filepath.Abs(rootProgramPath)
if err != nil {
t.Fatalf("failed to bind program: unable to find the absolute path of %v", rootProgramPath)
}
opts = append(opts, pcl.DirPath(absoluteProgramPath))
opts = append(opts, pcl.ComponentBinder(pcl.ComponentProgramBinderFromFileSystem()))
program, diags, err := pcl.BindProgram(parser.Files, opts...)
if err != nil {
t.Fatalf("could not bind program: %v", err)
}
bindDiags := new(bytes.Buffer)
if len(diags) > 0 {
require.NoError(t, hcl.NewDiagnosticTextWriter(bindDiags, hclFiles, 80, false).WriteDiagnostics(diags))
if diags.HasErrors() {
t.Fatalf("failed to bind program:\n%s", bindDiags)
}
t.Logf("bind diags:\n%s", bindDiags)
}
var files map[string][]byte
// generate a full project and check expected package versions
if testcase.IsGenProject {
project := workspace.Project{
Name: "test",
Runtime: workspace.NewProjectRuntimeInfo(testcase.Language, nil),
}
err = testcase.GenProject(testDir, project, program, nil /*localDependencies*/)
assert.NoError(t, err)
depFilePath := filepath.Join(testDir, testcase.DependencyFile)
outfilePath := filepath.Join(testDir, testcase.OutputFile)
CheckVersion(t, tt.Directory, depFilePath, testcase.ExpectedVersion)
GenProjectCleanUp(t, testDir, depFilePath, outfilePath)
}
files, diags, err = testcase.GenProgram(program)
assert.NoError(t, err)
if expectNYIDiags {
var tmpDiags hcl.Diagnostics
for _, d := range diags {
if !strings.HasPrefix(d.Summary, "not yet implemented") {
tmpDiags = append(tmpDiags, d)
}
}
diags = tmpDiags
}
if diags.HasErrors() {
buf := new(bytes.Buffer)
err := hcl.NewDiagnosticTextWriter(buf, hclFiles, 80, false).WriteDiagnostics(diags)
require.NoError(t, err, "Failed to write diag")
t.Fatalf("failed to generate program:\n%s", buf)
}
if pulumiAccept {
all: Reformat with gofumpt Per team discussion, switching to gofumpt. [gofumpt][1] is an alternative, stricter alternative to gofmt. It addresses other stylistic concerns that gofmt doesn't yet cover. [1]: https://github.com/mvdan/gofumpt See the full list of [Added rules][2], but it includes: - Dropping empty lines around function bodies - Dropping unnecessary variable grouping when there's only one variable - Ensuring an empty line between multi-line functions - simplification (`-s` in gofmt) is always enabled - Ensuring multi-line function signatures end with `) {` on a separate line. [2]: https://github.com/mvdan/gofumpt#Added-rules gofumpt is stricter, but there's no lock-in. All gofumpt output is valid gofmt output, so if we decide we don't like it, it's easy to switch back without any code changes. gofumpt support is built into the tooling we use for development so this won't change development workflows. - golangci-lint includes a gofumpt check (enabled in this PR) - gopls, the LSP for Go, includes a gofumpt option (see [installation instrutions][3]) [3]: https://github.com/mvdan/gofumpt#installation This change was generated by running: ```bash gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error) ``` The following files were manually tweaked afterwards: - pkg/cmd/pulumi/stack_change_secrets_provider.go: one of the lines overflowed and had comments in an inconvenient place - pkg/cmd/pulumi/destroy.go: `var x T = y` where `T` wasn't necessary - pkg/cmd/pulumi/policy_new.go: long line because of error message - pkg/backend/snapshot_test.go: long line trying to assign three variables in the same assignment I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 16:36:39 +00:00
err := os.WriteFile(expectedFile, files[testcase.OutputFile], 0o600)
require.NoError(t, err)
// generate the rest of the files
for fileName, content := range files {
if fileName != testcase.OutputFile {
outputPath := filepath.Join(testDir, fileName)
err := os.WriteFile(outputPath, content, 0o600)
require.NoError(t, err, "Failed to write file %s", outputPath)
}
}
} else {
assert.Equal(t, string(expected), string(files[testcase.OutputFile]))
// assert that the content is correct for the rest of the files
for fileName, content := range files {
if fileName != testcase.OutputFile {
outputPath := filepath.Join(testDir, fileName)
outputContent, err := os.ReadFile(outputPath)
require.NoError(t, err)
assert.Equal(t, string(outputContent), string(content))
}
}
}
if !skipCompile && testcase.Check != nil && !tt.SkipCompile.Has(testcase.Language) {
extraPulumiPackages := codegen.NewStringSet()
collectExtraPulumiPackages(program, extraPulumiPackages)
testcase.Check(t, expectedFile, extraPulumiPackages)
}
})
}
}
func collectExtraPulumiPackages(program *pcl.Program, extraPulumiPackages codegen.StringSet) {
for _, n := range program.Nodes {
if r, isResource := n.(*pcl.Resource); isResource {
pkg, _, _, _ := r.DecomposeToken()
if pkg != "pulumi" {
extraPulumiPackages.Add(pkg)
}
}
if component, isComponent := n.(*pcl.Component); isComponent {
collectExtraPulumiPackages(component.Program, extraPulumiPackages)
}
}
}
// CheckVersion checks for an expected package version
// Todo: support checking multiple package expected versions
func CheckVersion(t *testing.T, dir, depFilePath string, expectedVersionMap map[string]PkgVersionInfo) {
depFile, err := os.Open(depFilePath)
require.NoError(t, err)
2022-10-10 23:01:53 +00:00
defer depFile.Close()
// Splits on newlines by default.
scanner := bufio.NewScanner(depFile)
match := false
expectedPkg, expectedVersion := strings.TrimSpace(expectedVersionMap[dir].Pkg),
strings.TrimSpace(expectedVersionMap[dir].OpAndVersion)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, expectedPkg) {
line = strings.TrimSpace(line)
actualVersion := strings.TrimPrefix(line, expectedPkg)
actualVersion = strings.TrimSpace(actualVersion)
expectedVersion = strings.Trim(expectedVersion, "v:^/> ")
actualVersion = strings.Trim(actualVersion, "v:^/> ")
if expectedVersion == actualVersion {
match = true
break
}
actualSemver, err := semver.Make(actualVersion)
if err == nil {
continue
}
expectedSemver, _ := semver.Make(expectedVersion)
if actualSemver.Compare(expectedSemver) >= 0 {
match = true
break
}
}
}
2022-10-10 23:01:53 +00:00
require.Truef(t, match, "Did not find expected package version pair (%q,%q). Searched in:\n%s",
expectedPkg, expectedVersion, newLazyStringer(func() string {
// Reset the read on the file
_, err := depFile.Seek(0, io.SeekStart)
require.NoError(t, err)
buf := new(strings.Builder)
_, err = io.Copy(buf, depFile)
require.NoError(t, err)
return buf.String()
}).String())
}
func GenProjectCleanUp(t *testing.T, dir, depFilePath, outfilePath string) {
os.Remove(depFilePath)
os.Remove(outfilePath)
os.Remove(dir + "/.gitignore")
os.Remove(dir + "/Pulumi.yaml")
}
2022-10-10 23:01:53 +00:00
type lazyStringer struct {
cache string
f func() string
}
func (l lazyStringer) String() string {
if l.cache == "" {
l.cache = l.f()
}
return l.cache
}
// The `fmt` `%s` calls .String() if the object is not a string itself. We can delay
// computing expensive display logic until and unless we actually will use it.
func newLazyStringer(f func() string) fmt.Stringer {
return lazyStringer{f: f}
}