From 1066f6a4276ad315bb704d21c65d3557f5286370 Mon Sep 17 00:00:00 2001 From: mck Date: Sun, 25 May 2025 18:27:30 +0200 Subject: [PATCH] Remove auto-installation of golang when generating native protocol doc pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit patch by Mick Semb Wever; reviewed by Štefan Miklošovič for CASSANDRA-20678 --- .build/docker/bullseye-build.docker | 21 +++++- ...process-native-protocol-specs-in-docker.sh | 67 ++++--------------- 2 files changed, 33 insertions(+), 55 deletions(-) diff --git a/.build/docker/bullseye-build.docker b/.build/docker/bullseye-build.docker index 6928ec9f29..b31bf03b3a 100644 --- a/.build/docker/bullseye-build.docker +++ b/.build/docker/bullseye-build.docker @@ -15,7 +15,7 @@ # limitations under the License. FROM debian:bullseye -MAINTAINER Apache Cassandra +LABEL org.opencontainers.image.authors="Apache Cassandra " # CONTEXT is expected to be cassandra/.build @@ -52,3 +52,22 @@ RUN pip install --upgrade pip # dependencies for .build/ci/ci_parser.py RUN pip install beautifulsoup4==4.12.3 jinja2==3.1.3 + +# install golang. GO_VERSION_SHA must be updated with VERSION +RUN sh -c '\ + GO_VERSION="1.24.3" ;\ + GO_VERSION_SHAS="3333f6ea53afa971e9078895eaa4ac7204a8c6b5c68c10e6bc9a33e8e391bdd8 a463cb59382bd7ae7d8f4c68846e73c4d589f223c589ac76871b66811ded7836 13e6fe3fcf65689d77d40e633de1e31c6febbdbcb846eb05fc2434ed2213e92b 64a3fa22142f627e78fac3018ce3d4aeace68b743eff0afda8aae0411df5e4fb" ;\ + GO_OS=linux ;\ + [ $(uname) = "Darwin" ] && GO_OS=darwin ;\ + GO_PLATFORM=amd64 ;\ + [ $(uname -m) = "aarch64" ] && GO_PLATFORM=arm64 ;\ + GO_TAR="go${GO_VERSION}.${GO_OS}-${GO_PLATFORM}.tar.gz" ;\ + curl -L --fail --silent --retry 2 --retry-delay 5 --max-time 30 https://go.dev/dl/$GO_TAR -o $GO_TAR ;\ + GO_SHA="$(sha256sum $GO_TAR | cut -d" " -f2)" ;\ + echo "$GO_VERSION_SHAS" | sed "s/ /\n/g" | grep -q "$GO_SHA" || { echo "SHA256 mismatch for $GO_TAR $GO_SHA"; exit 1; } ;\ + tar -C /usr/local -xzf $GO_TAR ;\ + rm $GO_TAR' + +ENV GOROOT="/usr/local/go" +ENV GOPATH="$BUILD_HOME/go" +ENV PATH="$PATH:/usr/local/go/bin" \ No newline at end of file diff --git a/doc/scripts/process-native-protocol-specs-in-docker.sh b/doc/scripts/process-native-protocol-specs-in-docker.sh index 05565c02b9..332310ab66 100755 --- a/doc/scripts/process-native-protocol-specs-in-docker.sh +++ b/doc/scripts/process-native-protocol-specs-in-docker.sh @@ -20,73 +20,27 @@ # Variables GO_VERSION="1.23.1" - -GO_OS=linux - -if [ $(uname) = "Darwin" ]; then - GO_OS=darwin -fi - -GO_PLATFORM=amd64 - -if [ $(uname -m) = "aarch64" ]; then - GO_PLATFORM=arm64 -fi - -GO_TAR="go${GO_VERSION}.${GO_OS}-${GO_PLATFORM}.tar.gz" TMPDIR="${TMPDIR:-/tmp}" check_go_version() { if command -v go &>/dev/null; then local installed_version=$(go version | awk '{print $3}' | sed 's/go//') - if [ "$(printf '%s\n' "$GO_VERSION" "$installed_version" | sort -V | head -n1)" = "$GO_VERSION" ]; then - echo "Detected Go $installed_version (>= $GO_VERSION), skipping installation." + echo "Detected Go $installed_version (>= $GO_VERSION)" return 0 else - if [ -z $installed_version ]; then - echo "No Go installation detected, proceeding with installation." - else - echo "Detected Go $installed_version (< $GO_VERSION), proceeding with installation." - fi - return 1 + echo "Detected unsupported Go $installed_version (< $GO_VERSION), please update to supported version." fi else - echo "Go env not found in your system, proceeding with installation." - return 1 + echo "No Go installation detected, please install Go (>= $GO_VERSION)" fi + return 1 } if ! check_go_version; then - - if ls $TMPDIR/go$GO_VERSION > /dev/null 2>&1; then - echo "Reusing cached installation in $TMPDIR/go$GO_VERSION" - export PATH="$PATH:$TMPDIR/go$GO_VERSION/go/bin" - export GOPATH="$TMPDIR/go$GO_VERSION/go/bin" - export GOROOT="$TMPDIR/go$GO_VERSION/go" - else - if ! ls $TMPDIR/$GO_TAR > /dev/null 2>&1; then - echo "Downloading Go $GO_VERSION..." - - curl -L --fail --silent --retry 2 --retry-delay 5 --max-time 30 https://golang.org/dl/$GO_TAR -o $TMPDIR/$GO_TAR - - if [ $? != "0" ]; then - echo "Network error. Specify '-Dant.gen-doc.skip=true' to skip if offline." - exit 1 - fi - fi - - echo "Installing Go $GO_VERSION..." - mkdir -p $TMPDIR/go$GO_VERSION - tar -C "$TMPDIR/go$GO_VERSION" -xzf "$TMPDIR/$GO_TAR" - - # Set Go environment variables - export PATH="$PATH:$TMPDIR/go$GO_VERSION/go/bin" - export GOPATH="$TMPDIR/go$GO_VERSION/go/bin" - export GOROOT="$TMPDIR/go$GO_VERSION/go" - fi -else - echo "Using system-installed Go." + echo " Please install/upgrade Golang for 'ant gen-doc', or specify '-Dant.gen-doc.skip=true' to skip this step." + echo " For download and installation instructions see https://go.dev/doc/install" + exit 1 fi # Step 1: Building the parser @@ -107,7 +61,7 @@ git sparse-checkout set --no-cone /cqlprotodoc git checkout cd "${TMPDIR}/cassandra-website/cqlprotodoc" rm -rf "${TMPDIR}/cqlprotodoc" -$TMPDIR/go$GO_VERSION/go/bin/go build -o "$TMPDIR"/cqlprotodoc +go build -o "$TMPDIR"/cqlprotodoc # Step 2: Process the spec files using the parser echo "Processing the .spec files..." @@ -116,6 +70,11 @@ output_dir="modules/cassandra/attachments" mkdir -p "${output_dir}" "$TMPDIR"/cqlprotodoc . "${output_dir}" +if ! ls ${output_dir}/native_protocol_v*.html > /dev/null 2>&1; then + echo "failed: No native_protocol_v*.html files generated in ${output_dir}" + exit 1 +fi + # Step 4: Generate summary file summary_file="modules/cassandra/pages/reference/native-protocol.adoc"