Skip to content

docs: build historical multiversion docs with Java 8#909

Draft
dkropachev wants to merge 1 commit into
scylladb:scylla-4.xfrom
dkropachev:dk/fix-docs-multiversion-jdk-selection
Draft

docs: build historical multiversion docs with Java 8#909
dkropachev wants to merge 1 commit into
scylladb:scylla-4.xfrom
dkropachev:dk/fix-docs-multiversion-jdk-selection

Conversation

@dkropachev
Copy link
Copy Markdown

@dkropachev dkropachev commented May 27, 2026

Problem

Docs / Publish failed in the Build docs step for https://github.com/scylladb/java-driver/actions/runs/26452394479/job/77876624864. That job runs make -C docs multiversion, but the PR docs workflow only ran make -C docs test, so the published-docs multiversion/Javadoc path could break after merge without being exercised in PR CI.

make -C docs multiversion renders historical scylla-* branches and runs each checkout's branch-local docs/_utils/javadoc.sh. Those historical checkouts should keep using their own docs and Maven config, but that config was written for the Java 8-era build. Running it under Java 11 exposed old Error Prone/Javadoc assumptions, stale external Javadoc links, and legacy scripts that can fail after Maven leaves no API docs to copy.

Some historical Sphinx refs also print non-fatal warnings/CRITICAL diagnostics, but the publish-breaking exit was the historical Javadoc path under the wrong Java runtime.

Fix

  • Install Java 8 alongside Java 11 in the docs PR and publish workflows.
  • Keep Java 11 as the workflow default for normal docs.
  • Make this branch's docs/_utils/multiversion.sh select Java 8 for historical scylla-*/tag refs before the post-build Javadoc step.
  • Keep the post-build Javadoc command delegated to the checked-out ref's own ./docs/_utils/javadoc.sh; historical checkout docs/Maven config is not patched.
  • Run make -C docs multiversion in PR CI so the publish path is covered before merge.
  • Include docs workflow files in docs workflow path filters so docs CI changes are validated.
  • Make the current branch docs/_utils/javadoc.sh fail fast, skip install-time Javadoc attachment, and handle API output directories safely.

Testing

  • bash -n docs/_utils/javadoc.sh docs/_utils/multiversion.sh
  • git diff --check
  • targeted Java 8 post-build run for origin/scylla-3.10.2.x using the exact command generated by docs/_utils/multiversion.sh; it used the branch-local docs/_utils/javadoc.sh and passed
  • previous full run with the same Java-selection logic: JAVA_HOME=$HOME/.sdkman/candidates/java/11.0.29-tem JAVA_HOME_8_X64=$HOME/.sdkman/candidates/java/8.0.472-tem JAVA_HOME_11_X64=$HOME/.sdkman/candidates/java/11.0.29-tem PATH=$HOME/.sdkman/candidates/java/11.0.29-tem/bin:$PATH make -C docs multiversion

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

Docs workflows now trigger on changes to their own YAML files, add JDK 8 setup steps, and run a published multiversion build. Javadoc-generation scripts were hardened; a new simplified multiversion-javadoc.sh selects Java 8/11, cleans output, and invokes javadoc.sh. multiversion.sh runs from the repository root.

Changes

Documentation Multi-version Build System

Layer / File(s) Summary
Workflow triggers and JDK8 setup
.github/workflows/docs-pages.yml, .github/workflows/docs-pr.yml
on.push/on.pull_request path filters now include the workflow YAML files themselves; both workflows add a step to set up Temurin JDK 8 before the existing JDK 11 step; docs-pr.yml adds a "Build published docs" step running make -C docs multiversion.
Javadoc script hardening
docs/_utils/javadoc.sh
Enable set -euo pipefail; compute OUTPUT_DIR via ${SPHINX_MULTIVERSION_OUTPUTDIR:-}; conditionally remove existing output dir; consistently quote rm, mkdir -p, and mv operations.
Simplified multiversion javadoc wrapper
docs/_utils/multiversion-javadoc.sh
New wrapper enables strict bash, derives VERSION_NAME from SPHINX_MULTIVERSION_NAME, selects Java 8 vs 11 (using JAVA_HOME_8_X64/JAVA_HOME_11_X64), prints java -version, removes the Javadoc output directory, and runs docs/_utils/javadoc.sh. Previous repository-patching logic was removed.
Multiversion orchestration from repo root
docs/_utils/multiversion.sh
Enable strict bash flags, compute REPO_ROOT from script location, cd to repo root before running sphinx-multiversion, and invoke the new multiversion-javadoc.sh via $REPO_ROOT.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hop through YAML and bash so neat,
I set Java eight and make docs complete,
Strict flags keep errors from taking flight,
Multiversion builds now run from root right,
Hooray — the published pages shine bright! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes building historical multiversion docs with Java 8, but the PR objectives explicitly state 'Keep docs workflows on Java 11 only (no Java 8 fallback)' and the actual changes establish Java 11 as the primary runtime with Java 8 used only for specific historical branches during multiversion builds. Update the title to accurately reflect the change, such as 'docs: fix multiversion docs build with Java 11' or 'docs: enable multiversion docs in PR CI with proper Java selection' to match the actual implementation and objectives.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@dkropachev dkropachev marked this pull request as ready for review May 27, 2026 01:49
@dkropachev dkropachev force-pushed the dk/fix-docs-multiversion-jdk-selection branch from af6b211 to dba3d8e Compare May 27, 2026 01:50
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
docs/_utils/multiversion-javadoc.sh (2)

43-51: 💤 Low value

Consider defensive validation before deleting output directory.

While the rm -rf on line 50 is generally safe with set -u preventing unset variables, an explicit safety check would make the code more obviously correct and prevent accidental deletion if the directory path logic changes in the future.

🛡️ Add explicit path validation
     fi
 
+    # Safety check: ensure we're not deleting something unexpected
+    if [[ "$output_dir" != */api ]]; then
+        echo "Error: Unexpected output directory path: $output_dir"
+        exit 1
+    fi
+
     rm -rf "$output_dir"
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/_utils/multiversion-javadoc.sh` around lines 43 - 51, In
clean_javadoc_output(), add a defensive validation before calling rm -rf on the
computed output_dir: verify output_dir is non-empty, not equal to "/" or ".",
and matches the expected local path pattern (e.g., starts with "docs/_build" or
ends with "/api") or confirm it resolves under the repository directory; if the
validation fails, log an error and exit non-zero instead of deleting. Ensure you
reference the computed variable output_dir and the environment override
SPHINX_MULTIVERSION_OUTPUTDIR when performing the checks so the safety guard
runs for both default and overridden paths.

57-57: ⚡ Quick win

The bash -e invocation is redundant.

Since javadoc.sh now begins with set -euo pipefail (line 2), explicitly invoking it with bash -e is redundant. The script will handle its own error exits.

♻️ Simplify invocation
-bash -e ./docs/_utils/javadoc.sh
+bash ./docs/_utils/javadoc.sh

Alternatively, if you want to ensure fail-fast even for legacy checkouts where javadoc.sh might not have been hardened yet:

-bash -e ./docs/_utils/javadoc.sh
+bash -euo pipefail ./docs/_utils/javadoc.sh
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/_utils/multiversion-javadoc.sh` at line 57, The invocation in
multiversion-javadoc.sh is redundant: replace the line calling bash -e with a
plain executable call to ./docs/_utils/javadoc.sh (the javadoc.sh script already
contains set -euo pipefail), i.e., update the call in multiversion-javadoc.sh to
invoke javadoc.sh directly so error handling is delegated to javadoc.sh; if you
must keep compatibility for older checkouts, add a short comment explaining why
you would retain bash -e, otherwise remove it.
docs/_utils/javadoc.sh (1)

20-20: ⚡ Quick win

Verify glob expansion succeeds before moving.

The unquoted glob core/target/site/apidocs/* will fail if the directory is empty or if javadoc:javadoc doesn't generate files. With set -e, the script will exit, but the error message may be unclear.

🛡️ Add explicit check for generated files
 # Generate javadoc
 mvn javadoc:javadoc -T 1C
 if [[ -d "$OUTPUT_DIR" ]]; then
     rm -r "$OUTPUT_DIR"
 fi
 mkdir -p "$OUTPUT_DIR"
+if ! compgen -G "core/target/site/apidocs/*" > /dev/null; then
+    echo "Error: Javadoc generation produced no files in core/target/site/apidocs/"
+    exit 1
+fi
 mv -f core/target/site/apidocs/* "$OUTPUT_DIR"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/_utils/javadoc.sh` at line 20, The mv invocation in javadoc.sh uses an
unquoted glob (core/target/site/apidocs/*) which will fail when no files are
generated; update the script to check for files before moving: test whether the
apidocs directory exists and contains at least one file (e.g. using a glob check
or a nullglob-aware conditional) and only run the mv to "$OUTPUT_DIR" when files
are present, otherwise log a clear message or create an empty placeholder;
reference the existing mv command and the OUTPUT_DIR variable when making the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/_utils/javadoc.sh`:
- Line 20: The mv invocation in javadoc.sh uses an unquoted glob
(core/target/site/apidocs/*) which will fail when no files are generated; update
the script to check for files before moving: test whether the apidocs directory
exists and contains at least one file (e.g. using a glob check or a
nullglob-aware conditional) and only run the mv to "$OUTPUT_DIR" when files are
present, otherwise log a clear message or create an empty placeholder; reference
the existing mv command and the OUTPUT_DIR variable when making the change.

In `@docs/_utils/multiversion-javadoc.sh`:
- Around line 43-51: In clean_javadoc_output(), add a defensive validation
before calling rm -rf on the computed output_dir: verify output_dir is
non-empty, not equal to "/" or ".", and matches the expected local path pattern
(e.g., starts with "docs/_build" or ends with "/api") or confirm it resolves
under the repository directory; if the validation fails, log an error and exit
non-zero instead of deleting. Ensure you reference the computed variable
output_dir and the environment override SPHINX_MULTIVERSION_OUTPUTDIR when
performing the checks so the safety guard runs for both default and overridden
paths.
- Line 57: The invocation in multiversion-javadoc.sh is redundant: replace the
line calling bash -e with a plain executable call to ./docs/_utils/javadoc.sh
(the javadoc.sh script already contains set -euo pipefail), i.e., update the
call in multiversion-javadoc.sh to invoke javadoc.sh directly so error handling
is delegated to javadoc.sh; if you must keep compatibility for older checkouts,
add a short comment explaining why you would retain bash -e, otherwise remove
it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: df7f0882-64b1-4bff-acec-59136fea4a34

📥 Commits

Reviewing files that changed from the base of the PR and between 5a61e12 and dba3d8e.

📒 Files selected for processing (5)
  • .github/workflows/docs-pages.yml
  • .github/workflows/docs-pr.yml
  • docs/_utils/javadoc.sh
  • docs/_utils/multiversion-javadoc.sh
  • docs/_utils/multiversion.sh

@dkropachev dkropachev force-pushed the dk/fix-docs-multiversion-jdk-selection branch 2 times, most recently from 07064fb to ece08ca Compare May 27, 2026 02:57
@dkropachev dkropachev changed the title docs: make multiversion docs build on Java 11 docs: build historical multiversion docs with Java 8 May 27, 2026
@dkropachev dkropachev marked this pull request as draft May 27, 2026 02:58
The docs publish workflow failed in the Build docs step because it runs make -C docs multiversion, while PR docs CI only ran make -C docs test. That left the published-docs multiversion/Javadoc path uncovered until after merge.

The multiversion build renders historical scylla-* branches and runs each checkout's branch-local docs/_utils/javadoc.sh as a sphinx-multiversion post-build hook. Those historical checkouts should keep using their own docs and Maven config, but that config was written for the Java 8-era build. Running it under Java 11 exposed old Error Prone/Javadoc assumptions, stale external Javadoc links, and legacy scripts that could fail only after Maven left no API docs to copy.

Install Java 8 alongside Java 11 in the docs workflows. Java 11 remains the workflow default for normal docs. The current branch multiversion script selects Java 8 for historical refs before delegating to the branch-local Javadoc script, preserving same-ref docs config instead of patching temporary historical checkouts.

Also run make -C docs multiversion in PR CI, include docs workflow files in the docs workflow path filters, and make the current branch Javadoc script fail fast while avoiding install-time Javadoc attachment.
@dkropachev dkropachev force-pushed the dk/fix-docs-multiversion-jdk-selection branch from ece08ca to 91b0937 Compare May 27, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant