Skip to content

Allow building docs with a local sphinx_airflow_theme checkout - #75001

Merged
shahar1 merged 7 commits into
apache:mainfrom
shahar1:build-docs-with-local-sphinx-theme
Oct 24, 2026
Merged

shahar1 merged 7 commits into
apache:mainfrom
shahar1:build-docs-with-local-sphinx-theme

Conversation

@shahar1

@shahar1 shahar1 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

closes: #45576

As titled, this PR adds an option to mount airflow-site/sphinx_airflow_theme when running CI locally.

AI Summary Changes to the docs theme live in `airflow-site`, so checking them on real Airflow documentation meant building a wheel by hand and force-installing it inside a Breeze shell. This adds `--sphinx-airflow-theme-path` to `breeze build-docs`: the given `sphinx_airflow_theme` sub-folder of an `airflow-site` checkout is mounted read-only into the docs container and installed there before the build, so neither checkout nor `uv.lock` changes. The theme builds with `flit_core`, which does not write into the source folder, so the read-only mount is enough. Only the theme is reinstalled; a dependency the theme adds is installed with it.
breeze build-docs apache-airflow --sphinx-airflow-theme-path ../airflow-site/sphinx_airflow_theme

The option fails with a usage error before any Docker work when the folder has no generated CSS/JS (./site.sh prepare-theme not run, or the airflow-site root passed instead of the sub-folder), since the docs would otherwise build without styles. It also fails when combined with --sdk-docs-only, because the SDK docs do not use the Sphinx theme.

Verified locally with Docker: a marker added to the local theme's layout.html appears in the built HTML and is absent without the option. The install command was also checked against a read-only copy of the theme in the CI image. The Breeze tests for build-docs now share one Docker-free fixture that points AIRFLOW_ROOT_PATH to a temporary folder; before, the existing Python-version test deleted the real generated/**/apis folders. The companion airflow-site change adds ./site.sh build-airflow-docs and an informational CI preview on top of this option.

Not included: --autobuild with automatic rebuild when the mounted theme files change (raised on #70139); tracked in #75374.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Claude Opus 5.5)

Generated-by: Claude Code (Claude Opus 5.5) following the guidelines

🤖 Generated with Claude Code

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — being able to test unreleased theme changes against the real docs build is useful. A few things before this can go in:

Likely blocker

  1. scripts/ci/docker-compose/mount-sphinx-airflow-theme.yml mounts the theme with read_only: true, but run_docs_build.sh then runs uv pip install --reinstall /opt/sphinx_airflow_theme. The theme is a setuptools project, and building it from a source directory writes *.egg-info / build/ into that directory, so the install should fail with "Read-only file system" and abort the docs build (set -euo pipefail). Has this been run end-to-end with a real airflow-site checkout? Copying the tree to a temp dir inside the container and installing from the copy keeps the checkout clean and avoids the problem.

Behaviour

  1. --no-deps means a theme change that adds or bumps a dependency is silently installed without it, so the local build can diverge from what the released theme would produce.
  2. With --sdk-docs-only, --sphinx-airflow-theme-path is validated and then ignored without any message. Either pass it through or reject the combination.
  3. The sphinx_airflow_theme/static/_gen check lives in the command body and ends in sys.exit(1). A click callback= on the option raising click.BadParameter would give a standard usage error and keep the validation next to the option. It would also help to say explicitly in the help text that the path is the sphinx_airflow_theme sub-folder, not the airflow-site repo root, which is what most people will pass first.
  4. run_docs_build.sh decides whether to install by checking that /opt/sphinx_airflow_theme exists, and that path is also hard-coded in the compose file. Gating on SPHINX_AIRFLOW_THEME_PATH (already exported by Breeze) would keep a single source of truth.

Tests

  1. The docker_mocks fixture uses with patch.multiple(...); the repo convention prefers @mock.patch decorators.
  2. TestBuildDocsSphinxAirflowTheme duplicates the Docker stubbing already in TestBuildDocsPythonVersion. A shared fixture would remove the duplication, and redirecting AIRFLOW_ROOT_PATH to tmp_path there would stop the older class touching the real generated/ tree.
  3. test_theme_path_is_passed_to_shell_params should assert result.exit_code == 0 before reading call_args, otherwise an unrelated failure either passes silently or surfaces as an AttributeError.

Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting

@shahar1 shahar1 added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Oct 18, 2026

@Andrushika Andrushika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some comments.
We might need a follow-up issue for autobuild before merge, since closes: #45576 closes the issue and autobuild was asked for on #70139.

Comment thread scripts/in_container/run_docs_build.sh Resolved
@shahar1

shahar1 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews. The branch is rebased onto main, and the changes are in e721ac9..8cec2d9.

Review summary points, in order:

  1. Read-only mount: no change. The theme builds with flit_core (build-backend = "flit_core.buildapi" in airflow-site/sphinx_airflow_theme/pyproject.toml), which does not write *.egg-info or build/ into the source folder. It was run end to end with a real airflow-site checkout: a marker in layout.html showed up in the built HTML. The install was also checked against a read-only mount in the CI image.
  2. --no-deps is replaced with --reinstall-package sphinx-airflow-theme. Only the theme is reinstalled, and a dependency that the theme adds is installed too.
  3. --sdk-docs-only together with --sphinx-airflow-theme-path is now rejected with a usage error.
  4. The _gen check is now a click callback that raises click.BadParameter. The help text says the path is the sphinx_airflow_theme sub-folder, not the airflow-site root.
  5. run_docs_build.sh now installs the theme only when SPHINX_AIRFLOW_THEME_PATH is set.
    6–7. Both build-docs test classes now share one fixture that stubs Docker with autospecced mocks and points AIRFLOW_ROOT_PATH to tmp_path. Before, the existing Python-version test deleted the real generated/**/apis folders.
  6. The tests assert exit_code == 0 before reading call_args. The rejection tests also check the error text, so they fail without the new option.

Follow-up issue for the auto-rebuild mode asked for on #70139: #75374.


Drafted-by: Claude Code (Opus 5.5); reviewed by @shahar1 before posting

@shahar1
shahar1 requested a review from potiuk October 22, 2026 06:16

@Andrushika Andrushika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@shahar1
shahar1 requested a review from kaxil October 23, 2026 13:38
@shahar1
shahar1 force-pushed the build-docs-with-local-sphinx-theme branch from 8cec2d9 to 61758b6 Compare October 23, 2026 19:00
Changes to the docs theme live in airflow-site, and the only way to see
them on real Airflow documentation was to build a wheel by hand, copy it
into the Airflow checkout and install it inside Breeze before building.

Add a --sphinx-airflow-theme-path option to breeze build-docs. Breeze
mounts the given theme folder read-only into the container and installs
it there before the build, so an unreleased theme can be checked on the
real docs, locally or from airflow-site's own scripts and CI. The folder
must contain the generated theme assets, otherwise the build would be
silently unstyled.

closes: apache#45576
- Reinstall only the theme with --reinstall-package (keeps new theme
  dependencies) and gate the install on SPHINX_AIRFLOW_THEME_PATH.
- Validate the theme path in a click callback raising BadParameter and
  clarify in the help that it is the sphinx_airflow_theme sub-folder.
- Reject --sphinx-airflow-theme-path together with --sdk-docs-only.
- Share one autospecced Docker-stubbing fixture between the build-docs
  tests, redirect AIRFLOW_ROOT_PATH to tmp_path, and tighten the theme
  tests.
The two rejection tests now check the error text, so they fail without the new option.
prepare-theme copies the existing dist bundle, so edited SCSS/JS only reach _gen after build-landing-pages.
apache/airflow-site#1691 makes prepare-theme rebuild the landing pages when their SCSS/JS sources changed, so the note would be wrong once it lands. The recommended command works with old and new site.sh.
@shahar1
shahar1 force-pushed the build-docs-with-local-sphinx-theme branch from 61758b6 to 0b4ad71 Compare October 24, 2026 03:34
@shahar1
shahar1 merged commit 602e150 into apache:main Oct 24, 2026
147 checks passed
@shahar1
shahar1 deleted the build-docs-with-local-sphinx-theme branch October 24, 2026 05:13
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

github-actions Bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 24, 2026
…ckout (apache#75001)

(cherry picked from commit 602e150)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
aws-airflow-bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Oct 24, 2026
…ckout (apache#75001)

(cherry picked from commit 602e150)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
shahar1 added a commit that referenced this pull request Oct 24, 2026
…ckout (#75001) (#75537)

(cherry picked from commit 602e150)

Co-authored-by: Shahar Epstein <60007259+shahar1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-4-test Backport to v3-4-test ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to mount airflow-site/sphinx_airflow_theme when running CI locally

4 participants