From b8b6bafc07b0804f6e802ba563ff3b7deaea6eee Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Thu, 14 Dec 2023 15:51:45 +0000 Subject: [PATCH] chore(cdk-testing): fix init-go canary (#28365) The init-go canary was broken because the test replaced the aws-cdk go module with a locally build version. However in canaries we want to use the publish versioned instead. This change simply makes the replacement conditional. Manually tested in CodeBuild. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../cli-integ/tests/init-go/init-go.integtest.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/init-go/init-go.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/init-go/init-go.integtest.ts index 779078ac68739..56d8b9486c6b2 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/init-go/init-go.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/init-go/init-go.integtest.ts @@ -2,13 +2,20 @@ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '.. ['app', 'sample-app'].forEach(template => { integTest(`init go ${template}`, withTemporaryDirectory(withPackages(async (context) => { + const isCanary = !!process.env.IS_CANARY; context.packages.assertJsiiPackagesAvailable(); const shell = ShellHelper.fromContext(context); await context.packages.makeCliAvailable(); await shell.shell(['cdk', 'init', '-l', 'go', template]); - await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk/v2=$CODEBUILD_SRC_DIR/go/awscdk']); + + // Canaries will use the generated go.mod as is + // For pipeline tests we replace the source with the locally build one + if (!isCanary) { + await shell.shell(['go', 'mod', 'edit', '-replace', 'github.com/aws/aws-cdk-go/awscdk/v2=$CODEBUILD_SRC_DIR/go/awscdk']); + } + await shell.shell(['go', 'mod', 'tidy']); await shell.shell(['go', 'test']); await shell.shell(['cdk', 'synth']);