diff --git a/.github/workflows/cd-docs.yml b/.github/workflows/cd-docs.yml index 6616cd5aea..cedb64e38a 100644 --- a/.github/workflows/cd-docs.yml +++ b/.github/workflows/cd-docs.yml @@ -3,7 +3,8 @@ on: workflow_dispatch: push: branches: - - master + - 'master' + pull_request: permissions: contents: write jobs: @@ -17,6 +18,7 @@ jobs: run: | git config user.name github-actions[bot] git config user.email 41898282+github-actions[bot]@users.noreply.github.com + if: (github.event_name != 'pull_request') - name: Set up Python 3.9 uses: actions/setup-python@v5 @@ -26,6 +28,7 @@ jobs: cache-dependency-path: | setup.py tfx/dependencies.py + requirements-docs.txt - name: Save time for cache for mkdocs run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV @@ -39,7 +42,12 @@ jobs: mkdocs-material- - name: Install Dependencies - run: pip install mkdocs mkdocs-material mkdocstrings[python] griffe-inherited-docstrings mkdocs-autorefs mkdocs-jupyter mkdocs-caption markdown-grid-tables + run: pip install -r requirements-docs.txt - name: Deploy to GitHub Pages run: mkdocs gh-deploy --force + if: (github.event_name != 'pull_request') + + - name: Build docs to check for errors + run: mkdocs build + if: (github.event_name == 'pull_request') diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 0000000000..5bf64fe63c --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1,8 @@ +mkdocs +mkdocstrings[python] +mkdocs-material +griffe-inherited-docstrings +mkdocs-autorefs +mkdocs-jupyter +mkdocs-caption +markdown-grid-tables diff --git a/tfx/dependencies.py b/tfx/dependencies.py index 5a546e6b41..7666dd185a 100644 --- a/tfx/dependencies.py +++ b/tfx/dependencies.py @@ -37,7 +37,7 @@ from __future__ import annotations import os - +from pathlib import Path def select_constraint(default, nightly=None, git_master=None): """Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var.""" @@ -258,17 +258,12 @@ def make_extra_packages_docs() -> list[str]: list[str] List of packages required for building docs """ - return [ - "mkdocs", - "mkdocstrings[python]", - "mkdocs-material", - "griffe-inherited-docstrings", - "mkdocs-autorefs", - "mkdocs-jupyter", - "mkdocs-caption", - "pymdown-extensions", - "markdown-grid-tables", - ] + with open(Path(__file__).resolve().parent.parent / "requirements-docs.txt", "r") as fp: + reqs = fp.readlines() + + reqs = [req.replace("\n", "") for req in reqs] + + return reqs def make_extra_packages_all():