Skip to content

Commit b7582d9

Browse files
committed
Add link validation script to CI
Add a new link validator script (dist/validate-links.sh) that scans markdown files for internal /docs/ and /cn/docs/ links and verifies target pages exist. Integrate the checker into the Hugo GitHub Actions workflow (.github/workflows/hugo.yml) so links are validated during CI. Fix several documentation links in both English and Chinese introduction pages to the correct /docs/quickstart/hugegraph/... path. Remove the obsolete DISCLAIMER file and tweak dist/README wording. Also add a TODO note in dist/validate-release.sh regarding TLP graduation and ASF infra migration.
1 parent ee176b5 commit b7582d9

7 files changed

Lines changed: 72 additions & 10 deletions

File tree

.github/workflows/hugo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
restore-keys: |
4141
${{ runner.os }}-hugomod-
4242
43+
- name: Check Links
44+
run: bash dist/validate-links.sh
45+
4346
- name: Build Site (minify)
4447
run: npm i && hugo --minify
4548

DISCLAIMER

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

content/cn/docs/introduction/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ HugeGraph 支持多种部署模式,满足不同规模和场景的需求:
5050

5151
| 使用场景 | 推荐路径 |
5252
|---------|---------|
53-
| 快速体验 | [Docker 部署](/cn/docs/quickstart/hugegraph-server/hugegraph-server#docker) |
53+
| 快速体验 | [Docker 部署](/cn/docs/quickstart/hugegraph/hugegraph-server#docker) |
5454
| 构建 OLTP 应用 | Server → REST API / Gremlin / Cypher |
5555
| 图分析 (OLAP) | [Vermeer](/cn/docs/quickstart/computing/hugegraph-computer) (推荐) 或 Computer |
5656
| 构建 AI 应用 | [HugeGraph-AI](/cn/docs/quickstart/hugegraph-ai) (GraphRAG/知识图谱) |

content/en/docs/introduction/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ HugeGraph supports multiple deployment modes to meet different scales and scenar
3535
- Server + RocksDB backend storage
3636
- Suitable for development, testing, and small-to-medium scale data (< 4TB)
3737
- Docker quick start: `docker run hugegraph/hugegraph`
38-
- See [Server Quickstart](/docs/quickstart/hugegraph-server/hugegraph-server)
38+
- See [Server Quickstart](/docs/quickstart/hugegraph/hugegraph-server)
3939

4040
**Distributed Mode**
4141
- HugeGraph-PD: Metadata management and cluster scheduling

dist/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Apache HugeGraph 发版验证脚本
22

3-
Apache HugeGraph (Incubating) 发布包的自动化验证脚本。
3+
Apache HugeGraph 发布包的自动化验证脚本。
44

55
## 概述
66

dist/validate-links.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# Configuration
4+
CONTENT_DIR="content"
5+
EXIT_CODE=0
6+
7+
echo "Starting link validation..."
8+
9+
# Find all markdown files and verify links
10+
while read -r FILE; do
11+
# Extract internal links starting with /docs/ or /cn/docs/
12+
# We look for [text](url) pattern where url starts with /docs/ or /cn/docs/
13+
# Using grep to find all matching links in the file
14+
while read -r MATCH; do
15+
if [ -z "$MATCH" ]; then continue; fi
16+
17+
# Extract URL from ](url)
18+
LINK=${MATCH#*](}
19+
LINK=${LINK%)}
20+
21+
# Remove anchor and query parameters
22+
CLEAN_LINK=$(echo "$LINK" | cut -d'#' -f1 | cut -d'?' -f1)
23+
24+
# Determine target file path based on language prefix
25+
if [[ "$CLEAN_LINK" == /docs/* ]]; then
26+
TARGET_PATH="content/en${CLEAN_LINK}"
27+
elif [[ "$CLEAN_LINK" == /cn/docs/* ]]; then
28+
TARGET_PATH="content${CLEAN_LINK}"
29+
else
30+
continue
31+
fi
32+
33+
# Check for file existence variations
34+
FOUND=false
35+
36+
# Check 1: As .md file
37+
if [[ -f "${TARGET_PATH}.md" ]]; then
38+
FOUND=true
39+
# Check 2: Exact file (if extension was included)
40+
elif [[ -f "$TARGET_PATH" ]]; then
41+
FOUND=true
42+
# Check 3: Directory index
43+
elif [[ -f "${TARGET_PATH}/_index.md" ]]; then
44+
FOUND=true
45+
# Check 4: Directory README (legacy)
46+
elif [[ -f "${TARGET_PATH}/README.md" ]]; then
47+
FOUND=true
48+
fi
49+
50+
if [ "$FOUND" = false ]; then
51+
echo "Error: Broken link in $FILE"
52+
echo " Link: $LINK"
53+
echo " Target: $TARGET_PATH (and variants)"
54+
EXIT_CODE=1
55+
fi
56+
done < <(grep -oE '\]\((/docs/|/cn/docs/)[^)]+\)' "$FILE")
57+
done < <(find "$CONTENT_DIR" -type f -name "*.md")
58+
59+
if [ $EXIT_CODE -eq 0 ]; then
60+
echo "Link validation passed!"
61+
else
62+
echo "Link validation failed!"
63+
fi
64+
65+
exit $EXIT_CODE

dist/validate-release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
# TODO: Update for TLP graduation after ASF infra migration is complete.
23
################################################################################
34
# Apache HugeGraph Release Validation Script
45
################################################################################

0 commit comments

Comments
 (0)