Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #836

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .codebuild/e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ batch:
debug-session: true
depend-on:
- publish_to_local_registry
- identifier: l_graphql_generator_gen2
buildspec: .codebuild/run_gen2_e2e_test.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
CLI_REGION: us-west-2
depend-on:
- publish_to_local_registry
- identifier: w_graphql_generator_gen2
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: $WINDOWS_IMAGE_2019
type: WINDOWS_SERVER_2019_CONTAINER
variables:
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
CLI_REGION: us-east-1
depend-on:
- publish_to_local_registry
- build_windows
- identifier: >-
l_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
buildspec: .codebuild/run_e2e_tests.yml
Expand Down
21 changes: 21 additions & 0 deletions .codebuild/e2e_workflow_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,24 @@ batch:
debug-session: true
depend-on:
- publish_to_local_registry
- identifier: l_graphql_generator_gen2
buildspec: .codebuild/run_gen2_e2e_test.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
CLI_REGION: us-west-2
depend-on:
- publish_to_local_registry
- identifier: w_graphql_generator_gen2
buildspec: .codebuild/run_gen2_e2e_test_windows.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: $WINDOWS_IMAGE_2019
type: WINDOWS_SERVER_2019_CONTAINER
variables:
TEST_SUITE: src/__tests__/graphql-generator-gen2.test.ts
CLI_REGION: us-east-1
depend-on:
- publish_to_local_registry
- build_windows
23 changes: 23 additions & 0 deletions .codebuild/run_gen2_e2e_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 0.2
env:
shell: bash
variables:
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096

phases:
build:
commands:
- source ./shared-scripts.sh && _setupGen2E2ETestsLinux
- source ./shared-scripts.sh && _runGen2E2ETestsLinux
post_build:
commands:
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts

artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
21 changes: 21 additions & 0 deletions .codebuild/run_gen2_e2e_test_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 0.2
env:
shell: powershell.exe
variables:
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096
phases:
build:
commands:
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
- bash ./.codebuild/scripts/gen2_e2e_test_windows.sh
post_build:
commands:
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
- bash ./.codebuild/scripts/post_e2e_test.sh

artifacts:
files:
- '**/*'
base-directory: $Env:CODEBUILD_SRC_DIR\packages\amplify-codegen-e2e-tests\amplify-e2e-reports
8 changes: 8 additions & 0 deletions .codebuild/scripts/gen2_e2e_test_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# set exit on error to true
set -e

source ./shared-scripts.sh && _setupGen2E2ETestsWindows
codebuild-breakpoint
source ./shared-scripts.sh && _runGen2E2ETestsWindows
1,074 changes: 782 additions & 292 deletions dependency_licenses.txt

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions packages/amplify-codegen-e2e-core/src/asciinema-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type RecordingHeader = {
title: string;
env: any;
};

export type RecordingFrame = [number, 'o' | 'i', string];
export type Recording = {
header: RecordingHeader;
Expand All @@ -17,13 +18,21 @@ export type Recording = {

export class Recorder {
private isPaused: boolean = false;

private childProcess: pty.IPty;

private onDataHandlers: ((data: string) => void)[] = [];

private onExitHandlers: ((exitCode: number, signal: string | number) => void)[] = [];

private startTime: number;

private recording: Recording;

private cwd: string;

private exitCode: number | undefined;

constructor(
private cmd: string,
private args: string[],
Expand All @@ -41,7 +50,7 @@ export class Recorder {
height: rows,
timestamp: null,
title: 'Recording',
env: options,
env: {},
},
frames: [],
};
Expand All @@ -57,6 +66,9 @@ export class Recorder {
cols: this.cols,
rows: this.rows,
cwd: this.cwd,
shell: true,
// Do not set useConpty. node-pty is smart enough to set it to true only on versions of Windows that support it.
// useConpty: true,
...this.options,
});
this.addFrame(this.renderPrompt(this.cwd, this.cmd, this.args));
Expand All @@ -79,6 +91,7 @@ export class Recorder {
addOnExitHandlers(fn: (code: number, signal: string | number) => void) {
this.onExitHandlers.push(fn);
}

removeOnExitHandlers(fn: (code: number, signal: string | number) => void): boolean {
const idx = this.onExitHandlers.indexOf(fn);
if (idx === -1) {
Expand All @@ -89,7 +102,11 @@ export class Recorder {
}

getRecording(): string {
return [JSON.stringify(this.recording.header), ...this.recording.frames.map(frame => JSON.stringify(frame))].join('\n');
return [JSON.stringify(this.recording.header), ...this.recording.frames.map((frame) => JSON.stringify(frame))].join('\n');
}

getRecordingFrames(): Readonly<RecordingFrame[]> {
return [...this.recording.frames];
}

pauseRecording(): void {
Expand Down
52 changes: 22 additions & 30 deletions packages/amplify-codegen-e2e-core/src/configure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,32 @@ const MANDATORY_PARAMS = ['accessKeyId', 'secretAccessKey', 'region'];

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

return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), ['configure'], { stripColors: true })
.wait('Sign in to your AWS administrator account:')
.wait('Press Enter to continue')
.sendCarriageReturn()
.wait('Specify the AWS Region');

singleSelect(chain, s.region, amplifyRegions);

chain
.wait('Press Enter to continue')
.sendCarriageReturn()
.wait('accessKeyId')
.pauseRecording()
.sendLine(s.accessKeyId)
.wait('secretAccessKey')
.sendLine(s.secretAccessKey)
.resumeRecording()
.wait('Profile Name:')
.sendLine(s.profileName)
.wait('Successfully set up the new user.')
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
const chain = spawn(getCLIPath(), ['configure'], { stripColors: true })
.wait('Sign in to your AWS administrator account:')
.wait('Press Enter to continue')
.sendCarriageReturn()
.wait('Specify the AWS Region');

singleSelect(chain, s.region, amplifyRegions);

return chain
.wait('Press Enter to continue')
.sendCarriageReturn()
.wait('accessKeyId')
.pauseRecording()
.sendLine(s.accessKeyId)
.wait('secretAccessKey')
.sendLine(s.secretAccessKey)
.resumeRecording()
.wait('Profile Name:')
.sendLine(s.profileName)
.wait('Successfully set up the new user.')
.runAsync();
}

export function amplifyConfigureProject(settings: {
Expand Down
20 changes: 19 additions & 1 deletion packages/amplify-codegen-e2e-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { spawnSync, execSync } from 'child_process';
import { v4 as uuid } from 'uuid';
import * as ini from 'ini';
import { pathManager } from '@aws-amplify/amplify-cli-core';
import { getCommandPath } from './utils';
import { getCommandPath, sleep } from './utils';

export * from './configure/';
export * from './init/';
Expand Down Expand Up @@ -33,6 +33,15 @@ export function getCLIPath(testingWithLatestCodebase = false) {
return getCommandPath(commandName);
}

export function getScriptRunnerPath(testingWithLatestCodebase = false) {
if (!testingWithLatestCodebase) {
return process.platform === 'win32' ? 'node.exe' : 'exec';
}

// nodejs executable
return process.execPath;
}

export function isCI(): boolean {
return process.env.CI && process.env.CODEBUILD ? true : false;
}
Expand Down Expand Up @@ -70,6 +79,15 @@ export async function createNewProjectDir(
} while (fs.existsSync(projectDir));

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