From 77b88a3849c7f2d9ca7f3e3f9ce4bc4718c92292 Mon Sep 17 00:00:00 2001 From: Frank Lee Date: Tue, 28 Feb 2023 11:10:38 +0800 Subject: [PATCH] [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 --- .github/workflows/doc_check_on_pr.yml | 1 + .github/workflows/doc_test_on_pr.yml | 87 ++++++++++++++++++++++ .github/workflows/doc_test_on_schedule.yml | 47 ++++++++++++ docs/requirements-doc-test.txt | 2 + docs/source/en/get_started/installation.md | 2 + 5 files changed, 139 insertions(+) create mode 100644 .github/workflows/doc_test_on_pr.yml create mode 100644 .github/workflows/doc_test_on_schedule.yml create mode 100644 docs/requirements-doc-test.txt diff --git a/.github/workflows/doc_check_on_pr.yml b/.github/workflows/doc_check_on_pr.yml index 6e42053dd..6593ac50e 100644 --- a/.github/workflows/doc_check_on_pr.yml +++ b/.github/workflows/doc_check_on_pr.yml @@ -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 diff --git a/.github/workflows/doc_test_on_pr.yml b/.github/workflows/doc_test_on_pr.yml new file mode 100644 index 000000000..a0572766f --- /dev/null +++ b/.github/workflows/doc_test_on_pr.yml @@ -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 diff --git a/.github/workflows/doc_test_on_schedule.yml b/.github/workflows/doc_test_on_schedule.yml new file mode 100644 index 000000000..6b4f5d1f9 --- /dev/null +++ b/.github/workflows/doc_test_on_schedule.yml @@ -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 diff --git a/docs/requirements-doc-test.txt b/docs/requirements-doc-test.txt new file mode 100644 index 000000000..b49a94554 --- /dev/null +++ b/docs/requirements-doc-test.txt @@ -0,0 +1,2 @@ +colossalai +torch diff --git a/docs/source/en/get_started/installation.md b/docs/source/en/get_started/installation.md index 1757b4241..0e114696d 100644 --- a/docs/source/en/get_started/installation.md +++ b/docs/source/en/get_started/installation.md @@ -1,3 +1,5 @@ + + # Setup > Colossal-AI currently only supports the Linux operating system and has not been tested on other OS such as Windows and macOS.