-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
Updates `aws-service-spec` to run a custom build that is using the public API from `service-spec-importers`. Also adds a new build step to post the diff between `base` and `head` branch to the PR.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as zlib from 'node:zlib'; | ||
import { emptyDatabase } from '@aws-cdk/service-spec-types'; | ||
import { FullDatabase } from './full-database'; | ||
import { writeFile } from 'node:fs/promises'; | ||
|
||
async function main() { | ||
const outputFile = 'db.json.gz'; | ||
const buildReport = 'build-report'; | ||
|
||
process.stdout.write('Importing default sources... '); | ||
const { db, report } = await new FullDatabase(emptyDatabase(), { | ||
// @TODO: Switch this to 'true' once validation passes (this will never happen) | ||
validate: false, | ||
debug: Boolean(process.env.DEBUG), | ||
}).build(); | ||
const importResult = report.totalCount ? `WARN (${report.totalCount} problems encountered)` : 'OK'; | ||
process.stdout.write(`${importResult}\n`); | ||
|
||
process.stdout.write(`Writing database to file ${outputFile}... `); | ||
const data = JSON.stringify(db.save()); | ||
await writeFile(outputFile, zlib.gzipSync(data), { encoding: 'binary' }); | ||
process.stdout.write('OK\n'); | ||
|
||
process.stdout.write(`Creating build report in ${buildReport}... `); | ||
await report.write(buildReport); | ||
process.stdout.write('OK\n'); | ||
} | ||
|
||
main().catch((error) => { | ||
process.exitCode = 1; | ||
console.error('FAIL\n\n'); | ||
console.error(error); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as path from 'node:path'; | ||
import { SpecDatabase } from '@aws-cdk/service-spec-types'; | ||
import { DatabaseBuilder, DatabaseBuilderOptions, ReportAudience } from '@aws-cdk/service-spec-importers'; | ||
import { Augmentations } from './augmentations'; | ||
import { Scrutinies } from './scrutinies'; | ||
|
||
const SOURCES = path.join(__dirname, '../../../../sources'); | ||
|
||
export class FullDatabase extends DatabaseBuilder { | ||
public defaultProblemGrouping = new ReportAudience('CDK_Team'); | ||
|
||
constructor(db: SpecDatabase, options: DatabaseBuilderOptions) { | ||
super(db, options); | ||
|
||
this.importCloudFormationResourceSpec(path.join(SOURCES, 'CloudFormationResourceSpecification')) | ||
.importSamResourceSpec(path.join(SOURCES, 'CloudFormationResourceSpecification/us-east-1/100_sam')) | ||
.importCloudFormationRegistryResources(path.join(SOURCES, 'CloudFormationSchema')) | ||
.importSamJsonSchema(path.join(SOURCES, 'SAMSpec/sam.schema.json')) | ||
.importCloudFormationDocs(path.join(SOURCES, 'CloudFormationDocumentation/CloudFormationDocumentation.json')) | ||
.importStatefulResources(path.join(SOURCES, 'StatefulResources/StatefulResources.json')) | ||
.importCannedMetrics( | ||
path.join(SOURCES, 'CloudWatchConsoleServiceDirectory/CloudWatchConsoleServiceDirectory.json'), | ||
) | ||
.importScrutinies() | ||
.importAugmentations(); | ||
} | ||
|
||
/** | ||
* Import Augmentations | ||
*/ | ||
public importAugmentations() { | ||
return this.addSourceImporter(async (db) => new Augmentations(db).import()); | ||
} | ||
|
||
/** | ||
* Import Scrutinies | ||
*/ | ||
public importScrutinies() { | ||
return this.addSourceImporter(async (db) => new Scrutinies(db).import()); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.