Skip to content

Set fail on warning for documentation generation #1381

Set fail on warning for documentation generation

Set fail on warning for documentation generation #1381

Workflow file for this run

on:
push:
branches:
- main
tags-ignore:
- "**-rc**"
pull_request:
branches:
- main
# Run after build workflow completes so we can get the built artifact
workflow_run:
workflows: ["Python Release Build"]
types:
- completed
name: Deploy DataFusion Python site
jobs:
debug-github-context:
name: Print github context
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
build-docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Set target branch
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
id: target-branch
run: |
set -x
if test '${{ github.ref }}' = 'refs/heads/main'; then
echo "value=asf-staging" >> "$GITHUB_OUTPUT"
elif test '${{ github.ref_type }}' = 'tag'; then
echo "value=asf-site" >> "$GITHUB_OUTPUT"
else
echo "Unsupported input: ${{ github.ref }} / ${{ github.ref_type }}"
exit 1
fi
- name: Checkout docs sources
uses: actions/checkout@v5
- name: Checkout docs target branch
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ steps.target-branch.outputs.value }}
path: docs-target
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
# Try to download pre-built wheel from the build workflow
- name: Download wheel from build workflow
id: download-wheel
continue-on-error: true
uses: actions/download-artifact@v5
with:
name: dist
path: wheels/
# For workflow_run events, get artifacts from the triggering workflow
run-id: ${{ github.event.workflow_run.id || github.run_id }}
# Check if we have a compatible wheel
- name: Check for compatible wheel
id: check-wheel
run: |
set -x
if [ -d "wheels/" ] && [ "$(ls -A wheels/)" ]; then
echo "Available wheels:"
ls -la wheels/
# Find a compatible wheel for Linux x86_64 (the docs runner)
WHEEL=$(find wheels/ -name "*linux_x86_64*.whl" -o -name "*manylinux*x86_64*.whl" | head -1)
if [ -n "$WHEEL" ]; then
echo "Found compatible wheel: $WHEEL"
echo "wheel-found=true" >> "$GITHUB_OUTPUT"
echo "wheel-path=$WHEEL" >> "$GITHUB_OUTPUT"
else
echo "No compatible wheel found for Linux x86_64"
echo "wheel-found=false" >> "$GITHUB_OUTPUT"
fi
else
echo "No wheels directory or wheels found"
echo "wheel-found=false" >> "$GITHUB_OUTPUT"
fi
# Install from pre-built wheel if available
- name: Install from pre-built wheel
if: steps.check-wheel.outputs.wheel-found == 'true'
run: |
set -x
uv venv
# Install documentation dependencies
uv sync --dev --no-install-package datafusion --group docs
# Install the pre-built wheel
uv pip install "${{ steps.check-wheel.outputs.wheel-path }}"
echo "Installed datafusion from pre-built wheel"
# Fallback: Build from source if no wheel is available
- name: Build from source (fallback)
if: steps.check-wheel.outputs.wheel-found != 'true'
run: |
set -x
echo "No compatible pre-built wheel found, building from source"
# Install Protoc for building from source
sudo apt-get update
sudo apt-get install -y protobuf-compiler
uv venv
uv sync --dev --no-install-package datafusion --group docs
uv run --no-project maturin develop --uv
- name: Build docs
run: |
set -x
cd docs
curl -O https://gist.githubusercontent.com/ritchie46/cac6b337ea52281aa23c049250a4ff03/raw/89a957ff3919d90e6ef2d34235e6bf22304f3366/pokemon.csv
curl -O https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2021-01.parquet
uv run --no-project make html
- name: Copy & push the generated HTML
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
run: |
set -x
cd docs-target
# delete anything but: 1) '.'; 2) '..'; 3) .git/
find ./ | grep -vE "^./$|^../$|^./.git" | xargs rm -rf
cp ../.asf.yaml .
cp -r ../docs/build/html/* .
git status --porcelain
if [ "$(git status --porcelain)" != "" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m 'Publish built docs triggered by ${{ github.sha }}'
git push || git push --force
fi