From 02f46811db59dbe761b5901e58ec2b28964b53cf Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Fri, 29 Mar 2019 12:27:42 -0700 Subject: [PATCH] Add a SxS test for `@pulumi/pulumi` to help catch when we make breaking changes to core types. (#2610) --- .gitignore | 1 + sdk/nodejs/.gitignore | 2 +- sdk/nodejs/Makefile | 7 ++-- sdk/nodejs/tests/sxs/README.md | 13 +++++++ sdk/nodejs/tests/sxs/index.ts | 57 ++++++++++++++++++++++++++++++ sdk/nodejs/tests/sxs/package.json | 12 +++++++ sdk/nodejs/tests/sxs/tsconfig.json | 22 ++++++++++++ 7 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 sdk/nodejs/tests/sxs/README.md create mode 100644 sdk/nodejs/tests/sxs/index.ts create mode 100644 sdk/nodejs/tests/sxs/package.json create mode 100644 sdk/nodejs/tests/sxs/tsconfig.json diff --git a/.gitignore b/.gitignore index e03fdc74c..df08cc0a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.swp /vendor/ **/node_modules/ +**/bin **/.vscode/ coverage.cov *.coverprofile diff --git a/sdk/nodejs/.gitignore b/sdk/nodejs/.gitignore index c4efa6981..c6bf92ac5 100644 --- a/sdk/nodejs/.gitignore +++ b/sdk/nodejs/.gitignore @@ -1,4 +1,4 @@ -/bin/ +**/bin /coverage/ /prebuilt/ /node_modules/ diff --git a/sdk/nodejs/Makefile b/sdk/nodejs/Makefile index e283a5caf..32affa728 100644 --- a/sdk/nodejs/Makefile +++ b/sdk/nodejs/Makefile @@ -47,10 +47,13 @@ instanbul_tests:: istanbul report text-summary istanbul report text -test_fast:: instanbul_tests +sxs_tests:: + pushd tests/sxs && yarn && tsc && popd + +test_fast:: sxs_tests instanbul_tests $(GO_TEST_FAST) ${PROJECT_PKGS} -test_all:: instanbul_tests +test_all:: sxs_tests instanbul_tests $(GO_TEST) ${PROJECT_PKGS} dist:: diff --git a/sdk/nodejs/tests/sxs/README.md b/sdk/nodejs/tests/sxs/README.md new file mode 100644 index 000000000..729a5eeff --- /dev/null +++ b/sdk/nodejs/tests/sxs/README.md @@ -0,0 +1,13 @@ +This test validates that changes we're making in @pulumi/pulumi will be side-by-side compatible with the 'latest' version of `@pulumi/pulumi` that has already shipped. + +If a change is made that is not compatible, then the process should be: + +1. Ensure that the change is absolutely what we want to make. +2. Disable running this test. +3. Commit the change and update the minor version of `@pulumi/pulumi` (i.e. from 0.17.x to 0.18.0). +4. Flow this change downstream, rev'ing the minor version of all downstream packages. +5. Re-enable the test. Because there is now a new 'latest' `@pulumi/pulumi`, this test should pass. + +Step '3' indicates that we've made a breaking change, and that if 0.18 is pulled in from any package, that it must be pulled in from all packages. + +Step '4' is necessary so that people can pick a set of packages that all agree on using this new `@pulumi/pulumi` version. While not necessary to rev the minor version of these packages, we still do so to make it clear that there is a significant change here, and that one should not move to it as readily as they would a patch update. diff --git a/sdk/nodejs/tests/sxs/index.ts b/sdk/nodejs/tests/sxs/index.ts new file mode 100644 index 000000000..b4e1d38ae --- /dev/null +++ b/sdk/nodejs/tests/sxs/index.ts @@ -0,0 +1,57 @@ +// tslint:disable:file-header + +// See README.md for information on what to do if this test fails. + +import * as latestShipped from "@pulumi/pulumi"; + +// Note: we reference 'bin' as we want to see the typescript types with all internal information +// stripped. +import * as localUnshipped from "../../bin"; + +declare let latestShippedResource: latestShipped.Resource; +declare let localUnshippedResource: localUnshipped.Resource; + +declare let latestShippedComponentResourceOptions: latestShipped.ComponentResourceOptions; +declare let localUnshippedComponentResourceOptions: localUnshipped.ComponentResourceOptions; + +declare let latestShippedCustomResourceOptions: latestShipped.CustomResourceOptions; +declare let localUnshippedCustomResourceOptions: localUnshipped.CustomResourceOptions; + +latestShippedResource = localUnshippedResource; +localUnshippedResource = latestShippedResource; + +latestShippedComponentResourceOptions = localUnshippedComponentResourceOptions; +localUnshippedComponentResourceOptions = latestShippedComponentResourceOptions; + +latestShippedCustomResourceOptions = localUnshippedCustomResourceOptions; +localUnshippedCustomResourceOptions = latestShippedCustomResourceOptions; + +// simulate a resource similar to AWSX where there are instance methods that take +// other resources and options. + +class LatestShippedResourceExample1 extends latestShipped.ComponentResource { + constructor(name: string, props: any, opts: latestShipped.ComponentResourceOptions) { + super("", name, undefined, opts); + } + + public createInstance(name: string, opts: latestShipped.ComponentResourceOptions): LatestShippedResourceExample1 { + throw new Error(); + } +} + +class LocalUnshippedResourceExample1 extends localUnshipped.ComponentResource { + constructor(name: string, props: any, opts: localUnshipped.ComponentResourceOptions) { + super("", name, undefined, opts); + } + + public createInstance(name: string, opts: localUnshipped.ComponentResourceOptions): LocalUnshippedResourceExample1 { + throw new Error(); + } +} + +// make sure we can at least assign these to the Resource types from different versions. +declare let latestShippedDerivedComponentResource: LatestShippedResourceExample1; +declare let localUnshippedDerivedComponentResource: LocalUnshippedResourceExample1; + +latestShippedResource = localUnshippedDerivedComponentResource; +localUnshippedResource = latestShippedDerivedComponentResource; diff --git a/sdk/nodejs/tests/sxs/package.json b/sdk/nodejs/tests/sxs/package.json new file mode 100644 index 000000000..777fdc35f --- /dev/null +++ b/sdk/nodejs/tests/sxs/package.json @@ -0,0 +1,12 @@ +{ + "name": "sxs", + "version": "${VERSION}", + "license": "Apache-2.0", + "dependencies": { + "@pulumi/pulumi": "latest" + }, + "devDependencies": { + "@types/node": "^10.0.0", + "typescript": "^3.0.0" + } +} diff --git a/sdk/nodejs/tests/sxs/tsconfig.json b/sdk/nodejs/tests/sxs/tsconfig.json new file mode 100644 index 000000000..151c0c54a --- /dev/null +++ b/sdk/nodejs/tests/sxs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "outDir": "bin", + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "sourceMap": false, + "stripInternal": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true, + "strictNullChecks": true, + }, + "files": [ + "index.ts", + ] +} +