Use templates (#16142)
* Use tempaltes for all doc building jobs * Add this branch to the doc build * Switch to main branch
This commit is contained in:
116
.github/workflows/build_dev_documentation.yml
vendored
116
.github/workflows/build_dev_documentation.yml
vendored
@@ -1,116 +0,0 @@
|
|||||||
name: Build dev documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_package:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: huggingface/transformers-doc-builder
|
|
||||||
env:
|
|
||||||
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
|
||||||
PR_NUMBER: ${{ github.event.number }}
|
|
||||||
EVENT_CONTEXT: ${{ toJSON(github.event) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/doc-builder'
|
|
||||||
path: doc-builder
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/transformers'
|
|
||||||
path: transformers
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/notebooks'
|
|
||||||
path: notebooks
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
|
|
||||||
- name: Set env
|
|
||||||
run: |
|
|
||||||
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Setup environment
|
|
||||||
run: |
|
|
||||||
rm -rf doc-build-dev
|
|
||||||
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
|
|
||||||
|
|
||||||
pip uninstall -y doc-builder
|
|
||||||
cd doc-builder
|
|
||||||
git pull origin main
|
|
||||||
pip install -e .
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
cd transformers
|
|
||||||
pip install .[dev]
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
cd notebooks
|
|
||||||
git pull origin master
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
- name: Setup git
|
|
||||||
run: |
|
|
||||||
git config --global user.name "Hugging Face Doc Builder"
|
|
||||||
git config --global user.email docs@huggingface.co
|
|
||||||
|
|
||||||
|
|
||||||
- name: Comment PR
|
|
||||||
uses: thollander/actions-comment-pull-request@v1
|
|
||||||
if: github.event.action == 'opened'
|
|
||||||
|
|
||||||
with:
|
|
||||||
message: 'The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.'
|
|
||||||
GITHUB_TOKEN: ${{ env.WRITE }}
|
|
||||||
|
|
||||||
- name: Find Comment
|
|
||||||
if: github.event.action == 'reopened'
|
|
||||||
uses: peter-evans/find-comment@v1
|
|
||||||
id: fc
|
|
||||||
with:
|
|
||||||
issue-number: ${{ env.PR_NUMBER }}
|
|
||||||
comment-author: HuggingFaceDocBuilderDev
|
|
||||||
|
|
||||||
- name: Update comment
|
|
||||||
if: github.event.action == 'reopened'
|
|
||||||
uses: peter-evans/create-or-update-comment@v1
|
|
||||||
with:
|
|
||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
||||||
token: ${{ env.WRITE }}
|
|
||||||
edit-mode: replace
|
|
||||||
body: |
|
|
||||||
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.
|
|
||||||
|
|
||||||
- name: Make documentation
|
|
||||||
env:
|
|
||||||
NODE_OPTIONS: --max-old-space-size=6656
|
|
||||||
run: |
|
|
||||||
doc-builder build transformers transformers/docs/source --build_dir build_dir --clean --version pr_$PR_NUMBER --html
|
|
||||||
|
|
||||||
- name: Push to repositories
|
|
||||||
run: |
|
|
||||||
cd doc-build-dev
|
|
||||||
git pull
|
|
||||||
rm -rf transformers/pr_$PR_NUMBER
|
|
||||||
mv ../build_dir/transformers/pr_$PR_NUMBER transformers/pr_$PR_NUMBER
|
|
||||||
git status
|
|
||||||
|
|
||||||
if [[ `git status --porcelain` ]]; then
|
|
||||||
git add .
|
|
||||||
git commit -m "Updated with commit $COMMIT_SHA See: https://github.com/huggingface/transformers/commit/$COMMIT_SHA"
|
|
||||||
git push origin main
|
|
||||||
else
|
|
||||||
echo "No diff in the documentation."
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
128
.github/workflows/build_documentation.yml
vendored
128
.github/workflows/build_documentation.yml
vendored
@@ -4,126 +4,16 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- doc_builder*
|
|
||||||
- doc-builder*
|
- doc-builder*
|
||||||
- v*-release
|
- v*-release
|
||||||
|
- use_templates
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_package:
|
build:
|
||||||
runs-on: ubuntu-latest
|
uses: huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main
|
||||||
defaults:
|
with:
|
||||||
run:
|
commit_sha: ${{ github.sha }}
|
||||||
shell: bash -l {0}
|
package: transformers
|
||||||
|
notebook_folder: transformers_doc
|
||||||
steps:
|
secrets:
|
||||||
- uses: actions/setup-node@v2
|
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
||||||
with:
|
|
||||||
node-version: '16'
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/doc-builder'
|
|
||||||
path: doc-builder
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/doc-build'
|
|
||||||
path: doc-build
|
|
||||||
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/transformers'
|
|
||||||
path: transformers
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: 'huggingface/notebooks'
|
|
||||||
path: notebooks
|
|
||||||
token: ${{ secrets.HUGGINGFACE_PUSH }}
|
|
||||||
|
|
||||||
- name: Loading cache.
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: cache
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: v1-test_build_doc
|
|
||||||
restore-keys: |
|
|
||||||
v1-test_build_doc-${{ hashFiles('setup.py') }}
|
|
||||||
v1-test_build_doc
|
|
||||||
|
|
||||||
- name: Setup environment
|
|
||||||
run: |
|
|
||||||
sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
|
|
||||||
|
|
||||||
pip install git+https://github.com/huggingface/doc-builder
|
|
||||||
cd transformers
|
|
||||||
pip install .[dev]
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
export TORCH_VERSION=$(python -c "from torch import version; print(version.__version__.split('+')[0])")
|
|
||||||
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH_VERSION}+cpu.html
|
|
||||||
|
|
||||||
pip install torchvision
|
|
||||||
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
|
|
||||||
|
|
||||||
sudo apt install tesseract-ocr
|
|
||||||
pip install pytesseract
|
|
||||||
pip install pytorch-quantization --extra-index-url https://pypi.ngc.nvidia.com
|
|
||||||
pip install https://github.com/kpu/kenlm/archive/master.zip
|
|
||||||
|
|
||||||
- name: Setup git
|
|
||||||
run: |
|
|
||||||
git config --global user.name "Hugging Face Doc Builder"
|
|
||||||
git config --global user.email docs@huggingface.co
|
|
||||||
|
|
||||||
- name: Create build directory
|
|
||||||
run: |
|
|
||||||
cd doc-build
|
|
||||||
git pull
|
|
||||||
cd ..
|
|
||||||
mkdir build_dir
|
|
||||||
mkdir build_dir/transformers
|
|
||||||
cp doc-build/transformers/_versions.yml build_dir/transformers
|
|
||||||
|
|
||||||
- name: Make documentation
|
|
||||||
run: |
|
|
||||||
cd doc-builder &&
|
|
||||||
doc-builder build transformers ../transformers/docs/source --build_dir ../build_dir --notebook_dir ../notebooks_dir --clean --html &&
|
|
||||||
cd ..
|
|
||||||
env:
|
|
||||||
NODE_OPTIONS: --max-old-space-size=6656
|
|
||||||
|
|
||||||
- name: Push to repositories
|
|
||||||
run: |
|
|
||||||
cd doc-build
|
|
||||||
git pull
|
|
||||||
mv ../build_dir/transformers/_versions.yml transformers/
|
|
||||||
rm -rf transformers/$(ls ../build_dir/transformers)
|
|
||||||
mv ../build_dir/transformers/$(ls ../build_dir/transformers) transformers/$(ls ../build_dir/transformers)
|
|
||||||
git status
|
|
||||||
|
|
||||||
if [[ `git status --porcelain` ]]; then
|
|
||||||
git add .
|
|
||||||
git commit -m "Updated with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/transformers/commit/${{ github.sha }}"
|
|
||||||
git push origin main
|
|
||||||
else
|
|
||||||
echo "No diff in the documentation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
cd notebooks
|
|
||||||
git pull
|
|
||||||
cp -r ../notebooks_dir/. transformers_doc/
|
|
||||||
git status
|
|
||||||
|
|
||||||
if [[ `git status --porcelain` ]]; then
|
|
||||||
git add transformers_doc
|
|
||||||
git commit -m "Updated Transformer doc notebooks with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/transformers/commit/${{ github.sha }}" &&
|
|
||||||
git push origin master
|
|
||||||
else
|
|
||||||
echo "No diff in the notebooks."
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|||||||
16
.github/workflows/build_pr_documentation.yml
vendored
Normal file
16
.github/workflows/build_pr_documentation.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: Build PR Documentation
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
uses: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml@main
|
||||||
|
with:
|
||||||
|
commit_sha: ${{ github.event.pull_request.head.sha }}
|
||||||
|
pr_number: ${{ github.event.number }}
|
||||||
|
package: transformers
|
||||||
63
.github/workflows/delete_dev_documentation.yml
vendored
63
.github/workflows/delete_dev_documentation.yml
vendored
@@ -1,63 +0,0 @@
|
|||||||
name: Delete dev documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [ closed ]
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_package:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: huggingface/transformers-doc-builder
|
|
||||||
|
|
||||||
env:
|
|
||||||
PR_NUMBER: ${{ github.event.number }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Set env
|
|
||||||
run: |
|
|
||||||
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Setup environment
|
|
||||||
run: |
|
|
||||||
rm -rf doc-build-dev
|
|
||||||
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
|
|
||||||
|
|
||||||
- name: Setup git
|
|
||||||
run: |
|
|
||||||
git config --global user.name "Hugging Face Doc Builder"
|
|
||||||
git config --global user.email docs@huggingface.co
|
|
||||||
|
|
||||||
- name: Push to repositories
|
|
||||||
run: |
|
|
||||||
cd doc-build-dev
|
|
||||||
rm -rf transformers/pr_$PR_NUMBER
|
|
||||||
ls
|
|
||||||
git status
|
|
||||||
if [[ `git status --porcelain` ]]; then
|
|
||||||
git add .
|
|
||||||
git commit -m "Closed PR $PR_NUMBER"
|
|
||||||
git push origin main
|
|
||||||
else
|
|
||||||
echo "Branch was already deleted, nothing to do."
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Find Comment
|
|
||||||
if: ${{ always() }}
|
|
||||||
uses: peter-evans/find-comment@v1
|
|
||||||
id: fc
|
|
||||||
with:
|
|
||||||
issue-number: ${{ env.PR_NUMBER }}
|
|
||||||
comment-author: HuggingFaceDocBuilderDev
|
|
||||||
|
|
||||||
- name: Update comment
|
|
||||||
if: ${{ always() }}
|
|
||||||
uses: peter-evans/create-or-update-comment@v1
|
|
||||||
with:
|
|
||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
||||||
token: ${{ env.WRITE }}
|
|
||||||
edit-mode: replace
|
|
||||||
body: |
|
|
||||||
_The documentation is not available anymore as the PR was closed or merged._
|
|
||||||
13
.github/workflows/delete_doc_comment.yml
vendored
Normal file
13
.github/workflows/delete_doc_comment.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Delete dev documentation
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [ closed ]
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
delete:
|
||||||
|
uses: huggingface/doc-builder/.github/workflows/delete_doc_comment.yml@main
|
||||||
|
with:
|
||||||
|
pr_number: ${{ github.event.number }}
|
||||||
|
package: transformers
|
||||||
Reference in New Issue
Block a user