Skip to content

Commit 76ed161

Browse files
author
Dane Pilcher
authored
Merge pull request #836 from aws-amplify/main
Release
2 parents 68ee64d + cfd4c2b commit 76ed161

27 files changed

+5224
-611
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,27 @@ batch:
7878
debug-session: true
7979
depend-on:
8080
- publish_to_local_registry
81+
- identifier: l_graphql_generator_gen2
82+
buildspec: .codebuild/run_gen2_e2e_test.yml
83+
env:
84+
compute-type: BUILD_GENERAL1_LARGE
85+
variables:
86+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
87+
CLI_REGION: us-west-2
88+
depend-on:
89+
- publish_to_local_registry
90+
- identifier: w_graphql_generator_gen2
91+
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
92+
env:
93+
compute-type: BUILD_GENERAL1_LARGE
94+
image: $WINDOWS_IMAGE_2019
95+
type: WINDOWS_SERVER_2019_CONTAINER
96+
variables:
97+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
98+
CLI_REGION: us-east-1
99+
depend-on:
100+
- publish_to_local_registry
101+
- build_windows
81102
- identifier: >-
82103
l_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
83104
buildspec: .codebuild/run_e2e_tests.yml

.codebuild/e2e_workflow_base.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,24 @@ batch:
7878
debug-session: true
7979
depend-on:
8080
- publish_to_local_registry
81+
- identifier: l_graphql_generator_gen2
82+
buildspec: .codebuild/run_gen2_e2e_test.yml
83+
env:
84+
compute-type: BUILD_GENERAL1_LARGE
85+
variables:
86+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
87+
CLI_REGION: us-west-2
88+
depend-on:
89+
- publish_to_local_registry
90+
- identifier: w_graphql_generator_gen2
91+
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
92+
env:
93+
compute-type: BUILD_GENERAL1_LARGE
94+
image: $WINDOWS_IMAGE_2019
95+
type: WINDOWS_SERVER_2019_CONTAINER
96+
variables:
97+
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
98+
CLI_REGION: us-east-1
99+
depend-on:
100+
- publish_to_local_registry
101+
- build_windows

.codebuild/run_gen2_e2e_test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 0.2
2+
env:
3+
shell: bash
4+
variables:
5+
CI: true
6+
CODEBUILD: true
7+
NODE_OPTIONS: --max-old-space-size=8096
8+
9+
phases:
10+
build:
11+
commands:
12+
- source ./shared-scripts.sh && _setupGen2E2ETestsLinux
13+
- source ./shared-scripts.sh && _runGen2E2ETestsLinux
14+
post_build:
15+
commands:
16+
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
17+
- aws sts get-caller-identity
18+
- source ./shared-scripts.sh && _scanArtifacts
19+
20+
artifacts:
21+
files:
22+
- '**/*'
23+
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 0.2
2+
env:
3+
shell: powershell.exe
4+
variables:
5+
CI: true
6+
CODEBUILD: true
7+
NODE_OPTIONS: --max-old-space-size=8096
8+
phases:
9+
build:
10+
commands:
11+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
12+
- bash ./.codebuild/scripts/gen2_e2e_test_windows.sh
13+
post_build:
14+
commands:
15+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
16+
- bash ./.codebuild/scripts/post_e2e_test.sh
17+
18+
artifacts:
19+
files:
20+
- '**/*'
21+
base-directory: $Env:CODEBUILD_SRC_DIR\packages\amplify-codegen-e2e-tests\amplify-e2e-reports
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# set exit on error to true
4+
set -e
5+
6+
source ./shared-scripts.sh && _setupGen2E2ETestsWindows
7+
codebuild-breakpoint
8+
source ./shared-scripts.sh && _runGen2E2ETestsWindows

dependency_licenses.txt

Lines changed: 782 additions & 292 deletions
Large diffs are not rendered by default.

packages/amplify-codegen-e2e-core/src/asciinema-recorder.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type RecordingHeader = {
99
title: string;
1010
env: any;
1111
};
12+
1213
export type RecordingFrame = [number, 'o' | 'i', string];
1314
export type Recording = {
1415
header: RecordingHeader;
@@ -17,13 +18,21 @@ export type Recording = {
1718

1819
export class Recorder {
1920
private isPaused: boolean = false;
21+
2022
private childProcess: pty.IPty;
23+
2124
private onDataHandlers: ((data: string) => void)[] = [];
25+
2226
private onExitHandlers: ((exitCode: number, signal: string | number) => void)[] = [];
27+
2328
private startTime: number;
29+
2430
private recording: Recording;
31+
2532
private cwd: string;
33+
2634
private exitCode: number | undefined;
35+
2736
constructor(
2837
private cmd: string,
2938
private args: string[],
@@ -41,7 +50,7 @@ export class Recorder {
4150
height: rows,
4251
timestamp: null,
4352
title: 'Recording',
44-
env: options,
53+
env: {},
4554
},
4655
frames: [],
4756
};
@@ -57,6 +66,9 @@ export class Recorder {
5766
cols: this.cols,
5867
rows: this.rows,
5968
cwd: this.cwd,
69+
shell: true,
70+
// Do not set useConpty. node-pty is smart enough to set it to true only on versions of Windows that support it.
71+
// useConpty: true,
6072
...this.options,
6173
});
6274
this.addFrame(this.renderPrompt(this.cwd, this.cmd, this.args));
@@ -79,6 +91,7 @@ export class Recorder {
7991
addOnExitHandlers(fn: (code: number, signal: string | number) => void) {
8092
this.onExitHandlers.push(fn);
8193
}
94+
8295
removeOnExitHandlers(fn: (code: number, signal: string | number) => void): boolean {
8396
const idx = this.onExitHandlers.indexOf(fn);
8497
if (idx === -1) {
@@ -89,7 +102,11 @@ export class Recorder {
89102
}
90103

91104
getRecording(): string {
92-
return [JSON.stringify(this.recording.header), ...this.recording.frames.map(frame => JSON.stringify(frame))].join('\n');
105+
return [JSON.stringify(this.recording.header), ...this.recording.frames.map((frame) => JSON.stringify(frame))].join('\n');
106+
}
107+
108+
getRecordingFrames(): Readonly<RecordingFrame[]> {
109+
return [...this.recording.frames];
93110
}
94111

95112
pauseRecording(): void {

packages/amplify-codegen-e2e-core/src/configure/index.ts

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,32 @@ const MANDATORY_PARAMS = ['accessKeyId', 'secretAccessKey', 'region'];
5656

5757
export function amplifyConfigure(settings: AmplifyConfiguration): Promise<void> {
5858
const s = { ...defaultSettings, ...settings };
59-
const missingParam = MANDATORY_PARAMS.filter(p => !Object.keys(s).includes(p));
59+
const missingParam = MANDATORY_PARAMS.filter((p) => !Object.keys(s).includes(p));
6060
if (missingParam.length) {
6161
throw new Error(`mandatory params ${missingParam.join(' ')} are missing`);
6262
}
6363

64-
return new Promise((resolve, reject) => {
65-
const chain = spawn(getCLIPath(), ['configure'], { stripColors: true })
66-
.wait('Sign in to your AWS administrator account:')
67-
.wait('Press Enter to continue')
68-
.sendCarriageReturn()
69-
.wait('Specify the AWS Region');
70-
71-
singleSelect(chain, s.region, amplifyRegions);
72-
73-
chain
74-
.wait('Press Enter to continue')
75-
.sendCarriageReturn()
76-
.wait('accessKeyId')
77-
.pauseRecording()
78-
.sendLine(s.accessKeyId)
79-
.wait('secretAccessKey')
80-
.sendLine(s.secretAccessKey)
81-
.resumeRecording()
82-
.wait('Profile Name:')
83-
.sendLine(s.profileName)
84-
.wait('Successfully set up the new user.')
85-
.run((err: Error) => {
86-
if (!err) {
87-
resolve();
88-
} else {
89-
reject(err);
90-
}
91-
});
92-
});
64+
const chain = spawn(getCLIPath(), ['configure'], { stripColors: true })
65+
.wait('Sign in to your AWS administrator account:')
66+
.wait('Press Enter to continue')
67+
.sendCarriageReturn()
68+
.wait('Specify the AWS Region');
69+
70+
singleSelect(chain, s.region, amplifyRegions);
71+
72+
return chain
73+
.wait('Press Enter to continue')
74+
.sendCarriageReturn()
75+
.wait('accessKeyId')
76+
.pauseRecording()
77+
.sendLine(s.accessKeyId)
78+
.wait('secretAccessKey')
79+
.sendLine(s.secretAccessKey)
80+
.resumeRecording()
81+
.wait('Profile Name:')
82+
.sendLine(s.profileName)
83+
.wait('Successfully set up the new user.')
84+
.runAsync();
9385
}
9486

9587
export function amplifyConfigureProject(settings: {

packages/amplify-codegen-e2e-core/src/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { spawnSync, execSync } from 'child_process';
55
import { v4 as uuid } from 'uuid';
66
import * as ini from 'ini';
77
import { pathManager } from '@aws-amplify/amplify-cli-core';
8-
import { getCommandPath } from './utils';
8+
import { getCommandPath, sleep } from './utils';
99

1010
export * from './configure/';
1111
export * from './init/';
@@ -33,6 +33,15 @@ export function getCLIPath(testingWithLatestCodebase = false) {
3333
return getCommandPath(commandName);
3434
}
3535

36+
export function getScriptRunnerPath(testingWithLatestCodebase = false) {
37+
if (!testingWithLatestCodebase) {
38+
return process.platform === 'win32' ? 'node.exe' : 'exec';
39+
}
40+
41+
// nodejs executable
42+
return process.execPath;
43+
}
44+
3645
export function isCI(): boolean {
3746
return process.env.CI && process.env.CODEBUILD ? true : false;
3847
}
@@ -70,6 +79,15 @@ export async function createNewProjectDir(
7079
} while (fs.existsSync(projectDir));
7180

7281
fs.ensureDirSync(projectDir);
82+
if (!process.env.SKIP_CREATE_PROJECT_DIR_INITIAL_DELAY) {
83+
// createProjectDir(..) is something that nearly every test uses
84+
// Commands like 'init' would collide with each other if they occurred too close to one another.
85+
// Especially for nexpect output waiting
86+
// This makes it a perfect candidate for staggering test start times
87+
const initialDelay = Math.floor(Math.random() * 180 * 1000); // between 0 to 3 min
88+
console.log(`Waiting for ${initialDelay} ms`);
89+
await sleep(initialDelay);
90+
}
7391
console.log(projectDir);
7492
return projectDir;
7593
}

0 commit comments

Comments
 (0)