Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/check_docs_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Check the Documentation Build
on:
pull_request:
types: [opened, synchronize]
workflow_call:
workflow_dispatch:

permissions:
Expand All @@ -13,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
fetch-depth: 0
Expand Down Expand Up @@ -54,8 +55,6 @@ jobs:
. $GITHUB_WORKSPACE/venv/bin/activate
uv pip install -e . --no-deps
uv pip install torch
# verify links; the build fails if errors are found
sphinx-build -b linkcheck docs docs/_build/linkcheck -q --keep-going
# generates the actual website
sphinx-build -b html docs docs/_build/html
env:
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/linkcheck.yml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also run check_docs_build.yml and linkcheck.yml before publish_maxtext_package_to_pypi job here: https://github.com/AI-Hypercomputer/maxtext/blob/main/.github/workflows/pypi_release.yml#L46?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

name: Documentation Link Checker

on:
schedule:
# Run every Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
workflow_call:
workflow_dispatch: # Allow manual triggering

permissions:
contents: read
issues: write

jobs:
linkcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
fetch-depth: 0

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c # v7.0.0
with:
python-version: '3.12'
enable-cache: true

- name: Set venv
run: uv venv --python 3.12 $GITHUB_WORKSPACE/venv

- name: Install dependencies
run: . $GITHUB_WORKSPACE/venv/bin/activate && uv pip install -r src/dependencies/requirements/requirements_docs.txt

- name: Run Sphinx linkcheck
id: linkcheck
continue-on-error: true
run: |
. $GITHUB_WORKSPACE/venv/bin/activate
sphinx-build -b linkcheck docs docs/_build/linkcheck -q --keep-going
echo "exit_code=$?" >> $GITHUB_OUTPUT

- name: Prepare issue body
if: steps.linkcheck.outcome == 'failure'
run: |
DATE=$(date +%Y-%m-%d)
echo "ISSUE_DATE=$DATE" >> $GITHUB_ENV

cat > issue-body.md << 'EOF'
## Documentation Link Check Failed

The weekly documentation link checker has detected broken links.

**Workflow Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

### Broken Links Report

EOF

if [ -f docs/_build/linkcheck/output.txt ]; then
echo '```' >> issue-body.md
cat docs/_build/linkcheck/output.txt >> issue-body.md
echo '```' >> issue-body.md
else
echo 'No output file generated.' >> issue-body.md
fi

echo '' >> issue-body.md
echo 'Please review and fix the broken links in the documentation.' >> issue-body.md

- name: Create issue for broken links
if: steps.linkcheck.outcome == 'failure'
uses: peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6.0.0
with:
title: Documentation Link Check Failed - ${{ env.ISSUE_DATE }}
content-filepath: ./issue-body.md
labels: |
documentation
13 changes: 12 additions & 1 deletion .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ jobs:
needs: [release_approval]
uses: ./.github/workflows/build_and_test_maxtext.yml
secrets: inherit


build_docs:
name: Build Documentation
needs: [build_and_test_maxtext_package]
uses: ./.github/workflows/check_docs_build.yml
secrets: inherit

check_links:
name: Check Links in Documentation
uses: ./.github/workflows/linkcheck.yml
secrets: inherit

publish_maxtext_package_to_pypi:
name: Publish MaxText package to PyPI
needs: [build_and_test_maxtext_package]
Expand Down
Loading