Skip to content

Tests to speed up docs #7

Tests to speed up docs

Tests to speed up docs #7

name: Build PR Documentation Faster
on:
pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-builder'
path: doc-builder
ref: main
- uses: actions/checkout@v2
with:
repository: 'huggingface/huggingface_hub'
path: huggingface_hub
- uses: actions/setup-node@v3
with:
node-version: '20'
cache-dependency-path: "kit/package-lock.json"
- name: Set env variables
run: |
if [ -z "${{ inputs.path_to_docs }}" ]
then
echo "doc_folder=huggingface_hub/docs/source" >> $GITHUB_ENV
echo "path_to_docs not provided, defaulting to huggingface_hub/docs/source"
else
echo "doc_folder=${{ inputs.path_to_docs }}" >> $GITHUB_ENV
fi
echo "package_name=huggingface_hub" >> $GITHUB_ENV
# Setup venv
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.
- name: Setup venv + uv
run: |
pip install --upgrade uv
uv venv
- name: Setup environment
shell: bash
run: |
pip uninstall -y doc-builder
cd doc-builder
git pull origin main
uv pip install "hf-doc-builder @ ."
cd ..
cd huggingface_hub
uv pip install "huggingface_hub[dev] @ ."
cd ..
- name: Make documentation
env:
NODE_OPTIONS: --max-old-space-size=6656
shell: bash
run: |
source .venv/bin/activate
echo "doc_folder has been set to ${{ env.doc_folder }}"
cd doc-builder
args="--build_dir ../build_dir --clean --version pr_2140 --repo_owner huggingface --repo_name huggingface_hub --version_tag_suffix=src/"
IFS=', ' read -r -a langs <<< "cn de fr en hi ko"
for lang in "${langs[@]}"
do
echo "Generating docs for language $lang"
doc-builder build ${{ env.package_name }} ../${{ env.doc_folder }}/$lang $args --language $lang
done
cd ..
- name: Save commit_sha & pr_number
run: |
echo ${{ github.event.pull_request.head.sha }} > ./build_dir/commit_sha
echo ${{ github.event.number }} > ./build_dir/pr_number
- uses: actions/upload-artifact@v3
with:
name: doc-build-artifact
path: build_dir/