-
Notifications
You must be signed in to change notification settings - Fork 11.9k
test(@angular/cli): add CI validation for MCP example code #31174
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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,28 @@ | ||||||
{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating a application and commit it, should we use the current setup we have to generate an application on the fly? This is similar to other validations and it would make it easier to keep the app in code and deps in sync. See: angular-cli/scripts/json-help.mts Lines 34 to 35 in a195db3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking more about this, instead of added another CI step, why not simply add a bazel test? diff --git a/packages/angular/cli/lib/examples/BUILD.bazel b/packages/angular/cli/lib/examples/BUILD.bazel
new file mode 100644
index 000000000..b1f9df0c5
--- /dev/null
+++ b/packages/angular/cli/lib/examples/BUILD.bazel
@@ -0,0 +1,16 @@
+
+filegroup(
+ name = "examples",
+ srcs = glob( ["**/*.md"]),
+)
+
+sh_test(
+ name = "test",
+ srcs = ["//tools:ng_example_db"],
+ data = [":examples", "//tools:ng_example_db"],
+ args = [
+ "$(locations :examples)",
+ "--mode validate-structure",
+ ],
+)
diff --git a/tools/process_examples.mjs b/tools/process_examples.mjs
index 143f8d95a..2939bb9ea 100755
--- a/tools/process_examples.mjs
+++ b/tools/process_examples.mjs
@@ -162,14 +162,12 @@ function parseExampleFile(filePath) {
}
// --- Mode Implementations ---
-
function runValidateStructure(examplesPath) {
console.log('Validating markdown structure of all example files...');
- const exampleFiles = globSync('**/*.md', { cwd: examplesPath });
- for (const file of exampleFiles) {
- parseExampleFile(join(examplesPath, file));
+ for (const file of examplesPath) {
+ parseExampleFile(file);
}
- console.log(`Successfully validated structure of ${exampleFiles.length} files.`);
+ console.log(`Successfully validated structure of ${examplesPath.length} files.`);
}
function runGenerateDb(examplesPath, outputPath) {
@@ -357,7 +355,8 @@ function main() {
},
},
});
- const examplesPath = positionals[0] ?? '.';
+
+ const examplesPath = positionals ?? '.';
const mode = values.mode;
console.log(`Running example processor in '${mode}' mode.`);
@@ -371,7 +370,7 @@ function main() {
runValidateCode(examplesPath);
break;
case 'generate-db':
- runGenerateDb(examplesPath, values.output);
+ runGenerateDb(examplesPath[0], values.output);
break;
default:
throw new Error(
In a follow up we could also update IMO: I think it easier in terms of maintainability and future proofing to have all tests run with a single command and under bazel, instead of having multiple commands |
||||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||||||
"version": 1, | ||||||
"newProjectRoot": "projects", | ||||||
"projects": { | ||||||
"validation-harness": { | ||||||
"projectType": "application", | ||||||
"root": "", | ||||||
"sourceRoot": "src", | ||||||
"prefix": "app", | ||||||
"architect": { | ||||||
"build": { | ||||||
"builder": "@angular/build:application", | ||||||
"options": { | ||||||
"outputPath": "dist/validation-harness", | ||||||
"index": "src/index.html", | ||||||
"browser": "src/main.ts", | ||||||
"polyfills": ["zone.js"], | ||||||
"tsConfig": "tsconfig.app.json", | ||||||
"assets": [], | ||||||
"styles": [], | ||||||
"scripts": [] | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: should this has it's own pnpm lock and workspace file, seeing that there are a seperate |
||
"name": "example-validation-harness", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@angular/common": "^21.0.0-next", | ||
"@angular/compiler": "^21.0.0-next", | ||
"@angular/core": "^21.0.0-next", | ||
"@angular/forms": "^21.0.0-next", | ||
"@angular/platform-browser": "^21.0.0-next", | ||
"rxjs": "~7.8.0", | ||
"tslib": "^2.3.0", | ||
"zone.js": "~0.15.0" | ||
}, | ||
"devDependencies": { | ||
"@angular/build": "^21.0.0-next", | ||
"@angular/cli": "^21.0.0-next", | ||
"@angular/compiler-cli": "^21.0.0-next", | ||
"typescript": "~5.9.2" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
imports: [], | ||
template: '', | ||
}) | ||
export class App {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>ValidationHarness</title> | ||
<base href="/"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
</head> | ||
<body> | ||
<app-root></app-root> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import { bootstrapApplication } from '@angular/platform-browser'; | ||
import { App } from './app/app'; | ||
|
||
bootstrapApplication(App).catch((err) => console.error(err)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./out-tsc/app", | ||
"types": [] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["src/**/*.spec.ts"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"skipLibCheck": true, | ||
"isolatedModules": true, | ||
"experimentalDecorators": true, | ||
"importHelpers": true, | ||
"target": "ES2022", | ||
"module": "preserve" | ||
}, | ||
"angularCompilerOptions": { | ||
"enableI18nLegacyMessageIdFormat": false, | ||
"strictInjectionParameters": true, | ||
"strictInputAccessModifiers": true, | ||
"typeCheckHostBindings": true, | ||
"strictTemplates": true | ||
}, | ||
"files": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.app.json" | ||
} | ||
] | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: consider moving this to before the license checks so that it's always executed even when there are license failures, this is useful for automated dependency bumps. Potentially move
Check Package Licenses
as the last step