ci: set up golden file for typescript circular dependencies (#35647)

Sets up a golden file for the TypeScript circular dependencies for
source files inside of the `packages/` folder.

Also sets up the appropriate Yarn shorthand scripts, and a codeowner
group that is soley responsible for verifying changes to the golden.

PR Close #35647
This commit is contained in:
Paul Gschwendtner 2020-02-24 12:08:24 +01:00 committed by Andrew Kushnir
parent b7138c1ec5
commit f5a5c36d3c
5 changed files with 5711 additions and 5 deletions

View File

@ -1025,6 +1025,24 @@ groups:
- ~framework-global-approvers - ~framework-global-approvers
# ================================================
# Circular dependencies
# ================================================
circular-dependencies:
conditions:
- >
contains_any_globs(files, [
'goldens/packages-circular-deps.json'
])
reviewers:
users:
- IgorMinar
- josephperrott
- kara
teams:
- ~framework-global-approvers
#################################################################################### ####################################################################################
# Special Cases # Special Cases
#################################################################################### ####################################################################################

View File

@ -120,10 +120,18 @@ export function main(
chalk.yellow(` Fixed circular dependencies that need to be removed from the golden:`)); chalk.yellow(` Fixed circular dependencies that need to be removed from the golden:`));
fixedCircularDeps.forEach(c => console.error(`${convertReferenceChainToString(c)}`)); fixedCircularDeps.forEach(c => console.error(`${convertReferenceChainToString(c)}`));
console.info(); console.info();
// Print the command for updating the golden. Note that we hard-code the script name for
// approving default packages golden in `goldens/`. We cannot infer the script name passed to
// Yarn automatically since script are launched in a child process where `argv0` is different.
if (resolve(goldenFile) === resolve(projectDir, 'goldens/packages-circular-deps.json')) {
console.info(
chalk.yellow(` Please approve the new golden with: yarn ts-circular-deps:approve`));
} else {
console.info(chalk.yellow( console.info(chalk.yellow(
` Please update the golden. The following command can be ` + ` Please update the golden. The following command can be ` +
`run: yarn ts-circular-deps approve ${getRelativePath(baseDir, goldenFile)}.`)); `run: yarn ts-circular-deps approve ${getRelativePath(baseDir, goldenFile)}.`));
} }
}
return 1; return 1;
} }

View File

@ -9,3 +9,17 @@ To check or update the public api goldens, run one of the following commands:
yarn public-api:check yarn public-api:check
yarn public-api:update yarn public-api:update
``` ```
### *`packages-circular-deps.json`*
This golden file contains a list of all circular dependencies in the project. As part of the
lint CI job we compare the current circular dependencies against this golden to ensure that
we don't add more cycles. If cycles have been fixed, this file is also updated so that we can
slowly burn down the number of cycles in the project.
To check or update the golden, run the following commands:
```bash
yarn ts-circular-deps:check
yarn ts-circular-deps:approve
```

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,9 @@
"tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(packages|modules|scripts|tools)/**/*.+(js|ts)\"", "tslint": "tsc -p tools/tsconfig.json && tslint -c tslint.json \"+(packages|modules|scripts|tools)/**/*.+(js|ts)\"",
"public-api:check": "node goldens/public-api/manage.js test", "public-api:check": "node goldens/public-api/manage.js test",
"public-api:update": "node goldens/public-api/manage.js accept", "public-api:update": "node goldens/public-api/manage.js accept",
"ts-circular-deps": "ts-node dev-infra/ts-circular-dependencies/index.ts" "ts-circular-deps": "ts-node dev-infra/ts-circular-dependencies/index.ts",
"ts-circular-deps:check": "yarn -s ts-circular-deps check ./goldens/packages-circular-deps.json",
"ts-circular-deps:approve": "yarn -s ts-circular-deps approve ./goldens/packages-circular-deps.json"
}, },
"// 1": "dependencies are used locally and by bazel", "// 1": "dependencies are used locally and by bazel",
"dependencies": { "dependencies": {