This is an automated email from the ASF dual-hosted git repository. mck pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-website.git
commit ea28710bef28f117e3772916e1da5953eef22dbd Author: mck <[email protected]> AuthorDate: Sun Apr 5 01:26:37 2026 +0200 Autogenerate the doc antora.yml patch by Mick Semb Wever; reviewed by Anthony Grasso for CASSANDRA-17375 --- run.sh | 15 ++++++++ site-content/Dockerfile | 72 ++++++++++++++++++--------------------- site-content/docker-entrypoint.sh | 68 +++++++++++++++++++++++++----------- 3 files changed, 98 insertions(+), 57 deletions(-) diff --git a/run.sh b/run.sh index 28b523b7a..377df2a09 100755 --- a/run.sh +++ b/run.sh @@ -396,6 +396,7 @@ run_docker_website_command() { local cassandra_volume_mount_set="false" local cassandra_website_volume_mount_set="false" local cassandra_website_source_set="false" + local cassandra_custom_repo_or_branch_set="false" if [ -f "${env_file}" ] then @@ -425,6 +426,12 @@ run_docker_website_command() { continue fi + # Track if custom cassandra repo or branches are provided (not tags, as those are handled separately) + if [ "${repository_name}" = "cassandra" ] && [ "${repository_source_type}" != "tags" ] + then + cassandra_custom_repo_or_branch_set="true" + fi + case "${repository_source_type}" in url) local url_source_name="${repository_name}" @@ -453,6 +460,14 @@ run_docker_website_command() { done done + # If custom cassandra repo or branches were provided, set ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS to empty + # to prevent auto-generation of tags (unless tags were explicitly provided via -t option) + if [ "${cassandra_custom_repo_or_branch_set}" = "true" ] && \ + ! printf '%s\n' "${env_args[@]}" | grep -q "ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS=" + then + env_args+=("-e ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS=") + fi + if [ "${container_command}" = "generate-docs" ] then # Check if a local Cassandra repository path will be mounted inside the container when only generating the docs. If diff --git a/site-content/Dockerfile b/site-content/Dockerfile index 597678ac7..9a2c1a8ea 100644 --- a/site-content/Dockerfile +++ b/site-content/Dockerfile @@ -7,11 +7,6 @@ FROM ubuntu:22.04 # --build-arg BUILD_USER_ARG=$(whoami) \ # --build-arg UID_ARG=$(id -u) \ # --build-arg GID_ARG=$(id -g) \ -# . -# -# Other container parameters can be overridden at build time as well: -# - NODE_VERSION_ARG: Version of node to use. -# - ENTR_VERSION_ARG: Version of entr to use. # # # For developer convenience (to avoid having to run `./run.sh website container`) publish trunk changes to dockerhub with: @@ -20,13 +15,10 @@ FROM ubuntu:22.04 ARG BUILD_USER_ARG="build" ARG UID_ARG=1000 ARG GID_ARG=1000 -ARG NODE_VERSION_ARG="v20.16.0" -ARG ENTR_VERSION_ARG="4.6" -ARG TARGETPLATFORM # GO_VERSION_SHAS must contain contain a matching sha256 for the $GO_VERSION download. there should only be four SHAs listed. -ARG GO_VERSION="1.24.3" -ARG GO_VERSION_SHAS="3333f6ea53afa971e9078895eaa4ac7204a8c6b5c68c10e6bc9a33e8e391bdd8 a463cb59382bd7ae7d8f4c68846e73c4d589f223c589ac76871b66811ded7836 13e6fe3fcf65689d77d40e633de1e31c6febbdbcb846eb05fc2434ed2213e92b 64a3fa22142f627e78fac3018ce3d4aeace68b743eff0afda8aae0411df5e4fb" +ARG GO_VERSION="1.26.1" +ARG GO_VERSION_SHAS="031f088e5d955bab8657ede27ad4e3bc5b7c1ba281f05f245bcc304f327c987a a290581cfe4fe28ddd737dde3095f3dbeb7f2e4065cab4eae44dfc53b760c2f7 65773dab2f8cc4cd23d93ba6d0a805de150ca0b78378879292be0b903b8cdd08 353df43a7811ce284c8938b5f3c7df40b7bfb6f56cb165b150bc40b5e2dd541f" ENV BUILD_USER=${BUILD_USER_ARG} ENV BUILD_DIR="/home/${BUILD_USER}" @@ -42,23 +34,13 @@ RUN echo "Building with arguments:" \ # INSTALL wget, python3, java11, and other tools required to build the docs RUN apt update && \ apt install -y \ - openjdk-8-jdk \ - openjdk-11-jdk \ - openjdk-17-jdk \ - python3 \ - python3-pip \ - ant \ - ant-optional \ - make \ - git \ - gpg \ - wget \ - curl \ - gcc \ - sudo + openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk openjdk-21-jdk \ + python3 python3-pip ant ant-optional make git gpg wget curl \ + gcc sudo pandoc # install golang. GO_VERSION_SHA must be updated with VERSION RUN sh -c '\ + set -ex ;\ GO_OS=linux ;\ [ $(uname) = "Darwin" ] && GO_OS=darwin ;\ GO_PLATFORM=amd64 ;\ @@ -77,13 +59,21 @@ ENV PATH="$PATH:/usr/local/go/bin" RUN pip3 install jinja2 requests RUN ln -s /usr/bin/python3 /usr/bin/python -# INSTALL nodejs and nvm -RUN export PLATFORM=$(if [ "$TARGETPLATFORM" = "linux/amd64" ] ; then echo "x64"; else echo "arm64"; fi) \ - && set -ex \ - && wget "https://nodejs.org/dist/$NODE_VERSION_ARG/node-$NODE_VERSION_ARG-linux-$PLATFORM.tar.xz" \ - && tar -xJf "node-$NODE_VERSION_ARG-linux-$PLATFORM.tar.xz" -C /usr/local --strip-components=1 \ - && rm "node-$NODE_VERSION_ARG-linux-$PLATFORM.tar.xz" \ - && ln -s /usr/local/bin/node /usr/local/bin/nodejs + +# Install Node.js for Antora (documentation generation) +RUN sh -c '\ + set -ex ;\ + NODE_VERSION="v20.16.0" ;\ + NODE_PLATFORM=x64 ;\ + [ $(uname -m) = "aarch64" ] && NODE_PLATFORM=arm64 ;\ + NODE_VERSION_SHAS="c30af7dfea46de7d8b9b370fa33b8b15440bc93f0a686af8601bbb48b82f16c0 1d9929e72f692179f884cd676b2dfabd879cb77defa7869dc8cfc802619277fb" ;\ + NODE_TAR="node-${NODE_VERSION}-linux-${NODE_PLATFORM}.tar.xz" ;\ + wget -q "https://nodejs.org/dist/${NODE_VERSION}/${NODE_TAR}" --no-check-certificate ;\ + NODE_SHA="$(sha256sum ${NODE_TAR} | cut -d" " -f1)" ;\ + echo "$NODE_VERSION_SHAS" | sed "s/ /\n/g" | grep -q "$NODE_SHA" || { echo "SHA256 mismatch for ${NODE_TAR} ${NODE_SHA}"; exit 1; } ;\ + tar -xJf "${NODE_TAR}" -C /usr/local --strip-components=1 ;\ + rm "${NODE_TAR}" ;\ + ln -s /usr/local/bin/node /usr/local/bin/nodejs' CMD [ "npm", "--version" ] @@ -100,12 +90,19 @@ RUN groupadd --gid ${GID_ARG} --non-unique ${BUILD_USER} && \ # Setup directories for building the docs # Give the build user rw access to everything in the build directory neccessary for the ASF 'website'. -ENV ENTR_PACKAGE="${ENTR_VERSION_ARG}.tar.gz" WORKDIR ${BUILD_DIR} -RUN wget https://github.com/eradman/entr/archive/${ENTR_PACKAGE} --no-check-certificate && \ - mkdir entr && \ - tar -C ${BUILD_DIR}/entr --strip-components 1 -xzf ${ENTR_PACKAGE} && \ - rm ${ENTR_PACKAGE} + +# install entr +RUN sh -c '\ + set -ex ;\ + ENTR_VERSION="5.8" ;\ + ENTR_SHAS="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ;\ + wget -q https://github.com/eradman/entr/archive/${ENTR_VERSION}.tar.gz --no-check-certificate ;\ + ENTR_SHA="$(sha256sum ${NODE_TAR} | cut -d" " -f1)" ;\ + echo "$ENTR_SHAS" | sed "s/ /\n/g" | grep -q "$ENTR_SHA" || { echo "SHA256 mismatch for ${ENTR_VERSION}.tar.gz ${ENTR_SHA}"; exit 1; } ;\ + mkdir entr ;\ + tar -C ${BUILD_DIR}/entr --strip-components 1 -xzf ${ENTR_VERSION}.tar.gz ;\ + rm ${ENTR_VERSION}.tar.gz' WORKDIR ${BUILD_DIR}/entr RUN ./configure && \ @@ -131,8 +128,7 @@ ENV ANTORA_SITE_START_PAGE="_" ENV ANTORA_CONTENT_SOURCES_CASSANDRA_URL="https://github.com/apache/cassandra.git" # changing the next line also needs updates to the move_intree_document_directories calls in prepare_site_html_for_publication in docker-entrypoint.sh ENV ANTORA_CONTENT_SOURCES_CASSANDRA_BRANCHES="trunk cassandra-5.0 cassandra-4.1 cassandra-4.0 cassandra-3.11" -# FIXME – we can't generate tags yet as in-tree doc/antora.yml doesn't specify specifc tag versions -ENV ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS="" + ENV ANTORA_CONTENT_SOURCES_CASSANDRA_START_PATH="doc" ENV ANTORA_CONTENT_SOURCES_CASSANDRA_WEBSITE_URL="https://github.com/apache/cassandra-website.git" diff --git a/site-content/docker-entrypoint.sh b/site-content/docker-entrypoint.sh index c07f0b329..03c09172f 100755 --- a/site-content/docker-entrypoint.sh +++ b/site-content/docker-entrypoint.sh @@ -54,14 +54,8 @@ generate_cassandra_versioned_docs() { # Make sure Antora includes the versioned Cassandra documentation as part of the output. ANTORA_CONTENT_SOURCE_REPOSITORIES+=(CASSANDRA) - - local commit_changes_to_branch="" - if [ "$(wc -w <<< "${GENERATE_CASSANDRA_VERSIONS}")" -gt 1 ] - then - commit_changes_to_branch="enabled" - else - commit_changes_to_branch="disabled" - fi + # Antora includes the versioned docs via git branches (that are never pushed) + local commit_changes_to_branch=$([ "$(wc -w <<< "${GENERATE_CASSANDRA_VERSIONS}")" -gt 1 ] && echo "enabled") pushd "${CASSANDRA_WORKING_DIR}" > /dev/null for version in ${GENERATE_CASSANDRA_VERSIONS} @@ -255,18 +249,14 @@ prepare_site_html_for_publication() { log_message "INFO" "Renaming master dropdown version to website" grep -lr 'index.html\">master</a>' content/Cassandra | xargs -I{} sed -i 's|index.html\">master</a>|index.html\">website</a>|' {} log_message "INFO" "Moving versioned documentation HTML to content/doc" - # FIXME – we can't generate tags yet as in-tree doc/antora.yml doesn't specify specifc tag versions, so just copy them for now (see same fixme in Dockerfile) - move_intree_document_directories "3.11" "3.11.11" "3.11.12" "3.11.13" "3.11.14" "3.11.15" "3.11.16" "3.11.17" "3.11.18" "3.11.19" - move_intree_document_directories "4.0" "4.0.0" "4.0.1" "4.0.2" "4.0.3" "4.0.4" "4.0.5" "4.0.6" "4.0.7" "4.0.8" "4.0.9" "4.0.10" "4.0.11" "4.0.12" "4.0.13" "4.0.14" "4.0.15" "4.0.16" "4.0.17" - move_intree_document_directories "4.1" "4.1.0" "4.1.1" "4.1.2" "4.1.3" "4.1.4" "4.1.5" "4.1.6" "4.1.7" "4.1.8" - move_intree_document_directories "5.0" "5.0.1" "5.0.2" "5.0.3" "5.0.4" "stable" "latest" - move_intree_document_directories "trunk" "5.1" + # move content/Cassandra subdirectories to content/doc, plus aliases + move_intree_document_directories "5.0" "stable" "latest" + move_remaining_cassandra_subdirectories fi popd > /dev/null } - move_intree_document_directories() { local source_doc_dir="$1" shift @@ -290,13 +280,27 @@ move_intree_document_directories() { rm -fR ${target_base_dir}/${source_doc_dir} mv ${source_base_dir}/${source_doc_dir} ${target_base_dir}/ fi +} + +move_remaining_cassandra_subdirectories() { + local source_base_dir="content/Cassandra" + local target_base_dir="content/doc" - # Check if our source directory is empty and if it is clean it up. - # Otherwise, leave it as is so we can see if we have missed a version. - if [ -d "${source_base_dir}" ] && [ -z "$(ls -A ${source_base_dir})" ] + # Copy all remaining subdirectories from content/Cassandra/ to content/doc/ + if [ -d "${source_base_dir}" ] then - rmdir "${source_base_dir}" + for subdir in ${source_base_dir}/* + do + if [ -d "${subdir}" ] + then + local dir_name=$(basename "${subdir}") + log_message "INFO" "Copying remaining directory ${dir_name} to content/doc/" + rm -fR ${target_base_dir}/${dir_name} + mv ${subdir} ${target_base_dir}/ + fi + done fi + rmdir "${source_base_dir}" } run_preview_mode() { @@ -368,8 +372,34 @@ log_message() { fi } +auto_generate_cassandra_tags() { + # list of all release tags (that can have dynamic antora.yml , ref CASSANDRA-17375) + TEMP_REPO_DIR=$(mktemp -d) + git clone --bare "${ANTORA_CONTENT_SOURCES_CASSANDRA_URL}" "${TEMP_REPO_DIR}" 2>/dev/null || true + if [ -d "${TEMP_REPO_DIR}" ]; then + AUTO_TAGS="" + for tag in $(cd "${TEMP_REPO_DIR}" && git tag -l 'cassandra-*' | sort -V); do + major_ver=$(echo "$tag" | sed 's/cassandra-\([0-9]*\).*/\1/') + if [ "$major_ver" -ge 5 ]; then + if ! (cd "${TEMP_REPO_DIR}" && git show "${tag}:doc/antora.yml" >/dev/null 2>&1); then + # This tag is post CASSANDRA-17375, so include in build + AUTO_TAGS="${AUTO_TAGS} ${tag}" + fi + fi + done + rm -rf "${TEMP_REPO_DIR}" + ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS="${AUTO_TAGS}" + fi +} + # ============ MAIN ============ +# Auto-generate list of release tags only if ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS is unset +# (not just empty - empty means custom repos/branches were provided without tags) +if [ -z "${ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS+x}" ]; then + auto_generate_cassandra_tags +fi + GENERATE_CASSANDRA_VERSIONS=$(sed 's/^[[:space:]]]*//' <<< "${ANTORA_CONTENT_SOURCES_CASSANDRA_BRANCHES} ${ANTORA_CONTENT_SOURCES_CASSANDRA_TAGS}") export GENERATE_CASSANDRA_VERSIONS export LOG_LEVEL_INT=$(log_level_str_to_int "${LOG_LEVEL}") --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
