Skip to content

Commit 386ffb3

Browse files
committed
Use new mint validated command to detect parsing errors
This will replace brittle logic for running mint dev and then waiting for 45 seconds before checking the redirected logs for parsing errors. This logic runs in both fork PRs and non-fork PRs.
1 parent 4303808 commit 386ffb3

2 files changed

Lines changed: 18 additions & 56 deletions

File tree

.github/workflows/validate-mdx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828
restore-keys: |
2929
${{ runner.os }}-mintlify-
3030
- name: Install Mintlify CLI
31-
run: npm install -g mintlify
31+
run: npm install -g mint
3232
- name: Validate MDX with Mintlify
3333
run: ./scripts/mdx-validation/validate-mdx-mintlify.sh
Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
#!/bin/bash
22
set -e
33

4-
LOGFILE="/tmp/mint-dev-$$.log"
5-
PARSE_TIME=45 # Give Mintlify time to log parsing errors
6-
PID=""
7-
8-
# Cleanup function
9-
cleanup() {
10-
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
11-
kill "$PID" 2>/dev/null || true
12-
sleep 0.5
13-
kill -9 "$PID" 2>/dev/null || true
14-
fi
15-
rm -f "$LOGFILE"
16-
}
17-
18-
# Trap to ensure cleanup
19-
trap cleanup EXIT INT TERM
20-
214
# Check if there are any MDX files in the changeset
225
if [ -n "$GITHUB_BASE_REF" ]; then
236
# In a PR context, check changed files
@@ -40,53 +23,31 @@ if [ -n "$GITHUB_BASE_REF" ]; then
4023
echo ""
4124
fi
4225

43-
echo "Starting Mintlify validation..."
44-
echo ""
45-
echo "Running: mint dev --no-open (will run for ${PARSE_TIME}s to parse all files)"
46-
echo ""
47-
48-
# Run mint dev with tee to force output writing, timeout after PARSE_TIME seconds
49-
# Use timeout if available (Linux), otherwise use gtimeout (macOS with coreutils), or perl as fallback
50-
if command -v timeout > /dev/null 2>&1; then
51-
timeout --preserve-status ${PARSE_TIME}s mint dev --no-open 2>&1 | tee "$LOGFILE" > /dev/null || true
52-
elif command -v gtimeout > /dev/null 2>&1; then
53-
gtimeout --preserve-status ${PARSE_TIME}s mint dev --no-open 2>&1 | tee "$LOGFILE" > /dev/null || true
54-
else
55-
# Fallback: run mint dev in background and kill after PARSE_TIME
56-
mint dev --no-open 2>&1 | tee "$LOGFILE" > /dev/null &
57-
PID=$!
58-
sleep ${PARSE_TIME}
59-
kill "$PID" 2>/dev/null || true
60-
wait "$PID" 2>/dev/null || true
61-
fi
62-
63-
echo ""
64-
echo "✓ Mintlify finished parsing"
26+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
27+
echo "VALIDATING DOCUMENTATION BUILD"
28+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
29+
echo "Running: mint validate"
6530
echo ""
6631

67-
# Check for parsing errors
68-
if grep -q "parsing error" "$LOGFILE"; then
32+
# Run mint validate - exits with non-zero if there are any errors or warnings
33+
if mint validate; then
34+
echo ""
6935
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
70-
echo " MINTLIFY PARSING ERRORS DETECTED"
36+
echo " MINTLIFY VALIDATION PASSED"
7137
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
72-
echo ""
73-
echo "Parsing errors found:"
74-
echo ""
75-
grep "parsing error" "$LOGFILE" | sed 's/^/ /'
38+
echo "No errors or warnings detected"
39+
else
7640
echo ""
7741
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
78-
echo "💡 These are Mintlify parsing errors. Please fix them or"
79-
echo " file an issue if you believe they are incorrect:"
80-
echo " https://github.com/wandb/docs/issues/new"
42+
echo "❌ MINTLIFY VALIDATION FAILED"
43+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
44+
echo "Errors or warnings were detected. Please fix them or"
45+
echo "file an issue if you believe they are incorrect:"
46+
echo "https://github.com/wandb/docs/issues/new"
8147
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
82-
echo ""
8348
exit 1
8449
fi
8550

86-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
87-
echo "✅ MINTLIFY PARSING VALIDATION PASSED"
88-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
89-
echo "No parsing errors detected by Mintlify"
9051
echo ""
9152

9253
# Run broken links check
@@ -110,10 +71,11 @@ else
11071
echo "Please fix the broken links reported above"
11172
exit 1
11273
fi
74+
11375
echo ""
11476
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
11577
echo "✅ ALL VALIDATION CHECKS PASSED"
11678
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
117-
echo "- No parsing errors"
79+
echo "- No validation errors or warnings"
11880
echo "- No broken links"
11981
exit 0

0 commit comments

Comments
 (0)