Skip to content

Commit

Permalink
[DOCS] Enable hosted docs preview (#2803)
Browse files Browse the repository at this point in the history
Enables builds for documentation on every PR

Also optionally will upload this to netlify and generate a preview link
if:

1. This is a PR from the current repo (not a fork) since it needs access
to netlify secrets
2. Some files in `docs/` were modified OR the `documentation` tag is on
the PR

---------

Co-authored-by: Jay Chia <[email protected]@users.noreply.github.com>
  • Loading branch information
jaychia and Jay Chia authored Sep 8, 2024
1 parent 4578e36 commit 045dc05
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
95 changes: 95 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This workflow will build the Daft docs and optionally publishes them to Netlify
# for easy previews.

name: daft-docs

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
docgen:
runs-on: ubuntu-latest
continue-on-error: true
env:
python-version: '3.10'
steps:
- uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
cache: false
- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-build
cache-all-crates: 'true'
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
cache: pip
cache-dependency-path: |
pyproject.toml
requirements-dev.txt
- name: Setup Virtual Env
run: |
python -m venv venv
echo "$GITHUB_WORKSPACE/venv/bin" >> $GITHUB_PATH
pip install uv
- name: Install dependencies
run: |
uv pip install -r requirements-dev.txt
- name: Build Daft in development mode and generate docs
# TODO: Break on any Sphinx warnings
# make html SPHINXOPTS="-W --keep-going -n"
# See: https://stackoverflow.com/questions/38048945/how-to-turn-warnings-into-errors-when-building-sphinx-documentation-with-setupto
run: |
source activate
maturin develop
cd docs/
make html
- name: Upload built docs
uses: actions/upload-artifact@v4
with:
name: html-docs
path: docs/build/html
docpublish:
runs-on: ubuntu-latest
needs: docgen
# Only publish to netlify on:
# 1. If the previous doc building step didn't fail
# 2. If this is a PR from the current repo (since it needs access to secrets)
# 3. If some of the documentation files changed or it has the `documentation` label
if: |
${{ success() }} &&
github.event.pull_request != null &&
github.event.pull_request.head.repo.full_name == github.repository &&
(
contains(github.event.pull_request.changed_files, 'docs/') ||
contains(github.event.pull_request.labels.*.name, 'documentation')
)
steps:
- name: Download built HTML docs
uses: actions/download-artifact@v4
with:
name: html-docs
path: ./built_html
- name: Add a robots.txt to disable indexing of docs
run: |
echo "User-agent: *" > ./built_html/robots.txt
echo "Disallow: /" >> ./built_html/robots.txt
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: ./built_html
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: Deploy from GitHub Actions
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
1 change: 0 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ jobs:
maturin develop
pytest --doctest-modules --continue-on-collection-errors daft/dataframe/dataframe.py daft/expressions/expressions.py daft/convert.py daft/udf.py
publish-coverage-reports:
name: Publish coverage reports to CodeCov
runs-on: ubuntu-latest
Expand Down

0 comments on commit 045dc05

Please sign in to comment.