Skip to content

Allow the widget to reach the chat backend on 0g.ai in the CSP (#391) #391

Allow the widget to reach the chat backend on 0g.ai in the CSP (#391)

Allow the widget to reach the chat backend on 0g.ai in the CSP (#391) #391

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
# Version comes from package.json's "packageManager" field — don't also
# set `version` here or action-setup errors with ERR_PNPM_BAD_PM_VERSION.
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint code
run: |
if [ -f "package.json" ] && grep -q '"lint"' package.json; then
pnpm lint
else
echo "No lint script found, skipping..."
fi
- name: Type check
run: |
if [ -f "tsconfig.json" ]; then
npx tsc --noEmit
else
echo "No TypeScript config found, skipping type check..."
fi
- name: Retired phrases
run: |
# Positioning language that must not come back. Hard-coded until the
# brand canon file exists; keep in sync with the marketing kill list.
# "Aristotle" is deliberately not here: it is the mainnet release name.
PATTERN='decentralized AI operating system|deAIOS|modular AI blockchain|fastest modular|modular AI stack'
if grep -rniE "$PATTERN" docs docusaurus.config.ts --include='*.md' --include='*.mdx' --include='*.ts'; then
echo "::error::retired phrase found (see matches above); use the approved wording"
exit 1
fi
echo "No retired phrases."
- name: Build documentation
run: pnpm build
- name: Test build output
run: |
if [ ! -d "build" ]; then
echo "Build directory not found!"
exit 1
fi
if [ ! -f "build/index.html" ]; then
echo "Index.html not found in build directory!"
exit 1
fi
echo "Build successful ✅"
# Reuses the build/ directory from the step above — keep this in the same
# job so the site isn't built twice.
- name: Serve site and check links
run: |
# Mirror Vercel routing locally: cleanUrls + redirects from vercel.json
# (serve rejects the $schema field and the `has` header directive, so strip both)
jq 'del(.["$schema"]) | .headers |= map(select(.has == null))' vercel.json > /tmp/serve.json
npx --yes serve build -p 3000 -c /tmp/serve.json > /tmp/serve.log 2>&1 &
SERVER_PID=$!
# Wait for serve to accept connections
for i in $(seq 1 30); do
curl -sf -o /dev/null http://localhost:3000/ && break
sleep 1
done
BLC_OUT=$(npx --yes --package broken-link-checker blc http://localhost:3000 --recursive --exclude-external 2>&1 || true)
BROKEN=$(echo "$BLC_OUT" | grep -c "BROKEN" || true)
UNIQUE=$(echo "$BLC_OUT" | grep "BROKEN" | sort -u || true)
{
echo "## 🔗 Link Checker Results"
echo ""
echo "**Broken internal links: $BROKEN**"
if [ "$BROKEN" -gt 0 ]; then
echo ""
echo "<details><summary>Show broken links</summary>"
echo ""
echo '```'
echo "$UNIQUE"
echo '```'
echo ""
echo "</details>"
fi
} >> "$GITHUB_STEP_SUMMARY"
# The HTML crawler never opens llms.txt (no page links to it), so check
# every URL it lists against the served build explicitly.
LLMS_FAIL=0
LLMS_LINKS=$(grep -c '^- \[' build/llms.txt 2>/dev/null || echo 0)
LLMS_SOURCES=$(grep -c '^Source: ' build/llms-full.txt 2>/dev/null || echo 0)
if [ "$LLMS_LINKS" -lt 80 ]; then echo "::error::llms.txt has only $LLMS_LINKS links"; LLMS_FAIL=1; fi
if [ "$LLMS_SOURCES" -ne $((LLMS_LINKS - 4)) ]; then echo "::error::llms-full.txt has $LLMS_SOURCES Source lines for $((LLMS_LINKS - 4)) pages"; LLMS_FAIL=1; fi
while read -r url; do
path="${url#https://docs.0g.ai}"
code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:3000${path}")
if [ "$code" != "200" ]; then echo "::error::llms.txt link $url -> $code"; LLMS_FAIL=1; fi
done < <(grep -o 'https://docs\.0g\.ai[^) ,]*' build/llms.txt | grep -v '^https://docs\.0g\.ai$' | sort -u)
[ "$LLMS_FAIL" = 0 ] && echo "All llms.txt links resolve on the built site."
kill $SERVER_PID 2>/dev/null || true
if [ "$LLMS_FAIL" != 0 ]; then
echo "::error::llms.txt contains links that do not resolve"
exit 1
fi
if [ "$BROKEN" -gt 0 ]; then
echo "::error::$BROKEN broken internal links found"
exit 1
fi
spell-check:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Spell check
uses: streetsidesoftware/cspell-action@v6
with:
files: |
**/*.md
**/*.mdx
docs/**/*.md
config: .cspell.json
incremental_files_only: false