Skip to content

Commit

Permalink
fix(ci): fix check-links querying wrong host
Browse files Browse the repository at this point in the history
For reasons I don't understand, something changed on CI which makes our
server only listen on IPv6 (localhost is ::1) and our check-links.mjs
client only connect on IPv4 (localhost is 127.0.0.1). This causes our
website job to fail.

Work around this issue by explicitly using an address (::1 in this
case) instead of writing 'localhost'.
  • Loading branch information
strager committed Aug 18, 2024
1 parent 1fb746e commit bc0fdbf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ jobs:

- name: check links (dev)
run: |
# HACK(strager): We write "::1" instead of "localhost" because the
# latter listens on IPv6 but connects on IPv4 for some reason.
server_process_is_alive() {
kill -0 "${server_pid}"
}
http_server_is_running() {
curl_status=0
curl --no-progress-meter --head -o /dev/null 'http://localhost:9001/' || curl_status="${?}"
curl --no-progress-meter --head -o /dev/null 'http://[::1]:9001/' || curl_status="${?}"
if [ "${curl_status}" -eq 7 ]; then # 7 is 'Failed to connect to host.'
return 1
fi
Expand All @@ -69,14 +72,14 @@ jobs:
set -x
cd website/
yarn start localhost 9001 &
yarn start ::1 9001 &
server_pid="${!}"
cd ../
while server_process_is_alive && ! http_server_is_running; do
sleep 0.1
done
./website/tools/check-links.mjs http://localhost:9001/
./website/tools/check-links.mjs http://[::1]:9001/
kill "${server_pid}"
shell: bash

Expand Down

0 comments on commit bc0fdbf

Please sign in to comment.