From 18210bcbdfc53f782b238a34c78965143bb3f547 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 09:03:04 -0800 Subject: [PATCH 1/7] try this --- package-lock.json | 42 +++++++++---------- .../process-controller/process_controller.ts | 6 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index efc6c4dd82..443d92e31f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19442,18 +19442,18 @@ }, "packages/backend": { "name": "@aws-amplify/backend", - "version": "0.3.2", + "version": "0.3.3", "license": "Apache-2.0", "dependencies": { "@aws-amplify/amplify-api-next-alpha": "^0.8.0", "@aws-amplify/backend-auth": "^0.2.2", - "@aws-amplify/backend-data": "^0.3.2", - "@aws-amplify/backend-function": "^0.1.2", + "@aws-amplify/backend-data": "^0.4.0", + "@aws-amplify/backend-function": "^0.1.4", "@aws-amplify/backend-output-schemas": "^0.2.1", "@aws-amplify/backend-output-storage": "^0.2.0", "@aws-amplify/backend-secret": "^0.2.1", "@aws-amplify/backend-storage": "^0.2.1", - "@aws-amplify/platform-core": "^0.1.2", + "@aws-amplify/platform-core": "^0.1.4", "@aws-amplify/plugin-types": "^0.3.1", "@aws-sdk/client-amplify": "^3.440.0" }, @@ -19486,7 +19486,7 @@ }, "packages/backend-data": { "name": "@aws-amplify/backend-data", - "version": "0.3.2", + "version": "0.4.0", "license": "Apache-2.0", "dependencies": { "@aws-amplify/amplify-api-next-types-alpha": "^0.3.0", @@ -19498,7 +19498,7 @@ "devDependencies": { "@aws-amplify/amplify-api-next-alpha": "^0.8.0", "@aws-amplify/backend-platform-test-stubs": "^0.2.0", - "@aws-amplify/platform-core": "^0.1.3" + "@aws-amplify/platform-core": "^0.1.4" }, "peerDependencies": { "aws-cdk-lib": "^2.103.0", @@ -19507,10 +19507,10 @@ }, "packages/backend-deployer": { "name": "@aws-amplify/backend-deployer", - "version": "0.2.2", + "version": "0.2.3", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/platform-core": "^0.1.2", + "@aws-amplify/platform-core": "^0.1.4", "@aws-amplify/plugin-types": "^0.3.0", "execa": "^7.2.0", "tsx": "^3.12.6" @@ -19522,7 +19522,7 @@ }, "packages/backend-function": { "name": "@aws-amplify/backend-function", - "version": "0.1.3", + "version": "0.1.4", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-storage": "0.2.0", @@ -19532,7 +19532,7 @@ }, "devDependencies": { "@aws-amplify/backend-platform-test-stubs": "^0.2.0", - "@aws-amplify/platform-core": "^0.1.3" + "@aws-amplify/platform-core": "^0.1.4" }, "peerDependencies": { "aws-cdk-lib": "^2.103.0", @@ -19604,7 +19604,7 @@ }, "packages/cli": { "name": "@aws-amplify/backend-cli", - "version": "0.3.1", + "version": "0.4.0", "license": "Apache-2.0", "dependencies": { "@aws-amplify/backend-output-schemas": "^0.2.0", @@ -19614,8 +19614,8 @@ "@aws-amplify/deployed-backend-client": "^0.2.0", "@aws-amplify/form-generator": "^0.3.0", "@aws-amplify/model-generator": "^0.2.0", - "@aws-amplify/platform-core": "^0.1.1", - "@aws-amplify/sandbox": "^0.2.1", + "@aws-amplify/platform-core": "^0.1.4", + "@aws-amplify/sandbox": "^0.2.4", "@aws-sdk/credential-provider-ini": "^3.360.0", "@aws-sdk/credential-providers": "^3.360.0", "@smithy/shared-ini-file-loader": "^2.2.2", @@ -19776,7 +19776,7 @@ } }, "packages/create-amplify": { - "version": "0.2.2", + "version": "0.2.3", "license": "Apache-2.0", "dependencies": { "@aws-amplify/cli-core": "^0.2.0", @@ -19947,15 +19947,15 @@ }, "packages/integration-tests": { "name": "@aws-amplify/integration-tests", - "version": "0.2.2", + "version": "0.2.3", "license": "Apache-2.0", "devDependencies": { "@aws-amplify/amplify-api-next-alpha": "^0.8.0", - "@aws-amplify/backend": "0.3.2", + "@aws-amplify/backend": "0.3.3", "@aws-amplify/backend-auth": "0.2.3", "@aws-amplify/backend-secret": "^0.2.1", "@aws-amplify/backend-storage": "0.2.2", - "@aws-amplify/platform-core": "^0.1.3", + "@aws-amplify/platform-core": "^0.1.4", "@aws-sdk/client-amplify": "^3.440.0", "@aws-sdk/client-cloudformation": "^3.421.0", "execa": "^8.0.1", @@ -20041,7 +20041,7 @@ }, "packages/platform-core": { "name": "@aws-amplify/platform-core", - "version": "0.1.3", + "version": "0.1.4", "license": "Apache-2.0", "dependencies": { "@aws-amplify/plugin-types": "^0.3.0" @@ -20058,15 +20058,15 @@ }, "packages/sandbox": { "name": "@aws-amplify/sandbox", - "version": "0.2.3", + "version": "0.2.4", "license": "Apache-2.0", "dependencies": { - "@aws-amplify/backend-deployer": "0.2.2", + "@aws-amplify/backend-deployer": "0.2.3", "@aws-amplify/backend-secret": "^0.2.1", "@aws-amplify/cli-core": "^0.2.0", "@aws-amplify/client-config": "0.2.3", "@aws-amplify/deployed-backend-client": "^0.2.1", - "@aws-amplify/platform-core": "^0.1.3", + "@aws-amplify/platform-core": "^0.1.4", "@aws-sdk/client-cloudformation": "^3.421.0", "@aws-sdk/credential-providers": "^3.382.0", "@aws-sdk/types": "^3.378.0", diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index f5c71d2603..6118d32481 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -1,4 +1,4 @@ -import { Options, execa } from 'execa'; +import { Options, execa, execaSync } from 'execa'; import readline from 'readline'; import { PredicatedActionBuilder } from './predicated_action_queue_builder.js'; import { ActionType } from './predicated_action.js'; @@ -123,8 +123,8 @@ export const amplifyCli = ( ): ProcessController => { let command: string; if (options?.installationType === 'local') { - command = 'npx'; - args = ['amplify'].concat(args); + command = execaSync('npx', ['which', 'amplify']).stdout; + console.log(`Using ${command} from npx which amplify`); } else { command = 'amplify'; } From 47f0fe97108e6e235cb7289191eb758229b7ef29 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 09:13:40 -0800 Subject: [PATCH 2/7] try this --- .../src/process-controller/process_controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index 6118d32481..23a0bcde1b 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -123,7 +123,9 @@ export const amplifyCli = ( ): ProcessController => { let command: string; if (options?.installationType === 'local') { - command = execaSync('npx', ['which', 'amplify']).stdout; + command = execaSync('npx', ['which', 'amplify'], { + stdio: 'inherit', + }).stdout; console.log(`Using ${command} from npx which amplify`); } else { command = 'amplify'; From 6a5690e14838d1c2191454d52d254a6d438ab031 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 09:19:40 -0800 Subject: [PATCH 3/7] try this --- .../src/process-controller/process_controller.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index 23a0bcde1b..c45c13f7d0 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -124,6 +124,7 @@ export const amplifyCli = ( let command: string; if (options?.installationType === 'local') { command = execaSync('npx', ['which', 'amplify'], { + cwd: dir, stdio: 'inherit', }).stdout; console.log(`Using ${command} from npx which amplify`); From 343be9b1d9ede4a35d3085771e4bfdcd55c5500a Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 09:49:51 -0800 Subject: [PATCH 4/7] try this --- .../src/process-controller/process_controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index c45c13f7d0..8da6b2fcf8 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -125,8 +125,10 @@ export const amplifyCli = ( if (options?.installationType === 'local') { command = execaSync('npx', ['which', 'amplify'], { cwd: dir, - stdio: 'inherit', }).stdout; + if (!command) { + throw new Error('Unable to locate amplify binary'); + } console.log(`Using ${command} from npx which amplify`); } else { command = 'amplify'; From 2261552a19c3a7d71970a56191338f3517259aa8 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 10:40:54 -0800 Subject: [PATCH 5/7] try this --- .changeset/wet-tips-swim.md | 2 + .../process-controller/process_controller.ts | 5 +- .../health_checks.test.ts | 126 ++++++++++++------ 3 files changed, 91 insertions(+), 42 deletions(-) create mode 100644 .changeset/wet-tips-swim.md diff --git a/.changeset/wet-tips-swim.md b/.changeset/wet-tips-swim.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/wet-tips-swim.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index 8da6b2fcf8..5fc283373b 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -123,13 +123,16 @@ export const amplifyCli = ( ): ProcessController => { let command: string; if (options?.installationType === 'local') { + // TODO This is a workaround to lookup locally installed binary as seen by npx + // We're using binary directly because signals (Ctrl+C) don't propagate + // to child processes without TTY emulator. + // See: https://github.com/aws-amplify/amplify-backend/issues/582 command = execaSync('npx', ['which', 'amplify'], { cwd: dir, }).stdout; if (!command) { throw new Error('Unable to locate amplify binary'); } - console.log(`Using ${command} from npx which amplify`); } else { command = 'amplify'; } diff --git a/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts b/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts index 480d621a30..f136444b6d 100644 --- a/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts +++ b/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts @@ -11,6 +11,12 @@ import { CloudFormationClient, DeleteStackCommand, } from '@aws-sdk/client-cloudformation'; +import { + confirmDeleteSandbox, + interruptSandbox, + rejectCleanupSandbox, + waitForSandboxDeploymentToPrintTotalTime, +} from '../process-controller/predicated_action_macros.js'; const cfnClient = new CloudFormationClient(); @@ -21,10 +27,7 @@ const cfnClient = new CloudFormationClient(); * * These tests intentionally do not use local npm registry (verdaccio). */ -void describe('Live dependency health checks', () => { - let tempDir: string; - let testBranch: TestBranch; - +void describe('Live dependency health checks', { concurrency: true }, () => { before(async () => { // nuke the npx cache to ensure we are installing latest versions of packages from the npm const { stdout } = await execa('npm', ['config', 'get', 'cache']); @@ -35,50 +38,91 @@ void describe('Live dependency health checks', () => { } }); - beforeEach(async () => { - tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'test-amplify')); - testBranch = await amplifyAppPool.createTestBranch(); - }); + void describe('pipeline deployment', () => { + let tempDir: string; + let testBranch: TestBranch; + beforeEach(async () => { + tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'test-amplify')); + testBranch = await amplifyAppPool.createTestBranch(); + }); + + afterEach(async () => { + await fs.rm(tempDir, { recursive: true }); + const stackName = `amplify-${testBranch.appId}-${testBranch.branchName}`; + try { + await cfnClient.send( + new DeleteStackCommand({ + StackName: stackName, + }) + ); + } catch (e) { + console.log(`Failed to delete ${stackName}`); + console.log(e); + } + }); + + void it('end to end flow', async () => { + await execa('npm', ['create', 'amplify', '--yes'], { + cwd: tempDir, + stdio: 'inherit', + }); - afterEach(async () => { - await fs.rm(tempDir, { recursive: true }); - const stackName = `amplify-${testBranch.appId}-${testBranch.branchName}`; - try { - await cfnClient.send( - new DeleteStackCommand({ - StackName: stackName, - }) + await amplifyCli( + [ + 'pipeline-deploy', + '--branch', + testBranch.branchName, + '--appId', + testBranch.appId, + ], + tempDir, + { + installationType: 'local', + env: { CI: 'true' }, + } + ).run(); + + const clientConfigStats = await fs.stat( + path.join(tempDir, 'amplifyconfiguration.json') ); - } catch (e) { - console.log(`Failed to delete ${stackName}`); - console.log(e); - } + assert.ok(clientConfigStats.isFile()); + }); }); - void it('end to end flow with pipeline deployment', async () => { - await execa('npm', ['create', 'amplify', '--yes'], { - cwd: tempDir, - stdio: 'inherit', + void describe('sandbox deployment', () => { + let tempDir: string; + beforeEach(async () => { + tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'test-amplify')); + }); + + afterEach(async () => { + await fs.rm(tempDir, { recursive: true }); }); - await amplifyCli( - [ - 'pipeline-deploy', - '--branch', - testBranch.branchName, - '--appId', - testBranch.appId, - ], - tempDir, - { + void it('end to end flow', async () => { + await execa('npm', ['create', 'amplify', '--yes'], { + cwd: tempDir, + stdio: 'inherit', + }); + + await amplifyCli(['sandbox'], tempDir, { installationType: 'local', - env: { CI: 'true' }, - } - ).run(); + }) + .do(waitForSandboxDeploymentToPrintTotalTime()) + .do(interruptSandbox()) + .do(rejectCleanupSandbox()) + .run(); - const clientConfigStats = await fs.stat( - path.join(tempDir, 'amplifyconfiguration.json') - ); - assert.ok(clientConfigStats.isFile()); + const clientConfigStats = await fs.stat( + path.join(tempDir, 'amplifyconfiguration.json') + ); + assert.ok(clientConfigStats.isFile()); + + await amplifyCli(['sandbox', 'delete'], tempDir, { + installationType: 'local', + }) + .do(confirmDeleteSandbox()) + .run(); + }); }); }); From 697be3feebe18412084c962c6ec523b711614ef0 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 13:59:04 -0800 Subject: [PATCH 6/7] trim --- .../src/process-controller/process_controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index 5fc283373b..c11a812d7b 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -129,7 +129,7 @@ export const amplifyCli = ( // See: https://github.com/aws-amplify/amplify-backend/issues/582 command = execaSync('npx', ['which', 'amplify'], { cwd: dir, - }).stdout; + }).stdout.trim(); if (!command) { throw new Error('Unable to locate amplify binary'); } From a2f983a79f31cd052b4878de7e43a065c63f7133 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 9 Nov 2023 14:01:11 -0800 Subject: [PATCH 7/7] does this work perhaps? --- .../process-controller/process_controller.ts | 24 +++++++------------ .../health_checks.test.ts | 9 ++----- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index c11a812d7b..9248e77511 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -117,24 +117,18 @@ export const amplifyCli = ( args: string[] = [], dir: string, options?: { - installationType?: 'global' | 'local'; env?: Record; } ): ProcessController => { - let command: string; - if (options?.installationType === 'local') { - // TODO This is a workaround to lookup locally installed binary as seen by npx - // We're using binary directly because signals (Ctrl+C) don't propagate - // to child processes without TTY emulator. - // See: https://github.com/aws-amplify/amplify-backend/issues/582 - command = execaSync('npx', ['which', 'amplify'], { - cwd: dir, - }).stdout.trim(); - if (!command) { - throw new Error('Unable to locate amplify binary'); - } - } else { - command = 'amplify'; + // TODO This is a workaround to lookup locally installed binary as seen by npx + // We're using binary directly because signals (Ctrl+C) don't propagate + // to child processes without TTY emulator. + // See: https://github.com/aws-amplify/amplify-backend/issues/582 + const command = execaSync('npx', ['which', 'amplify'], { + cwd: dir, + }).stdout.trim(); + if (!command) { + throw new Error('Unable to locate amplify binary'); } return new ProcessController(command, args, { cwd: dir, diff --git a/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts b/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts index f136444b6d..b734b398b7 100644 --- a/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts +++ b/packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts @@ -77,7 +77,6 @@ void describe('Live dependency health checks', { concurrency: true }, () => { ], tempDir, { - installationType: 'local', env: { CI: 'true' }, } ).run(); @@ -105,9 +104,7 @@ void describe('Live dependency health checks', { concurrency: true }, () => { stdio: 'inherit', }); - await amplifyCli(['sandbox'], tempDir, { - installationType: 'local', - }) + await amplifyCli(['sandbox'], tempDir) .do(waitForSandboxDeploymentToPrintTotalTime()) .do(interruptSandbox()) .do(rejectCleanupSandbox()) @@ -118,9 +115,7 @@ void describe('Live dependency health checks', { concurrency: true }, () => { ); assert.ok(clientConfigStats.isFile()); - await amplifyCli(['sandbox', 'delete'], tempDir, { - installationType: 'local', - }) + await amplifyCli(['sandbox', 'delete'], tempDir) .do(confirmDeleteSandbox()) .run(); });