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

chore(cdk-lib): cloud-assembly-schema tests are flaky, becaue they are not free of side-effects #26568

Merged
merged 1 commit into from
Jul 30, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ function log(message: string) {
*/
const SCHEMA_DIR = path.resolve(__dirname, '../schema');

const SCHEMA_DEFINITIONS: { [schemaName: string]: { rootTypeName: string } } = {
'assets': { rootTypeName: 'AssetManifest' },
'cloud-assembly': { rootTypeName: 'AssemblyManifest' },
'integ': { rootTypeName: 'IntegManifest' },
const SCHEMA_DEFINITIONS: {
[schemaName: string]: {
/**
* The name of the root type.
*/
rootTypeName: string;
/**
* Files loaded to generate the schema.
* Should be relative to `cloud-assembly-schema/lib`.
* Usually this is just the file containing the root type.
*/
files: string[];
}
} = {
'assets': {
rootTypeName: 'AssetManifest',
files: [path.join('assets', 'schema.ts')],
},
'cloud-assembly': {
rootTypeName: 'AssemblyManifest',
files: [path.join('cloud-assembly', 'schema.ts')],
},
'integ': {
rootTypeName: 'IntegManifest',
files: [path.join('integ-tests', 'schema.ts')],
},
};

export const SCHEMAS = Object.keys(SCHEMA_DEFINITIONS);
Expand Down Expand Up @@ -59,14 +81,13 @@ export function generateSchema(schemaName: string, saveToFile: boolean = true) {
topRef: true,
noExtraProps: false,
out,
skipLibCheck: true,
};

const compilerOptions = {
strictNullChecks: true,
};

const program = tjs.getProgramFromFiles([path.join(__dirname, '../lib/index.d.ts')], compilerOptions);
const program = tjs.getProgramFromFiles(spec.files.map(file =>path.join(__dirname, '..', 'lib', file)), compilerOptions);
const schema = tjs.generateSchema(program, spec.rootTypeName, settings);

augmentDescription(schema);
Expand Down Expand Up @@ -126,5 +147,5 @@ function augmentDescription(schema: any) {
* compatibility checks.
*/
function addAnyMetadataEntry(schema: any) {
schema.definitions.MetadataEntry?.properties.data.anyOf.push({ description: 'Free form data.' });
schema?.definitions?.MetadataEntry?.properties.data.anyOf.push({ description: 'Free form data.' });
}