[workflow] added auto doc test on PR (#2929)

* [workflow] added auto doc test on PR

* [workflow] added doc test workflow

* polish code

* polish code

* polish code

* polish code

* polish code

* polish code

* polish code
pull/2933/head
Frank Lee 2023-02-28 11:10:38 +08:00 committed by GitHub
parent 197d0bf4ed
commit 77b88a3849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 139 additions and 0 deletions

View File

@ -64,5 +64,6 @@ jobs:
mkdir $cache_dir
mv ColossalAI $cache_dir
cd ColossalAI-Documentation
pip install -v ./doc-build/third_party/hf-doc-builder
pip install -v ./doc-build
bash ./scripts/build.sh

87
.github/workflows/doc_test_on_pr.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: Test Documentation on PR
on:
pull_request:
# any change in the examples folder will trigger check for the corresponding example.
paths:
- 'docs/source/**.md'
jobs:
# This is for changed example files detect and output a matrix containing all the corresponding directory name.
detect-changed-doc:
if: |
github.event.pull_request.draft == false &&
github.base_ref == 'main' &&
github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' && github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
name: Detect changed example files
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Locate base commit
id: locate-base-sha
run: |
curBranch=$(git rev-parse --abbrev-ref HEAD)
commonCommit=$(git merge-base origin/main $curBranch)
echo $commonCommit
echo "baseSHA=$commonCommit" >> $GITHUB_OUTPUT
- name: Get all changed example files
id: changed-files
uses: tj-actions/changed-files@v35
with:
base_sha: ${{ steps.locate-base-sha.outputs.baseSHA }}
files: |
./docs/source/**/*.md
# If no file is changed, it will prompt an error and shows the matrix do not have value.
check-changed-doc:
# Add this condition to avoid executing this job if the trigger event is workflow_dispatch.
if: |
github.event.pull_request.draft == false &&
github.base_ref == 'main' &&
github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' && github.event_name == 'pull_request' &&
needs.detect-changed-doc.outputs.any_changed == 'true'
name: Test the changed Doc
needs: detect-changed-doc
runs-on: [self-hosted, gpu]
container:
image: hpcaitech/pytorch-cuda:1.12.0-11.3.0
options: --gpus all --rm
timeout-minutes: 20
steps:
- name: Checkout ColossalAI-Documentation
uses: actions/checkout@v2
with:
path: './ColossalAI-Documentation'
repository: 'hpcaitech/ColossalAI-Documentation'
- name: Install Docer
run: |
pip install -v ./ColossalAI-Documentation/doc-build/third_party/hf-doc-builder
pip install -v ./ColossalAI-Documentation/doc-build
- name: Checkout ColossalAI
uses: actions/checkout@v3
- name: Install ColossalAI
run: |
pip install -v .
- name: Install Doc Test Requirements
run: |
pip install -r docs/requirements-doc-test.txt
- name: Test the Doc
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Testing $file now..."
docer test -p $file
done
env:
NCCL_SHM_DISABLE: 1

View File

@ -0,0 +1,47 @@
name: Test Documentation on Schedule
on:
# run at 07:00 of every Sunday(singapore time) so here is UTC time Saturday 23:00
schedule:
- cron: '0 23 * * 6'
workflow_dispatch:
jobs:
check-changed-doc:
# Add this condition to avoid executing this job if the trigger event is workflow_dispatch.
if: github.repository == 'hpcaitech/ColossalAI'
name: Test the changed Doc
runs-on: [self-hosted, gpu]
container:
image: hpcaitech/pytorch-cuda:1.12.0-11.3.0
options: --gpus all --rm
timeout-minutes: 60
steps:
- name: Checkout ColossalAI-Documentation
uses: actions/checkout@v2
with:
path: './ColossalAI-Documentation'
repository: 'hpcaitech/ColossalAI-Documentation'
- name: Install Docer
run: |
pip install -v ./ColossalAI-Documentation/doc-build/third_party/hf-doc-builder
pip install -v ./ColossalAI-Documentation/doc-build
- name: Checkout ColossalAI
uses: actions/checkout@v3
- name: Install ColossalAI
run: |
pip install -v .
- name: Install Doc Test Requirements
run: |
pip install -r docs/requirements-doc-test.txt
- name: Test the Doc
run: |
for file in $(find ./docs/source -name "*.md"); do
docer test -p $file
done
env:
NCCL_SHM_DISABLE: 1

View File

@ -0,0 +1,2 @@
colossalai
torch

View File

@ -1,3 +1,5 @@
<!-- doc-test-command: echo "installation.md does not need test" -->
# Setup
> Colossal-AI currently only supports the Linux operating system and has not been tested on other OS such as Windows and macOS.