Skip to content

Commit 8ec490d

Browse files
author
Dane Pilcher
authored
ci: e2e tests on windows (#750)
1 parent f84e1c6 commit 8ec490d

File tree

17 files changed

+311
-84
lines changed

17 files changed

+311
-84
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 120 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ batch:
6363
depend-on:
6464
- publish_to_local_registry
6565
- identifier: >-
66-
add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
66+
l_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
6767
buildspec: .codebuild/run_e2e_tests.yml
6868
env:
6969
compute-type: BUILD_GENERAL1_LARGE
@@ -74,7 +74,7 @@ batch:
7474
depend-on:
7575
- publish_to_local_registry
7676
- identifier: >-
77-
graphql_codegen_js_remove_codegen_android_remove_codegen_ios_add_codegen_android
77+
l_graphql_codegen_js_remove_codegen_android_remove_codegen_ios_add_codegen_android
7878
buildspec: .codebuild/run_e2e_tests.yml
7979
env:
8080
compute-type: BUILD_GENERAL1_LARGE
@@ -85,7 +85,7 @@ batch:
8585
depend-on:
8686
- publish_to_local_registry
8787
- identifier: >-
88-
configure_codegen_ios_datastore_modelgen_android_datastore_modelgen_js_feature_flags
88+
l_configure_codegen_ios_datastore_modelgen_android_datastore_modelgen_js_feature_flags
8989
buildspec: .codebuild/run_e2e_tests.yml
9090
env:
9191
compute-type: BUILD_GENERAL1_LARGE
@@ -96,7 +96,7 @@ batch:
9696
depend-on:
9797
- publish_to_local_registry
9898
- identifier: >-
99-
graphql_codegen_ios_add_codegen_js_datastore_modelgen_ios_remove_codegen_js
99+
l_graphql_codegen_ios_add_codegen_js_datastore_modelgen_ios_remove_codegen_js
100100
buildspec: .codebuild/run_e2e_tests.yml
101101
env:
102102
compute-type: BUILD_GENERAL1_LARGE
@@ -107,7 +107,7 @@ batch:
107107
depend-on:
108108
- publish_to_local_registry
109109
- identifier: >-
110-
datastore_modelgen_flutter_env_codegen_model_introspection_codegen_pull_codegen
110+
l_datastore_modelgen_flutter_env_codegen_model_introspection_codegen_pull_codegen
111111
buildspec: .codebuild/run_e2e_tests.yml
112112
env:
113113
compute-type: BUILD_GENERAL1_LARGE
@@ -118,7 +118,7 @@ batch:
118118
depend-on:
119119
- publish_to_local_registry
120120
- identifier: >-
121-
push_codegen_ios_push_codegen_android_graphql_documents_generator_push_codegen_js
121+
l_push_codegen_ios_push_codegen_android_graphql_documents_generator_push_codegen_js
122122
buildspec: .codebuild/run_e2e_tests.yml
123123
env:
124124
compute-type: BUILD_GENERAL1_LARGE
@@ -129,7 +129,7 @@ batch:
129129
depend-on:
130130
- publish_to_local_registry
131131
- identifier: >-
132-
build_app_ts_uninitialized_project_codegen_js_uninitialized_project_modelgen_android_uninitialized_project_modelgen_flutter
132+
l_build_app_ts_uninitialized_project_codegen_js_uninitialized_project_modelgen_android_uninitialized_project_modelgen_flutter
133133
buildspec: .codebuild/run_e2e_tests.yml
134134
env:
135135
compute-type: BUILD_GENERAL1_LARGE
@@ -139,7 +139,7 @@ batch:
139139
CLI_REGION: ap-southeast-1
140140
depend-on:
141141
- publish_to_local_registry
142-
- identifier: uninitialized_project_modelgen_ios_uninitialized_project_modelgen_js
142+
- identifier: l_uninitialized_project_modelgen_ios_uninitialized_project_modelgen_js
143143
buildspec: .codebuild/run_e2e_tests.yml
144144
env:
145145
compute-type: BUILD_GENERAL1_LARGE
@@ -149,10 +149,121 @@ batch:
149149
CLI_REGION: ap-southeast-2
150150
depend-on:
151151
- publish_to_local_registry
152+
- identifier: >-
153+
w_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
154+
buildspec: .codebuild/run_e2e_tests_windows.yml
155+
env:
156+
compute-type: BUILD_GENERAL1_LARGE
157+
image: $WINDOWS_IMAGE_2019
158+
type: WINDOWS_SERVER_2019_CONTAINER
159+
variables:
160+
TEST_SUITE: >-
161+
src/__tests__/add-codegen-ios.test.ts|src/__tests__/configure-codegen-android.test.ts|src/__tests__/configure-codegen-js.test.ts|src/__tests__/graphql-codegen-android.test.ts
162+
CLI_REGION: us-east-1
163+
depend-on:
164+
- publish_to_local_registry
165+
- build_windows
166+
- identifier: >-
167+
w_graphql_codegen_js_remove_codegen_android_remove_codegen_ios_add_codegen_android
168+
buildspec: .codebuild/run_e2e_tests_windows.yml
169+
env:
170+
compute-type: BUILD_GENERAL1_LARGE
171+
image: $WINDOWS_IMAGE_2019
172+
type: WINDOWS_SERVER_2019_CONTAINER
173+
variables:
174+
TEST_SUITE: >-
175+
src/__tests__/graphql-codegen-js.test.ts|src/__tests__/remove-codegen-android.test.ts|src/__tests__/remove-codegen-ios.test.ts|src/__tests__/add-codegen-android.test.ts
176+
CLI_REGION: us-east-1
177+
depend-on:
178+
- publish_to_local_registry
179+
- build_windows
180+
- identifier: >-
181+
w_configure_codegen_ios_datastore_modelgen_android_datastore_modelgen_js_feature_flags
182+
buildspec: .codebuild/run_e2e_tests_windows.yml
183+
env:
184+
compute-type: BUILD_GENERAL1_LARGE
185+
image: $WINDOWS_IMAGE_2019
186+
type: WINDOWS_SERVER_2019_CONTAINER
187+
variables:
188+
TEST_SUITE: >-
189+
src/__tests__/configure-codegen-ios.test.ts|src/__tests__/datastore-modelgen-android.test.ts|src/__tests__/datastore-modelgen-js.test.ts|src/__tests__/feature-flags.test.ts
190+
CLI_REGION: us-east-1
191+
depend-on:
192+
- publish_to_local_registry
193+
- build_windows
194+
- identifier: >-
195+
w_graphql_codegen_ios_add_codegen_js_datastore_modelgen_ios_remove_codegen_js
196+
buildspec: .codebuild/run_e2e_tests_windows.yml
197+
env:
198+
compute-type: BUILD_GENERAL1_LARGE
199+
image: $WINDOWS_IMAGE_2019
200+
type: WINDOWS_SERVER_2019_CONTAINER
201+
variables:
202+
TEST_SUITE: >-
203+
src/__tests__/graphql-codegen-ios.test.ts|src/__tests__/add-codegen-js.test.ts|src/__tests__/datastore-modelgen-ios.test.ts|src/__tests__/remove-codegen-js.test.ts
204+
CLI_REGION: us-east-1
205+
depend-on:
206+
- publish_to_local_registry
207+
- build_windows
208+
- identifier: >-
209+
w_datastore_modelgen_flutter_env_codegen_model_introspection_codegen_pull_codegen
210+
buildspec: .codebuild/run_e2e_tests_windows.yml
211+
env:
212+
compute-type: BUILD_GENERAL1_LARGE
213+
image: $WINDOWS_IMAGE_2019
214+
type: WINDOWS_SERVER_2019_CONTAINER
215+
variables:
216+
TEST_SUITE: >-
217+
src/__tests__/datastore-modelgen-flutter.test.ts|src/__tests__/env-codegen.test.ts|src/__tests__/model-introspection-codegen.test.ts|src/__tests__/pull-codegen.test.ts
218+
CLI_REGION: us-east-1
219+
depend-on:
220+
- publish_to_local_registry
221+
- build_windows
222+
- identifier: >-
223+
w_push_codegen_ios_push_codegen_android_graphql_documents_generator_push_codegen_js
224+
buildspec: .codebuild/run_e2e_tests_windows.yml
225+
env:
226+
compute-type: BUILD_GENERAL1_LARGE
227+
image: $WINDOWS_IMAGE_2019
228+
type: WINDOWS_SERVER_2019_CONTAINER
229+
variables:
230+
TEST_SUITE: >-
231+
src/__tests__/push-codegen-ios.test.ts|src/__tests__/push-codegen-android.test.ts|src/__tests__/graphql-documents-generator.test.ts|src/__tests__/push-codegen-js.test.ts
232+
CLI_REGION: us-east-1
233+
depend-on:
234+
- publish_to_local_registry
235+
- build_windows
236+
- identifier: >-
237+
w_build_app_ts_uninitialized_project_codegen_js_uninitialized_project_modelgen_android_uninitialized_project_modelgen_flutter
238+
buildspec: .codebuild/run_e2e_tests_windows.yml
239+
env:
240+
compute-type: BUILD_GENERAL1_LARGE
241+
image: $WINDOWS_IMAGE_2019
242+
type: WINDOWS_SERVER_2019_CONTAINER
243+
variables:
244+
TEST_SUITE: >-
245+
src/__tests__/build-app-ts.test.ts|src/__tests__/uninitialized-project-codegen-js.test.ts|src/__tests__/uninitialized-project-modelgen-android.test.ts|src/__tests__/uninitialized-project-modelgen-flutter.test.ts
246+
CLI_REGION: us-east-1
247+
depend-on:
248+
- publish_to_local_registry
249+
- build_windows
250+
- identifier: w_uninitialized_project_modelgen_ios_uninitialized_project_modelgen_js
251+
buildspec: .codebuild/run_e2e_tests_windows.yml
252+
env:
253+
compute-type: BUILD_GENERAL1_LARGE
254+
image: $WINDOWS_IMAGE_2019
255+
type: WINDOWS_SERVER_2019_CONTAINER
256+
variables:
257+
TEST_SUITE: >-
258+
src/__tests__/uninitialized-project-modelgen-ios.test.ts|src/__tests__/uninitialized-project-modelgen-js.test.ts
259+
CLI_REGION: us-east-1
260+
depend-on:
261+
- publish_to_local_registry
262+
- build_windows
152263
- identifier: cleanup_e2e_resources
153264
buildspec: .codebuild/cleanup_e2e_resources.yml
154265
env:
155266
compute-type: BUILD_GENERAL1_MEDIUM
156267
depend-on:
157268
- >-
158-
add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
269+
l_add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 0.2
2+
env:
3+
shell: powershell.exe
4+
variables:
5+
AMPLIFY_DIR: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin
6+
AMPLIFY_PATH: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin/amplify
7+
CI: true
8+
CODEBUILD: true
9+
NODE_OPTIONS: --max-old-space-size=8096
10+
SKIP_SET_NPM_PREFIX: true
11+
phases:
12+
build:
13+
commands:
14+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
15+
- bash ./.codebuild/scripts/e2e_test_windows.sh
16+
post_build:
17+
commands:
18+
# commands need to be run in stand-alone bash scripts so that bash can be used on windows
19+
- bash ./.codebuild/scripts/post_e2e_test.sh
20+
21+
artifacts:
22+
files:
23+
- '**/*'
24+
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 && _setupE2ETestsWindows
7+
codebuild-breakpoint
8+
source ./shared-scripts.sh && _runE2ETestsWindows

.codebuild/scripts/local_publish_helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function startLocalRegistry {
77
# Start local registry
88
tmp_registry_log="$(mktemp)"
99
echo "Registry output file: $tmp_registry_log"
10-
(cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &)
10+
nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &
1111
# Wait for Verdaccio to boot
1212
grep -q 'http address' <(tail -f $tmp_registry_log)
1313
}
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 && _unassumeTestAccountCredentials
7+
aws sts get-caller-identity
8+
source ./shared-scripts.sh && _scanArtifacts

packages/amplify-codegen-e2e-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"jest-circus": "^27.5.1",
3333
"jest-environment-node": "^26.6.2",
3434
"lodash": "^4.17.19",
35-
"node-pty": "beta",
35+
"node-pty": "1.0.0",
3636
"retimer": "2.0.0",
3737
"rimraf": "^3.0.0",
3838
"strip-ansi": "^6.0.0",

packages/amplify-codegen-e2e-core/src/categories/api.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export function addApiWithoutSchema(cwd: string, opts: Partial<AddApiOptions & {
4949
.sendCarriageReturn()
5050
.wait('Do you want to edit the schema now?')
5151
.sendConfirmNo()
52-
.wait(
53-
'"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud',
54-
)
52+
.wait('"amplify publish" will build all your local backend and frontend resources')
5553
.run((err: Error) => {
5654
if (!err) {
5755
resolve();
@@ -79,10 +77,8 @@ export function addApiWithBlankSchema(cwd: string, opts: Partial<AddApiOptions &
7977
.sendKeyDown(2)
8078
.sendCarriageReturn()
8179
.wait('Do you want to edit the schema now?')
82-
.sendLine('n')
83-
.wait(
84-
'"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud',
85-
)
80+
.sendConfirmNo()
81+
.wait('"amplify publish" will build all your local backend and frontend resources')
8682
.sendEof()
8783
.run((err: Error) => {
8884
if (!err) {
@@ -112,10 +108,8 @@ export function addApiWithBlankSchemaAndConflictDetection(cwd: string) {
112108
.sendKeyDown(2)
113109
.sendCarriageReturn()
114110
.wait('Do you want to edit the schema now?')
115-
.sendLine('n')
116-
.wait(
117-
'"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud',
118-
)
111+
.sendConfirmNo()
112+
.wait('"amplify publish" will build all your local backend and frontend resources')
119113
.run((err: Error) => {
120114
if (!err) {
121115
resolve();

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +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';
89

910
export * from './configure/';
1011
export * from './init/';
@@ -24,14 +25,16 @@ declare global {
2425
const amplifyTestsDir = 'amplify-codegen-e2e-tests';
2526

2627
export function getCLIPath(testingWithLatestCodebase = false) {
28+
let commandName = 'amplify-dev';
2729
if (isCI() && !testingWithLatestCodebase) {
28-
return 'amplify';
30+
commandName = 'amplify';
2931
}
30-
return 'amplify-dev';
32+
33+
return getCommandPath(commandName);
3134
}
3235

3336
export function isCI(): boolean {
34-
return process.env.CI && (process.env.CODEBUILD) ? true : false;
37+
return process.env.CI && process.env.CODEBUILD ? true : false;
3538
}
3639

3740
export function injectSessionToken(profileName: string) {
@@ -57,7 +60,9 @@ export async function createNewProjectDir(
5760
projectName: string,
5861
prefix = path.join(fs.realpathSync(os.tmpdir()), amplifyTestsDir),
5962
): Promise<string> {
60-
const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim();
63+
const currentHash = execSync('git rev-parse --short HEAD', { cwd: __dirname })
64+
.toString()
65+
.trim();
6166
let projectDir;
6267
do {
6368
const randomId = await global.getRandomId();

packages/amplify-codegen-e2e-core/src/init/cra.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* commands for a Create React App */
2-
import { nspawn as spawn } from '..';
2+
import { nspawn as spawn, getCommandPath } from '..';
33

44
const defaultSettings = {
55
disableCIDetection: false,
@@ -8,7 +8,7 @@ const defaultSettings = {
88
export function craInstall(cwd: string, settings: Object = {}): Promise<void> {
99
return new Promise((resolve, reject) => {
1010
const s = { ...defaultSettings, ...settings };
11-
const chain = spawn('npm', ['install'], { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
11+
const chain = spawn(getCommandPath('npm'), ['install'], { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
1212

1313
chain.run((err: Error) => {
1414
if (err) {
@@ -23,7 +23,7 @@ export function craInstall(cwd: string, settings: Object = {}): Promise<void> {
2323
export function craBuild(cwd: string, settings: Object = {}): Promise<void> {
2424
return new Promise((resolve, reject) => {
2525
const s = { ...defaultSettings, ...settings };
26-
const chain = spawn('npm', ['run', 'build'], { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
26+
const chain = spawn(getCommandPath('npm'), ['run', 'build'], { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
2727

2828
chain.run((err: Error) => {
2929
if (err) {
@@ -41,8 +41,8 @@ export function cypressRun(cwd: string, settings: any = {}): Promise<void> {
4141
const args = ['cypress', 'run'];
4242
if (s?.componentsTesting) {
4343
args.push('--component');
44-
};
45-
const chain = spawn('npx', args, { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
44+
}
45+
const chain = spawn(getCommandPath('npx'), args, { cwd, stripColors: true, disableCIDetection: s.disableCIDetection });
4646

4747
chain.run((err: Error) => {
4848
if (err) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { execSync } from 'child_process';
2+
/* Get the full absolute path of a command with `which`
3+
*
4+
* Windows executors on CB fail to spawn a command with custom nexpect unless the full path is used.
5+
*/
6+
export function getCommandPath(command: string): string {
7+
return execSync(`which ${command}`)
8+
.toString()
9+
.trim();
10+
}

0 commit comments

Comments
 (0)