Skip to content

Commit fd95833

Browse files
committed
feat: add android e2e test
1 parent 225ad09 commit fd95833

File tree

7 files changed

+81
-18
lines changed

7 files changed

+81
-18
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ batch:
3737
CLI_REGION: us-east-2
3838
depend-on:
3939
- publish_to_local_registry
40+
- identifier: build_app_android
41+
buildspec: .codebuild/run_android_modelgen_e2e_test.yml
42+
env:
43+
compute-type: BUILD_GENERAL1_LARGE
44+
variables:
45+
TEST_SUITE: src/__tests__/build-app-android.test.ts
46+
CLI_REGION: us-east-2
47+
depend-on:
48+
- publish_to_local_registry
4049
- identifier: >-
4150
add_codegen_ios_configure_codegen_android_configure_codegen_js_graphql_codegen_android
4251
buildspec: .codebuild/run_e2e_tests.yml
@@ -100,7 +109,7 @@ batch:
100109
variables:
101110
TEST_SUITE: >-
102111
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
103-
CLI_REGION: ap-southeast-1
112+
CLI_REGION: ap-northeast-1
104113
depend-on:
105114
- publish_to_local_registry
106115
- identifier: build_app_ts
@@ -109,16 +118,7 @@ batch:
109118
compute-type: BUILD_GENERAL1_LARGE
110119
variables:
111120
TEST_SUITE: src/__tests__/build-app-ts.test.ts
112-
CLI_REGION: ap-southeast-2
113-
depend-on:
114-
- publish_to_local_registry
115-
- identifier: build_app_android
116-
buildspec: .codebuild/run_e2e_tests.yml
117-
env:
118-
compute-type: BUILD_GENERAL1_MEDIUM
119-
variables:
120-
TEST_SUITE: src/__tests__/build-app-android.test.ts
121-
CLI_REGION: ap-northeast-1
121+
CLI_REGION: ap-southeast-1
122122
depend-on:
123123
- publish_to_local_registry
124124
- identifier: cleanup_e2e_resources

.codebuild/e2e_workflow_base.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ batch:
3737
CLI_REGION: us-east-2
3838
depend-on:
3939
- publish_to_local_registry
40+
- identifier: build_app_android
41+
buildspec: .codebuild/run_android_modelgen_e2e_test.yml
42+
env:
43+
compute-type: BUILD_GENERAL1_LARGE
44+
variables:
45+
TEST_SUITE: src/__tests__/build-app-android.test.ts
46+
CLI_REGION: us-east-2
47+
depend-on:
48+
- publish_to_local_registry
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 0.2
2+
env:
3+
shell: bash
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+
11+
phases:
12+
install:
13+
commands:
14+
- sudo apt update
15+
- yes | sudo apt install android-sdk
16+
- export ANDROID_HOME=/usr/lib/android-sdk
17+
- yes | sudo apt install sdkmanager
18+
# Review SDK licenses
19+
- yes | sudo sdkmanager --licenses
20+
21+
build:
22+
commands:
23+
- source ./shared-scripts.sh && _runE2ETestsLinux
24+
post_build:
25+
commands:
26+
- aws sts get-caller-identity
27+
- source ./shared-scripts.sh && _scanArtifacts
28+
29+
artifacts:
30+
files:
31+
- $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports/*
32+
discard-paths: yes

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,26 @@ export function androidBuild(cwd: string, settings: Object = {}): Promise<void>
2525
}
2626
});
2727
});
28-
}
28+
};
29+
30+
export function acceptLicenses(cwd: string, settings: Object = {}): Promise<void> {
31+
return new Promise((resolve, reject) => {
32+
const s = { ...defaultSettings, ...settings };
33+
34+
const chain = spawn('sdkmanager', ['--licenses'], {
35+
cwd,
36+
stripColors: true,
37+
disableCIDetection: s.disableCIDetection
38+
})
39+
.wait("Review licenses that have not been accepted (y/N)?")
40+
.sendLine("y");
41+
42+
chain.run((err: Error) => {
43+
if (err) {
44+
reject(err);
45+
} else {
46+
resolve();
47+
}
48+
});
49+
});
50+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"private": true,
1919
"scripts": {
20-
"e2e": "npm run setup-profile && jest --verbose",
20+
"e2e": "npm run setup-profile && jest --verbose --forceExit",
2121
"setup-profile": "ts-node ./src/configure_tests.ts",
2222
"clean-e2e-resources": "ts-node ./src/cleanup-e2e-resources.ts",
2323
"clean-cb-e2e-resources": "ts-node ./src/cleanup-cb-e2e-resources.ts"

packages/amplify-codegen-e2e-tests/src/__tests__/build-app-android.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
22
initProjectWithQuickstart,
33
DEFAULT_ANDROID_CONFIG,
4-
addApiWithBlankSchemaAndConflictDetection,
54
updateApiSchemaWithText,
65
generateModels,
76
androidBuild,
7+
acceptLicenses
88
} from '@aws-amplify/amplify-codegen-e2e-core';
99
const { schemas } = require('@aws-amplify/graphql-schema-test-library');
1010
import { existsSync, writeFileSync, readdirSync, rmSync } from 'fs';
@@ -21,6 +21,7 @@ describe('build app - Android', () => {
2121
beforeAll(async () => {
2222
await initProjectWithQuickstart(projectRoot, { ...config });
2323
apiName = readdirSync(path.join(projectRoot, 'amplify', 'backend', 'api'))[0];
24+
await acceptLicenses(projectRoot);
2425
});
2526

2627
afterAll(async () => {

scripts/split-e2e-tests-codebuild.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ const REPO_ROOT = join(__dirname, '..');
2121
const TEST_TIMINGS_PATH = join(REPO_ROOT, 'scripts', 'cci', 'test-timings.data.json');
2222
const CODEBUILD_CONFIG_BASE_PATH = join(REPO_ROOT, '.codebuild', 'e2e_workflow_base.yml');
2323
const CODEBUILD_GENERATE_CONFIG_PATH = join(REPO_ROOT, '.codebuild', 'e2e_workflow.yml');
24-
const RUN_SOLO = [
25-
'src/__tests__/build-app-android.test.ts',
26-
];
24+
const RUN_SOLO = [];
2725
const EXCLUDE_TESTS = [
2826
'src/__tests__/build-app-swift.test.ts',
27+
'src/__tests__/build-app-android.test.ts',
2928
];
3029

3130
export function loadConfigBase() {
@@ -166,7 +165,7 @@ const splitTests = (
166165
tmp.env.variables.USE_PARENT_ACCOUNT = 1;
167166
}
168167
if (j.runSolo) {
169-
tmp.env['compute-type'] = 'BUILD_GENERAL1_MEDIUM';
168+
tmp.env['compute-type'] = 'BUILD_GENERAL1_LARGE';
170169
}
171170
result.push(tmp);
172171
}

0 commit comments

Comments
 (0)