Skip to content

Commit 1f356fc

Browse files
committed
added documentation validation workflow
1 parent 4fac8d5 commit 1f356fc

File tree

3 files changed

+85
-25
lines changed

3 files changed

+85
-25
lines changed

.github/workflows/claude.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,8 @@ jobs:
742742
743743
echo "✅ Both release notes files exist"
744744
745-
# Validate MDX structure
746-
python util/validate_mdx.py "docs/releases/$TAG_NAME.mdx" --tag "$TAG_NAME"
745+
# Validate MDX structure (release notes specific)
746+
python util/validate_mdx.py "docs/releases/$TAG_NAME.mdx" --tag "$TAG_NAME" --release-notes
747747
748748
- name: Update docs.json with new release
749749
env:

.github/workflows/docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Docs Validation
5+
6+
on:
7+
push:
8+
paths:
9+
- 'docs/**'
10+
- 'util/validate_mdx.py'
11+
- '.github/workflows/docs.yml'
12+
pull_request:
13+
paths:
14+
- 'docs/**'
15+
- 'util/validate_mdx.py'
16+
- '.github/workflows/docs.yml'
17+
18+
jobs:
19+
validate:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Validate MDX frontmatter
30+
run: |
31+
echo "Validating MDX frontmatter..."
32+
find docs -name "*.mdx" | xargs python util/validate_mdx.py
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '20'
38+
39+
- name: Install Mintlify CLI
40+
run: npm install -g mintlify
41+
42+
- name: Validate docs with Mintlify
43+
working-directory: docs
44+
run: |
45+
echo "Validating documentation with Mintlify..."
46+
mintlify build
47+
echo "✅ Documentation validated successfully"

util/validate_mdx.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
1414

1515

16-
def validate_mdx(file_path: str, tag: str | None = None) -> list[str]:
16+
def validate_mdx(
17+
file_path: str, tag: str | None = None, release_notes: bool = False
18+
) -> list[str]:
1719
"""
18-
Validate an MDX release notes file.
20+
Validate an MDX file.
1921
2022
Args:
2123
file_path: Path to the MDX file
2224
tag: Optional release tag to validate against (e.g., 'v0.16.0')
25+
release_notes: If True, validate release notes specific requirements
2326
2427
Returns:
2528
List of validation errors (empty if valid)
@@ -49,46 +52,56 @@ def validate_mdx(file_path: str, tag: str | None = None) -> list[str]:
4952
if "description:" not in frontmatter:
5053
errors.append("Missing 'description' in frontmatter")
5154

52-
# Check title matches tag if provided
53-
if tag:
55+
# Check title matches tag if provided (release notes only)
56+
if tag and release_notes:
5457
title_match = re.search(
5558
r'title:\s*["\']?([^"\'\n]+)["\']?', frontmatter
5659
)
5760
if title_match and tag not in title_match.group(1):
5861
errors.append(f"Title should contain '{tag}'")
5962

60-
# Check for required sections
61-
required_sections = ["## Overview", "## What's New", "## Full Changelog"]
62-
for section in required_sections:
63-
if section not in content:
64-
errors.append(f"Missing required section: {section}")
63+
# Release notes specific checks
64+
if release_notes:
65+
required_sections = ["## Overview", "## What's New", "## Full Changelog"]
66+
for section in required_sections:
67+
if section not in content:
68+
errors.append(f"Missing required section: {section}")
6569

66-
# Check for changelog link
67-
if "github.com/amd/gaia/compare/" not in content:
68-
errors.append("Missing changelog comparison link")
70+
if "github.com/amd/gaia/compare/" not in content:
71+
errors.append("Missing changelog comparison link")
6972

7073
return errors
7174

7275

7376
def main():
74-
parser = argparse.ArgumentParser(description="Validate MDX release notes files")
75-
parser.add_argument("file", help="Path to the MDX file to validate")
77+
parser = argparse.ArgumentParser(description="Validate MDX files")
78+
parser.add_argument("file", nargs="+", help="Path(s) to MDX file(s) to validate")
7679
parser.add_argument(
7780
"--tag", "-t", help="Release tag to validate against (e.g., v0.16.0)"
7881
)
82+
parser.add_argument(
83+
"--release-notes",
84+
"-r",
85+
action="store_true",
86+
help="Enable release notes specific validation",
87+
)
7988
args = parser.parse_args()
8089

81-
print(f"Validating {args.file}...")
82-
83-
errors = validate_mdx(args.file, args.tag)
84-
85-
if errors:
86-
print("❌ Validation errors:")
87-
for error in errors:
88-
print(f" - {error}")
90+
all_errors = {}
91+
for file_path in args.file:
92+
print(f"Validating {file_path}...")
93+
errors = validate_mdx(file_path, args.tag, args.release_notes)
94+
if errors:
95+
all_errors[file_path] = errors
96+
97+
if all_errors:
98+
for file_path, errors in all_errors.items():
99+
print(f"❌ {file_path}:")
100+
for error in errors:
101+
print(f" - {error}")
89102
sys.exit(1)
90103

91-
print("✅ MDX validation passed")
104+
print(f"✅ {len(args.file)} file(s) validated successfully")
92105
sys.exit(0)
93106

94107

0 commit comments

Comments
 (0)