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

Skip to content

Commit f1726d0

Browse files
committed
test(@angular/cli): add CI validation for MCP example code
This commit introduces a new CI check to validate the correctness of code snippets and markdown structure within the `find_examples` markdown files. To support this, the previous the `example_db_generator.js` script has been refactored and consolidated into a single, unified, mode-driven script: `process_examples.mjs`. This improves maintainability and ensures consistent parsing and validation logic. The new script provides two new validation modes for CI: - `validate-structure`: Parses all examples to validate their front matter and ensure they adhere to the required markdown heading structure. - `validate-code`: Uses a pre-built Angular application harness to perform a full `ng build` on all example code, ensuring compilation and template correctness. This provides a strong guarantee of the quality and reliability of the code and structure of all examples served by the `find_examples` tool.
1 parent 0e9d54a commit f1726d0

File tree

7 files changed

+408
-211
lines changed

7 files changed

+408
-211
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
uses: angular/dev-infra/github-actions/linting/licenses@5043638fd8529765b375831a4679b9013141b326
6060
- name: Check tooling setup
6161
run: pnpm check-tooling-setup
62+
- name: Validate MCP Example Markdown
63+
run: pnpm check-mcp-examples
6264
- name: Check commit message
6365
# Commit message validation is only done on pull requests as its too late to validate once
6466
# it has been merged.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"public-api:update": "node goldens/public-api/manage.js accept",
2727
"ts-circular-deps": "pnpm -s ng-dev ts-circular-deps --config ./scripts/circular-deps-test.conf.mjs",
2828
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json",
29+
"check-mcp-examples": "node tools/process_examples.mjs packages/angular/cli/lib/examples --mode validate-structure",
2930
"diff-release-package": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/diff-release-package.mts"
3031
},
3132
"repository": {
@@ -124,6 +125,7 @@
124125
"listr2": "9.0.3",
125126
"lodash": "^4.17.21",
126127
"magic-string": "0.30.19",
128+
"marked": "^16.2.1",
127129
"npm": "^11.0.0",
128130
"prettier": "^3.0.0",
129131
"protractor": "~7.0.0",

pnpm-lock.yaml

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ js_binary(
3434
js_binary(
3535
name = "ng_example_db",
3636
data = [
37-
"example_db_generator.js",
37+
"process_examples.mjs",
38+
"//:node_modules/marked",
3839
"//:node_modules/zod",
3940
],
40-
entry_point = "example_db_generator.js",
41+
entry_point = "process_examples.mjs",
4142
)

tools/example_db_generator.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def cli_example_db(name, srcs, path, out, data = []):
88
tool = "//tools:ng_example_db",
99
progress_message = "Generating code example database from %s" % path,
1010
mnemonic = "NgExampleSqliteDb",
11-
args = [path, "$(rootpath %s)" % out],
11+
args = ["--mode generate-db", "--output $(rootpath %s)" % out, path],
1212
)

tools/example_db_generator.js

Lines changed: 0 additions & 207 deletions
This file was deleted.

0 commit comments

Comments
 (0)