From 239ad3a09904755ad3a672a81994d36e11e72fdf Mon Sep 17 00:00:00 2001 From: Robert Young Date: Fri, 31 Oct 2025 09:55:03 +1300 Subject: [PATCH] Add /get-started which redirects to the latest quickstart Why: I want a permanent and snappy URL that redirects to the latest proxy quick start so that I can embed it in videos etc. This should be long lasting so I've added simple tests (invoked at the end of build.sh) to check that the page, target page and link are what we expect. Signed-off-by: Robert Young --- _layouts/redirect.html | 2 +- build.sh | 1 + get-started.markdown | 5 +++++ test.sh | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 get-started.markdown create mode 100755 test.sh diff --git a/_layouts/redirect.html b/_layouts/redirect.html index 949977af..de02649a 100644 --- a/_layouts/redirect.html +++ b/_layouts/redirect.html @@ -1,5 +1,5 @@ -{% assign absolute_target = page.target | absolute_url %} +{% assign absolute_target = page.target | replace: '$$LATEST_RELEASE$$', site.data.kroxylicious.latestRelease | absolute_url %} diff --git a/build.sh b/build.sh index 95484c3a..eaa6276d 100755 --- a/build.sh +++ b/build.sh @@ -34,3 +34,4 @@ BUILD_COMMAND='eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/ RUN_ARGS+=(bash -c "${BUILD_COMMAND}") echo "${RUN_ARGS[@]}" ${CONTAINER_ENGINE} run "${RUN_ARGS[@]}" +./test.sh diff --git a/get-started.markdown b/get-started.markdown new file mode 100644 index 00000000..bc243d76 --- /dev/null +++ b/get-started.markdown @@ -0,0 +1,5 @@ +--- +layout: redirect +target: "/documentation/$$LATEST_RELEASE$$/html/proxy-quick-start/" +delay: 1 +--- diff --git a/test.sh b/test.sh new file mode 100755 index 00000000..99e42762 --- /dev/null +++ b/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Checks the output of build.sh (which is the production build deployed to pages) +set -euo pipefail + +LATEST_RELEASE=$(grep "latestRelease:" _data/kroxylicious.yml | awk '{print $2}') + +LATEST_RELEASE_QUICKSTART="_site/documentation/${LATEST_RELEASE}/html/proxy-quick-start/index.html" +PERMANENT_QUICKSTART_REDIRECT="_site/get-started.html" +EXPECTED_REDIRECT_STRING="" + +check_file_exists() { + local file_path="$1" + local file_description="$2" + if [ -f "${file_path}" ]; then + echo "SUCCESS: ${file_description} file found at ${file_path}" + else + echo "ERROR: ${file_description} file not found at ${file_path}" >&2 + exit 1 + fi +} + +echo "Expect /get-started to HTML redirect to the latest quickstart" +check_file_exists "${LATEST_RELEASE_QUICKSTART}" "Latest release quickstart" +check_file_exists "${PERMANENT_QUICKSTART_REDIRECT}" "Permanent quickstart redirect" + +if grep -qF "${EXPECTED_REDIRECT_STRING}" "${PERMANENT_QUICKSTART_REDIRECT}"; then + echo "SUCCESS: Expected redirect string found in ${PERMANENT_QUICKSTART_REDIRECT}" +else + echo "ERROR: Expected redirect string '${EXPECTED_REDIRECT_STRING}' not found in ${PERMANENT_QUICKSTART_REDIRECT}" + exit 1 +fi +echo "All checks succeeded!" +exit 0