Skip to content

Commit c84c86d

Browse files
committed
docs: build multiversion Javadocs in parallel with matching JDKs
Docs publishing runs make -C docs multiversion, but PR docs CI only ran make -C docs test. That left the publish-only multiversion and Javadoc path uncovered before merge. Install Java 8 alongside Java 11 in the docs workflows and make the multiversion post-build helper select Java 8 for historical scylla-* and tag refs while keeping Java 11 for the current docs build. The helper still runs each checked-out ref's own docs/_utils/javadoc.sh, so older docs use their branch-local Maven and docs configuration. Run make -C docs multiversion in PR CI and include docs workflow files in the docs workflow path filters so CI changes are validated before publishing. Build multiversion refs with a repo-local parallel runner. It calculates version-level parallelism from os.cpu_count(), caps it at 8 workers, builds each version in an isolated temporary output root to avoid shared Sphinx theme asset races, then publishes completed outputs serially. Give each version build its own temporary Maven local repository through MAVEN_OPTS so parallel historical Javadoc builds do not race on shared snapshot metadata. Also make the current branch Javadoc script deterministic: skip install-time Javadoc attachment during the preparatory install, keep Maven parallelism with -T 1C, accept the current core/target/reports/apidocs output location with fallback to core/target/site/apidocs, and fail clearly when generated output is missing or empty.
1 parent 5a61e12 commit c84c86d

6 files changed

Lines changed: 477 additions & 7 deletions

File tree

.github/workflows/docs-pages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- scylla-4.x
99
- 'scylla-**'
1010
paths:
11+
- '.github/workflows/docs-pages.yml'
12+
- '.github/workflows/docs-pr.yml'
1113
- 'docs/**'
1214
- 'faq/**'
1315
- 'manual/**'
@@ -36,6 +38,12 @@ jobs:
3638
with:
3739
python-version: '3.13'
3840

41+
- name: Set up JDK 8 for historical docs
42+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
43+
with:
44+
java-version: '8'
45+
distribution: 'temurin'
46+
3947
- name: Set up JDK 11
4048
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
4149
with:

.github/workflows/docs-pr.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
branches:
1111
- scylla-4.x
1212
paths:
13+
- '.github/workflows/docs-pages.yml'
14+
- '.github/workflows/docs-pr.yml'
1315
- 'docs/**'
1416
- 'faq/**'
1517
- 'manual/**'
@@ -31,6 +33,12 @@ jobs:
3133
with:
3234
python-version: '3.13'
3335

36+
- name: Set up JDK 8 for historical docs
37+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
38+
with:
39+
java-version: '8'
40+
distribution: 'temurin'
41+
3442
- name: Set up JDK 11
3543
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
3644
with:
@@ -45,3 +53,6 @@ jobs:
4553

4654
- name: Build docs
4755
run: make -C docs test
56+
57+
- name: Build published docs
58+
run: make -C docs multiversion

docs/_utils/javadoc.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
#!/bin/bash
2+
set -euo pipefail
23

34
# Install dependencies
4-
mvn install -DskipTests -T 1C
5+
mvn install -DskipTests -Dmaven.javadoc.skip=true -T 1C
56

67
# Define output folder
78
OUTPUT_DIR="docs/_build/dirhtml/api"
8-
if [[ "$SPHINX_MULTIVERSION_OUTPUTDIR" != "" ]]; then
9+
if [[ "${SPHINX_MULTIVERSION_OUTPUTDIR:-}" != "" ]]; then
910
OUTPUT_DIR="$SPHINX_MULTIVERSION_OUTPUTDIR/api"
1011
echo "HTML_OUTPUT = $OUTPUT_DIR" >> doxyfile
1112
fi
1213

1314
# Generate javadoc
1415
mvn javadoc:javadoc -T 1C
15-
[ -d $OUTPUT_DIR ] && rm -r $OUTPUT_DIR
16+
JAVADOC_SOURCE_DIR="core/target/site/apidocs"
17+
if [[ ! -d "$JAVADOC_SOURCE_DIR" && -d "core/target/reports/apidocs" ]]; then
18+
JAVADOC_SOURCE_DIR="core/target/reports/apidocs"
19+
fi
20+
if [[ ! -d "$JAVADOC_SOURCE_DIR" ]]; then
21+
echo "Javadoc output directory was not generated" >&2
22+
exit 1
23+
fi
24+
shopt -s nullglob
25+
JAVADOC_FILES=("$JAVADOC_SOURCE_DIR"/*)
26+
if (( ${#JAVADOC_FILES[@]} == 0 )); then
27+
echo "Javadoc output directory is empty" >&2
28+
exit 1
29+
fi
30+
if [[ -d "$OUTPUT_DIR" ]]; then
31+
rm -r "$OUTPUT_DIR"
32+
fi
1633
mkdir -p "$OUTPUT_DIR"
17-
mv -f core/target/site/apidocs/* $OUTPUT_DIR
34+
mv -f "${JAVADOC_FILES[@]}" "$OUTPUT_DIR"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# sphinx-multiversion runs this script from each temporary checkout. This
5+
# branch-owned wrapper only selects the Java runtime; the actual Javadocs are
6+
# still generated by the checkout's own docs/_utils/javadoc.sh so historical
7+
# refs keep their branch-local docs and Maven configuration.
8+
9+
version_name="${SPHINX_MULTIVERSION_NAME:-unknown}"
10+
11+
if [[ "${version_name}" == scylla-* || "${version_name}" == tags/* ]]; then
12+
if [[ -z "${JAVA_HOME_8_X64:-}" ]]; then
13+
echo "JAVA_HOME_8_X64 is required to build historical docs for ${version_name}" >&2
14+
exit 1
15+
fi
16+
17+
export JAVA_HOME="$JAVA_HOME_8_X64"
18+
export PATH="$JAVA_HOME/bin:$PATH"
19+
echo "Using Java 8 for historical docs version ${version_name}"
20+
elif [[ -n "${JAVA_HOME_11_X64:-}" ]]; then
21+
export JAVA_HOME="$JAVA_HOME_11_X64"
22+
export PATH="$JAVA_HOME/bin:$PATH"
23+
echo "Using Java 11 for ${version_name}"
24+
fi
25+
26+
echo "Building Javadocs for ${version_name} with Java:"
27+
java -version
28+
29+
bash -e ./docs/_utils/javadoc.sh

docs/_utils/multiversion.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#! /bin/bash
1+
#! /bin/bash
2+
set -euo pipefail
23

3-
cd .. && sphinx-multiversion docs/source docs/_build/dirhtml \
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
6+
7+
cd "$REPO_ROOT" && python "$SCRIPT_DIR/parallel_multiversion.py" docs/source docs/_build/dirhtml \
48
--pre-build "bash -c \"(find . -mindepth 2 -name README.md -execdir mv '{}' index.md ';'; find . -mindepth 2 -name README.rst -execdir mv '{}' index.rst ';')\"" \
5-
--post-build './docs/_utils/javadoc.sh'
9+
--post-build "bash '$SCRIPT_DIR/multiversion-javadoc.sh'"

0 commit comments

Comments
 (0)