Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
uses: angular/dev-infra/github-actions/linting/licenses@5043638fd8529765b375831a4679b9013141b326
- name: Check tooling setup
run: pnpm check-tooling-setup
- name: Validate MCP Example Markdown
Copy link
Collaborator

@alan-agius4 alan-agius4 Sep 12, 2025

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

run: pnpm check-mcp-examples
- name: Check commit message
# Commit message validation is only done on pull requests as its too late to validate once
# it has been merged.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"public-api:update": "node goldens/public-api/manage.js accept",
"ts-circular-deps": "pnpm -s ng-dev ts-circular-deps --config ./scripts/circular-deps-test.conf.mjs",
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json",
"check-mcp-examples": "node tools/process_examples.mjs packages/angular/cli/lib/examples --mode validate-structure",
"diff-release-package": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/diff-release-package.mts"
},
"repository": {
Expand Down Expand Up @@ -124,6 +125,7 @@
"listr2": "9.0.3",
"lodash": "^4.17.21",
"magic-string": "0.30.19",
"marked": "^16.2.1",
"npm": "^11.0.0",
"prettier": "^3.0.0",
"protractor": "~7.0.0",
Expand Down
12 changes: 11 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ js_binary(
js_binary(
name = "ng_example_db",
data = [
"example_db_generator.js",
"process_examples.mjs",
"//:node_modules/marked",
"//:node_modules/zod",
],
entry_point = "example_db_generator.js",
entry_point = "process_examples.mjs",
)
28 changes: 28 additions & 0 deletions tools/example-validation-harness/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
Copy link
Collaborator

@alan-agius4 alan-agius4 Sep 12, 2025

Choose a reason for hiding this comment

The 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:

const newProjectRoot = temporaryProjectRoot ?? (await createTemporaryProject());
const ngPath = path.join(newProjectRoot, 'node_modules/.bin/ng');

Copy link
Collaborator

@alan-agius4 alan-agius4 Sep 12, 2025

Choose a reason for hiding this comment

The 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 cli_example_db to run the filegroup and runfiles.

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": []
}
}
}
}
}
}
21 changes: 21 additions & 0 deletions tools/example-validation-harness/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 pnpm i in the script?

"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"
}
}
16 changes: 16 additions & 0 deletions tools/example-validation-harness/src/app/app.ts
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 {}
13 changes: 13 additions & 0 deletions tools/example-validation-harness/src/index.html
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>
12 changes: 12 additions & 0 deletions tools/example-validation-harness/src/main.ts
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));
9 changes: 9 additions & 0 deletions tools/example-validation-harness/tsconfig.app.json
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"]
}
29 changes: 29 additions & 0 deletions tools/example-validation-harness/tsconfig.json
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"
}
]
}
2 changes: 1 addition & 1 deletion tools/example_db_generator.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ def cli_example_db(name, srcs, path, out, data = []):
tool = "//tools:ng_example_db",
progress_message = "Generating code example database from %s" % path,
mnemonic = "NgExampleSqliteDb",
args = [path, "$(rootpath %s)" % out],
args = ["--mode generate-db", "--output $(rootpath %s)" % out, path],
)
Loading
Loading