Skip to content

Commit

Permalink
Merge pull request #668 from aws-amplify/main
Browse files Browse the repository at this point in the history
Release Amplify Codegen 08-15-2023
  • Loading branch information
AaronZyLee authored Aug 15, 2023
2 parents 612fd61 + cb28b9b commit d284bdb
Show file tree
Hide file tree
Showing 20 changed files with 424 additions and 347 deletions.
6 changes: 5 additions & 1 deletion .codebuild/cleanup_e2e_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ env:
phases:
build:
commands:
- source ./shared-scripts.sh && _cleanupE2EResources
- source ./shared-scripts.sh && _cleanupE2EResources
artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
6 changes: 5 additions & 1 deletion .codebuild/cleanup_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ phases:
build:
commands:
- yarn production-build
- cd packages/amplify-codegen-e2e-tests && yarn clean-e2e-resources
- cd packages/amplify-codegen-e2e-tests && yarn clean-e2e-resources
artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
5 changes: 3 additions & 2 deletions .codebuild/run_android_modelgen_e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ phases:
- source ./shared-scripts.sh && _runE2ETestsLinux
post_build:
commands:
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
5 changes: 3 additions & 2 deletions .codebuild/run_e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ phases:
- source ./shared-scripts.sh && _runE2ETestsLinux
post_build:
commands:
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
4 changes: 2 additions & 2 deletions .codebuild/run_ios_modelgen_e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ phases:

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"packages/*"
],
"devDependencies": {
"@aws-amplify/amplify-cli-core": "^4.0.4",
"@aws-amplify/amplify-cli-core": "^4.2.4-rc.43f73ab268.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@commitlint/config-lerna-scopes": "^17.0.2",
Expand Down Expand Up @@ -119,7 +119,7 @@
"typescript": "4.7.4"
},
"resolutions": {
"@aws-amplify/amplify-cli-core": "4.0.4",
"@aws-amplify/amplify-cli-core": "4.2.4-rc.43f73ab268.0",
"minimist": "^1.2.6",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/ini": "^1.3.31"
},
"peerDependencies": {
"@aws-amplify/amplify-cli-core": "^4.0.0",
"@aws-amplify/amplify-cli-core": "^4.2.4-rc.43f73ab268.0",
"amplify-headless-interface": "^1.13.1",
"graphql-transformer-core": "^8.0.0"
}
Expand Down
8 changes: 5 additions & 3 deletions packages/amplify-codegen-e2e-core/src/nexpect-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ class AmplifyCLIExecutionReporter {

onRunComplete(contexts, results) {
const { publicPath = process.cwd(), filename = 'jest_html_reporters.html', logoImgPath } = this._options;
const runIdx = process.env['RUN_INDEX'] ?? '0';
const logoImg = logoImgPath ? imgToBase64(logoImgPath) : undefined;
fs.ensureDirSync(publicPath);
const reportPath = path.join(publicPath, runIdx);
fs.ensureDirSync(reportPath);

const processedResults = results.testResults.map(result => {
const resultCopy = { ...result };
Expand All @@ -73,7 +75,7 @@ class AmplifyCLIExecutionReporter {

const recordingWithPath = recordings.map(r => {
const castFile = `${uuid.v4()}.cast`;
const castFilePath = path.join(publicPath, castFile);
const castFilePath = path.join(reportPath, castFile);
fs.writeFileSync(castFilePath, r.recording);
const rCopy = { ...r };
delete rCopy.recording;
Expand All @@ -98,7 +100,7 @@ class AmplifyCLIExecutionReporter {
resultsWithRecordings._reporterOptions = { ...this._options, logoImg, customInfos: {} };
const data = JSON.stringify(resultsWithRecordings);

const filePath = path.resolve(publicPath, filename);
const filePath = path.resolve(reportPath, filename);
// const filePathMock = path.resolve(publicPath, `devMock.json`);
// fs.writeFileSync(filePathMock, data);
const htmlTemplate = fs.readFileSync(localTemplatePath, 'utf-8');
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ts-node": "^8.10.1"
},
"peerDependencies": {
"@aws-amplify/amplify-cli-core": "^4.0.0",
"@aws-amplify/amplify-cli-core": "^4.2.4-rc.43f73ab268.0",
"graphql-transformer-core": "^8.0.0"
},
"jest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AWS_REGIONS_TO_RUN_TESTS = [
'ap-southeast-2',
];

const reportPath = path.normalize(path.join(__dirname, '..', 'amplify-e2e-reports', 'stale-resources.json'));
const reportPathDir = path.normalize(path.join(__dirname, '..', 'amplify-e2e-reports'));

const MULTI_JOB_APP = '<Amplify App reused by multiple apps>';
const ORPHAN = '<orphan>';
Expand Down Expand Up @@ -546,7 +546,8 @@ const deleteCfnStack = async (account: AWSAccountInfo, accountIndex: number, sta
}
};

const generateReport = (jobs: _.Dictionary<ReportEntry>): void => {
const generateReport = (jobs: _.Dictionary<ReportEntry>, accountIdx: number): void => {
const reportPath = path.join(reportPathDir, `stale-resources-${accountIdx}.json`);
fs.ensureFileSync(reportPath);
fs.writeFileSync(reportPath, JSON.stringify(jobs, null, 4));
};
Expand Down Expand Up @@ -688,7 +689,7 @@ const cleanupAccount = async (account: AWSAccountInfo, accountIndex: number, fil
const allResources = await mergeResourcesByCCIJob(apps, stacks, buckets, orphanBuckets, orphanIamRoles);
const staleResources = _.pickBy(allResources, filterPredicate);

generateReport(staleResources);
generateReport(staleResources, accountIndex);
await deleteResources(account, accountIndex, staleResources);
console.log(`${generateAccountInfo(account, accountIndex)} Cleanup done!`);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/amplify-codegen/src/commands/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Amplify Flutter versions prior to 0.6.0 are no longer supported by codegen. Plea
const transformerVersion = readNumericFeatureFlag('graphQLTransformer.transformerVersion');
const respectPrimaryKeyAttributesOnConnectionField = readFeatureFlag('graphQLTransformer.respectPrimaryKeyAttributesOnConnectionField');
const generateModelsForLazyLoadAndCustomSelectionSet = readFeatureFlag('codegen.generateModelsForLazyLoadAndCustomSelectionSet');
const improvePluralization = readFeatureFlag('graphQLTransformer.improvePluralization');

let isTimestampFieldsAdded = readFeatureFlag('codegen.addTimestampFields');

Expand All @@ -125,6 +126,7 @@ Amplify Flutter versions prior to 0.6.0 are no longer supported by codegen. Plea
usePipelinedTransformer,
transformerVersion,
respectPrimaryKeyAttributesOnConnectionField,
improvePluralization,
generateModelsForLazyLoadAndCustomSelectionSet,
codegenVersion: packageVersion,
overrideOutputDir, // This needs to live under `config` in order for the GraphQL types to work out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ extension Post {
public static let schema = defineSchema { model in
let post = Post.keys
model.pluralName = \\"Posts\\"
model.listPluralName = \\"Posts\\"
model.syncPluralName = \\"Posts\\"
model.attributes(
.index(fields: [\\"id\\", \\"title\\"], name: nil),
Expand Down Expand Up @@ -175,7 +176,8 @@ extension Comment {
public static let schema = defineSchema { model in
let comment = Comment.keys
model.pluralName = \\"Comments\\"
model.listPluralName = \\"Comments\\"
model.syncPluralName = \\"Comments\\"
model.attributes(
.index(fields: [\\"id\\", \\"content\\"], name: nil),
Expand Down Expand Up @@ -285,7 +287,8 @@ extension ModelCompositePk {
public static let schema = defineSchema { model in
let modelCompositePk = ModelCompositePk.keys
model.pluralName = \\"ModelCompositePks\\"
model.listPluralName = \\"ModelCompositePks\\"
model.syncPluralName = \\"ModelCompositePks\\"
model.attributes(
.index(fields: [\\"id\\", \\"dob\\"], name: nil),
Expand Down Expand Up @@ -385,7 +388,8 @@ extension ModelExplicitCustomPk {
public static let schema = defineSchema { model in
let modelExplicitCustomPk = ModelExplicitCustomPk.keys
model.pluralName = \\"ModelExplicitCustomPks\\"
model.listPluralName = \\"ModelExplicitCustomPks\\"
model.syncPluralName = \\"ModelExplicitCustomPks\\"
model.attributes(
.index(fields: [\\"userId\\"], name: nil),
Expand Down Expand Up @@ -480,7 +484,8 @@ extension ModelExplicitDefaultPk {
public static let schema = defineSchema { model in
let modelExplicitDefaultPk = ModelExplicitDefaultPk.keys
model.pluralName = \\"ModelExplicitDefaultPks\\"
model.listPluralName = \\"ModelExplicitDefaultPks\\"
model.syncPluralName = \\"ModelExplicitDefaultPks\\"
model.attributes(
.index(fields: [\\"id\\"], name: nil),
Expand Down Expand Up @@ -569,7 +574,8 @@ extension ModelImplicitDefaultPk {
public static let schema = defineSchema { model in
let modelImplicitDefaultPk = ModelImplicitDefaultPk.keys
model.pluralName = \\"ModelImplicitDefaultPks\\"
model.listPluralName = \\"ModelImplicitDefaultPks\\"
model.syncPluralName = \\"ModelImplicitDefaultPks\\"
model.attributes(
.primaryKey(fields: [modelImplicitDefaultPk.id])
Expand Down Expand Up @@ -703,7 +709,8 @@ extension Project {
public static let schema = defineSchema { model in
let project = Project.keys
model.pluralName = \\"Projects\\"
model.listPluralName = \\"Projects\\"
model.syncPluralName = \\"Projects\\"
model.attributes(
.index(fields: [\\"projectId\\", \\"name\\"], name: nil),
Expand Down Expand Up @@ -841,7 +848,8 @@ extension Team {
public static let schema = defineSchema { model in
let team = Team.keys
model.pluralName = \\"Teams\\"
model.listPluralName = \\"Teams\\"
model.syncPluralName = \\"Teams\\"
model.attributes(
.index(fields: [\\"teamId\\", \\"name\\"], name: nil),
Expand Down Expand Up @@ -983,7 +991,8 @@ extension ListContainer {
public static let schema = defineSchema { model in
let listContainer = ListContainer.keys
model.pluralName = \\"ListContainers\\"
model.listPluralName = \\"ListContainers\\"
model.syncPluralName = \\"ListContainers\\"
model.fields(
.id(),
Expand Down Expand Up @@ -1122,7 +1131,8 @@ extension Todo {
public static let schema = defineSchema { model in
let todo = Todo.keys
model.pluralName = \\"Todos\\"
model.listPluralName = \\"Todos\\"
model.syncPluralName = \\"Todos\\"
model.fields(
.id(),
Expand Down Expand Up @@ -1247,7 +1257,8 @@ extension task {
public static let schema = defineSchema { model in
let task = task.keys
model.pluralName = \\"tasks\\"
model.listPluralName = \\"tasks\\"
model.syncPluralName = \\"tasks\\"
model.fields(
.id(),
Expand Down
Loading

0 comments on commit d284bdb

Please sign in to comment.