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
26 changes: 12 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,18 @@ jobs:
- run:
name: Smoke test quick start redirects
command: |
status=$(curl --header "x-forwarded-proto: https" \
--silent --output /dev/null -w "%{http_code}" \
http://localhost:3001/docs/quick-start-guide)
if [ ${status} -ne 200 ]; then
echo "Expect a 200 status code, got ${status}"
exit 1
fi
status=$(curl --header "x-forwarded-proto: https" \
--silent --output /dev/null -w "%{http_code}" \
http://localhost:3001/docs/quick-start-guide/)
if [ ${status} -ne 301 ]; then
echo "Expect a 301 status code, got ${status}"
exit 1
fi
./bin/assert-success.sh /docs/quick-start-guide
./bin/assert-redirect.sh /docs/quick-start-guide/ \
https://localhost/docs/quick-start-guide
- run:
name: Test website redirects
command: |
./bin/assert-redirect.sh /tutorials https://ably.com/tutorials
- run:
name: Test client library redirects
command: |
./bin/assert-redirect.sh /client-lib-development-guide \
https://sdk.ably.com/builds/ably/specification/main/

workflows:
test_branch:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ graphql-types.ts
cli
dist
config/nginx-redirects.conf
/config/nginx.conf
/logs/
37 changes: 37 additions & 0 deletions bin/assert-redirect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

#
# A utility script to assert redirects served up by nginx
#
# Usage: assert-redirects.sh PATH DESTINATION_URL
#
# - PATH - Local URL path, like /docs
# - DESTINATION_URL - Destination URL the direct goes to

FROM=${1}
TO=${2}

if [[ -z $FROM || -z $TO ]]; then
echo "Usage: assert-redirects.sh PATH DESTINATION_URL"
exit 1
fi

OUTPUT=$(curl --header "X-Forwarded-Proto: https" \
--silent --output /dev/null \
--write-out "%{http_code} %{redirect_url}" \
http://localhost:3001${FROM})

CODE=$(echo $OUTPUT | cut -f 1 -d " ")
URL=$(echo $OUTPUT | cut -f 2 -d " ")

if [ ${CODE} -ne 301 ]; then
echo "Expect a 301 status code, got '${CODE}'"
exit 1
fi

if [ ${URL} != ${TO} ]; then
echo "Expected ${FROM} to redirect to ${TO}, got '${URL}' instead"
exit 1
fi

echo "OK: '${FROM}' redirects to '${TO}'"
27 changes: 27 additions & 0 deletions bin/assert-success.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#
# A utility script to assert successful responses served up by nginx
#
# Usage: assert-success.sh PATH
#
# - PATH - Local URL path, like /docs

URI_PATH=${1}

if [[ -z $URI_PATH ]]; then
echo "Usage: assert-success.sh PATH"
exit 1
fi

CODE=$(curl --header "X-Forwarded-Proto: https" \
--silent --output /dev/null \
--write-out "%{http_code}" \
http://localhost:3001${URI_PATH})

if [ ${CODE} -ne 200 ]; then
echo "Expect a 200 status code, got '${CODE}'"
exit 1
fi

echo "OK: '${URI_PATH}' returned a 200 status code"
13 changes: 13 additions & 0 deletions config/client-lib-development-guide-redirects.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These pages for the client library development guides used to be accessible
# on docs.ably.com, but have moved to sdk.ably.com and are no longer available
# in the Gatsby toolchain.

/client-lib-development-guide/comet https://sdk.ably.com/builds/ably/specification/main/comet/;
/client-lib-development-guide/encryption https://sdk.ably.com/builds/ably/specification/main/encryption/;
/client-lib-development-guide/feature-prioritisation https://sdk.ably.com/builds/ably/specification/main/feature-prioritisation/;
/client-lib-development-guide/features https://sdk.ably.com/builds/ably/specification/main/features/;
/client-lib-development-guide/protocol https://sdk.ably.com/builds/ably/specification/main/protocol/;
/client-lib-development-guide/test-api https://sdk.ably.com/builds/ably/specification/main/test-api/;
/client-lib-development-guide/versioning https://sdk.ably.com/builds/ably/specification/main/versioning/;
/client-lib-development-guide/websocket https://sdk.ably.com/builds/ably/specification/main/websocket/;
/client-lib-development-guide https://sdk.ably.com/builds/ably/specification/main/;
2 changes: 2 additions & 0 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ http {
# Creates a map of redirects for us
map $uri $redirected_url {
default "none";
include website-redirects.conf;
include client-lib-development-guide-redirects.conf;
<% if File.exists?(File.dirname(__FILE__) + '/nginx-redirects.conf') %>
include nginx-redirects.conf;
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions config/website-redirects.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Redirect pages that used to be available in the nanoc toolchain, back
# to the website where people should be accessing them

~^/tutorials(.*)$ https://ably.com/tutorials$1;