Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"check:html": "html-validate public",
"check:links": "deadlinks-linux public",
"check:redirects": "tests/redirect.sh -s",
"checks": "run-s check:links check:html",
"checks": "run-s check:links check:html check:redirects",
"clean": "gulp clean",
"check:dependencies": "run-p check:cache check:dedupe",
"check:cache": "yarn workspaces foreach install --immutable --immutable-cache --check-cache",
Expand Down
36 changes: 30 additions & 6 deletions tests/redirect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ if [ "$SERVE" == 1 ]; then
fi
fi

# make sure we can reach the web site
CURL_CMD=curl
set +e
$CURL_CMD -sS -k -o /dev/null --retry-all-errors --retry-delay 3 --retry 5 "$BASE_URL" || {
set -e
if [ -n "${CONTAINER_ID+x}" ]; then
echo Reverting to using curl from within the HTTP container
$CONTAINER_CMD exec "$CONTAINER_ID" apt-get update -y
$CONTAINER_CMD exec "$CONTAINER_ID" apt-get install -y curl
CURL_CMD="$CONTAINER_CMD exec $CONTAINER_ID curl"
BASE_URL=https://localhost
$CURL_CMD -sS -k -o /dev/null --retry-all-errors --retry-delay 3 --retry 5 "$BASE_URL"
else
exit 1
fi
}
set -e

TOTAL=0
SUCCESS=0

Expand All @@ -98,7 +116,7 @@ function test {

local output
set +e
output=$(curl -k -w '%{http_code},%{redirect_url}\n' -o /dev/null -s "${url}")
output=$($CURL_CMD -k -w '%{http_code},%{redirect_url}' -o /dev/null -s "${url}")
set -e
TOTAL=$((TOTAL + 1))

Expand All @@ -112,12 +130,18 @@ function test {
fi
}

HTACCESS_FILE="$GIT_ROOT/documentation/.htaccess"
if [ ! -f "$HTACCESS_FILE" ]; then
echo "No $HTACCESS_FILE found, using last published version. If you have made changes to the Antora playbook make sure to build the site first to test those."
$CURL_CMD -s -o "$HTACCESS_FILE" 'https://gitbox.apache.org/repos/asf?p=camel-website.git;a=blob_plain;f=.htaccess;hb=refs/heads/asf-site'
fi

# determine current _latest_ versions
COMPONENTS_VERSION="$(grep 'components/latest' "$GIT_ROOT/documentation/.htaccess" | grep -Z -o '[^/]*$')"
CAMEL_K_VERSION="$(grep 'camel-k/latest' "$GIT_ROOT/documentation/.htaccess" | grep -Z -o '[^/]*$')"
CAMEL_KAFKA_CONNECTOR_VERSION="$(grep 'camel-kafka-connector/latest' "$GIT_ROOT/documentation/.htaccess" | grep -Z -o '[^/]*$')"
CAMEL_QUARKUS_VERSION="$(grep 'camel-quarkus/latest' "$GIT_ROOT/documentation/.htaccess" | grep -Z -o '[^/]*$')"
CAMEL_KAMELETS_VERSION="$(grep 'camel-kamelets/latest' "$GIT_ROOT/documentation/.htaccess" | grep -Z -o '[^/]*$')"
COMPONENTS_VERSION="$(grep '^Redirect 302 /components/latest' "$HTACCESS_FILE" | grep -Z -o '[^/]*$')"
CAMEL_K_VERSION="$(grep '^Redirect 302 /camel-k/latest' "$HTACCESS_FILE" | grep -Z -o '[^/]*$')"
CAMEL_KAFKA_CONNECTOR_VERSION="$(grep '^Redirect 302 /camel-kafka-connector/latest' "$HTACCESS_FILE" | grep -Z -o '[^/]*$')"
CAMEL_QUARKUS_VERSION="$(grep '^Redirect 302 /camel-quarkus/latest' "$HTACCESS_FILE" | grep -Z -o '[^/]*$')"
CAMEL_KAMELETS_VERSION="$(grep '^Redirect 302 /camel-kamelets/latest' "$HTACCESS_FILE" | grep -Z -o '[^/]*$')"

#
# TESTS
Expand Down