diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index 20a0a7193c3..fe85551cb2a 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -21,16 +21,15 @@ env: PYPI_CACHE: "_ci-cache_PyPI" PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: 'python' TOKENIZERS_PARALLELISM: false - SPHINX_FETCH_ASSETS: 1 # todo: consider not downloading on PRs jobs: - docs-check: + docs-make: if: github.event.pull_request.draft == false runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: - check: [doctest, linkcheck] + check: [html, doctest, linkcheck] env: SPHINX_MOCK_REQUIREMENTS: 0 timeout-minutes: 30 @@ -47,16 +46,28 @@ jobs: pytorch-version: ${{ matrix.pytorch-version }} pypi-dir: ${{ env.PYPI_CACHE }} + - name: Install Latex + if: ${{ matrix.check == 'html' }} + # install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux + run: | + sudo apt-get update + sudo apt-get install -y \ + texlive-latex-extra texlive-pictures texlive-fonts-recommended dvipng cm-super + - name: Install package & dependencies run: | - sudo apt-get update && sudo apt-get install -y cmake + sudo apt-get update --fix-missing + sudo apt-get install -y cmake pip --version - pip install . -U -r requirements/docs.txt --find-links $PYPI_CACHE -f $TORCH_URL + pip install . -U -r requirements/docs.txt \ + --find-links=${PYPI_CACHE} --find-links=${TORCH_URL} pip list - name: Test Examples in Documentation if: ${{ matrix.check == 'doctest' }} working-directory: ./docs + env: + SPHINX_FETCH_ASSETS: 0 run: | make doctest make coverage @@ -64,53 +75,20 @@ jobs: - name: Check External Links if: ${{ matrix.check == 'linkcheck' }} working-directory: ./docs + env: + SPHINX_FETCH_ASSETS: 0 run: make --jobs $(nproc) linkcheck SPHINXOPTS="--keep-going" - # ToDO: comment on PR if any link failed - #continue-on-error: true - - - make-html: - runs-on: ubuntu-22.04 - timeout-minutes: 45 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.9" - - - name: source cashing - uses: ./.github/actions/pull-caches - with: - requires: ${{ matrix.requires }} - pytorch-version: ${{ matrix.pytorch-version }} - pypi-dir: ${{ env.PYPI_CACHE }} - - # Note: This uses an internal pip API and may not always work - # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow - - name: Cache pip - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements/docs.txt') }} - restore-keys: ${{ runner.os }}-pip- - - - name: Install dependencies & package - run: | - # install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux - sudo apt-get update - sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures texlive-fonts-recommended cm-super - pip --version - pip install . -U -r requirements/docs.txt --find-links $PYPI_CACHE -f $TORCH_URL - pip list - shell: bash - name: Make Documentation + if: ${{ matrix.check == 'html' }} working-directory: ./docs + env: + SPHINX_FETCH_ASSETS: 1 run: make html --debug SPHINXOPTS="-W --keep-going" - name: Upload built docs + if: ${{ matrix.check == 'html' && github.event_name == 'push' }} uses: actions/upload-artifact@v3 - if: github.event_name == 'push' with: name: docs-${{ github.sha }} path: docs/build/ @@ -125,9 +103,11 @@ jobs: deploy-docs: - needs: [docs-check, make-html] + needs: docs-make if: github.repository_owner == 'Lightning-AI' && github.event_name == 'push' runs-on: ubuntu-latest + env: + GCP_TARGET: "gs://lightning-docs-metrics" steps: - uses: actions/download-artifact@v3 with: @@ -147,14 +127,22 @@ jobs: # Uploading docs to GCS, so they can be served on lightning.ai - name: Upload docs/metrics/stable to GCS 🪣 if: startsWith(github.ref, 'refs/heads/release/') - run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/stable + run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/stable # Uploading docs to GCS, so they can be served on lightning.ai - name: Upload docs/metrics/latest to GCS 🪣 if: github.ref == 'refs/heads/master' - run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/latest + run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/latest # Uploading docs to GCS, so they can be served on lightning.ai - name: Upload docs/metrics/release to GCS 🪣 if: startsWith(github.ref, 'refs/tags/') - run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/${{ github.ref_name }} + run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/${{ github.ref_name }} + + # Uploading docs as archive to GCS, so they can be as backup + - name: Upload docs as archive to GCS 🪣 + if: startsWith(github.ref, 'refs/tags/') + working-directory: docs/build + run: | + zip ${{ github.ref_name }}.zip -r html/ + gsutil cp ${{ github.ref_name }}.zip ${GCP_TARGET}