Skip to content

Commit 3d258b2

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 `validate_examples.js` and `example_db_generator.js` scripts have 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 ff54b98 commit 3d258b2

7 files changed

Lines changed: 409 additions & 204 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
run: pnpm admin validate
4040
- name: Check tooling setup
4141
run: pnpm check-tooling-setup
42+
- name: Validate Example Markdown Structure
43+
run: pnpm bazel run //tools:validate_examples_structure
44+
- name: Validate Example Code Compilation
45+
run: pnpm bazel run //tools:validate_examples_code
4246

4347
build:
4448
runs-on: ubuntu-latest

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"listr2": "9.0.3",
125125
"lodash": "^4.17.21",
126126
"magic-string": "0.30.19",
127+
"marked": "^16.2.1",
127128
"npm": "^11.0.0",
128129
"prettier": "^3.0.0",
129130
"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 & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)