From 714d98539fc51cf8c0bcd261c00c6c119d657c87 Mon Sep 17 00:00:00 2001 From: Santhil Kherwal <72144927+santhil-cyber@users.noreply.github.com> Date: Sat, 28 Feb 2026 00:08:48 +0530 Subject: [PATCH] ci: add GitHub Actions workflow for documentation build and deploy Add a CI/CD workflow that: - Builds Sphinx documentation on every push and PR to main - Validates with -W (warnings as errors) and linkcheck - Deploys to GitHub Pages on merge to main - Uses path filters to only trigger on docs/ or neural_lam/ changes - Installs graphviz for inheritance diagram rendering Also adds docs/requirements.txt with minimal Sphinx dependencies. Relates to #61 --- .github/workflows/docs.yml | 88 ++++++++++++++++++++++++++++++++++++++ docs/requirements.txt | 7 +++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100644 docs/requirements.txt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..f6b67bcc4 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,88 @@ +# Build and deploy documentation using Sphinx +# +# On pull requests: builds docs to verify they compile without errors. +# On pushes to main: builds and deploys to GitHub Pages. +# +# This workflow is documentation-tooling agnostic — it runs whichever +# Sphinx build is configured in docs/conf.py. If the project switches +# to Jupyter Book or another Sphinx-based tool, only the install step +# and build command need updating. +name: Documentation + +on: + push: + branches: [main] + paths: + - "docs/**" + - "neural_lam/**" + - ".github/workflows/docs.yml" + pull_request: + branches: [main] + paths: + - "docs/**" + - "neural_lam/**" + - ".github/workflows/docs.yml" + +# Allow only one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: false + +permissions: + contents: read + pages: write + id-token: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v6 + with: + python-version: "3.12" + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y graphviz + + - name: Install neural-lam and doc dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e . + python -m pip install -r docs/requirements.txt + + - name: Build documentation + working-directory: docs + run: | + sphinx-build -b html . _build/html -W --keep-going -n + env: + MPLBACKEND: Agg + + - name: Check for broken links + working-directory: docs + continue-on-error: true + run: | + sphinx-build -b linkcheck . _build/linkcheck + + - name: Upload documentation artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: docs/_build/html + + deploy: + needs: build + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..d45634673 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,7 @@ +# Documentation build dependencies +# Install with: pip install -r docs/requirements.txt +sphinx>=7.0 +pydata-sphinx-theme>=0.15 +sphinx-autoapi>=3.0 +numpydoc>=1.6 +sphinx-copybutton>=0.5