Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
wait for server shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
rylew1 committed May 18, 2024
1 parent 841c408 commit d3f928a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/ci-frontend-a11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ jobs:
run: npm run dev &

- name: Wait for server to be ready
run: npx wait-on http://localhost:3000 --timeout 60000 --log-level verbose
run: |
# Ensure the server wait script is executable
chmod +x ./wait-for-server.sh
./wait-for-server.sh
shell: bash

- name: Run pa11y-ci
run: npm run test:pa11y 2>&1 | tee pa11y_output.txt
Expand Down
30 changes: 30 additions & 0 deletions frontend/bin/wait-for-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# wait-for-server.sh

#!/bin/bash
set -e

# Color formatting for readability
GREEN='\033[0;32m'
RED='\033[0;31m'
NO_COLOR='\033[0m'

MAX_WAIT_TIME=800 # seconds, adjust as necessary
WAIT_TIME=0

echo "Waiting for server to become ready..."

# Use curl to check the server health endpoint
until curl --output /dev/null --silent --head --fail http://localhost:3000;
do
printf '.'
sleep 5

WAIT_TIME=$(($WAIT_TIME + 5))
if [ $WAIT_TIME -gt $MAX_WAIT_TIME ]
then
echo -e "${RED}ERROR: Server did not become ready within ${MAX_WAIT_TIME} seconds.${NO_COLOR}"
exit 1
fi
done

echo -e "${GREEN}Server is ready after ~${WAIT_TIME} seconds.${NO_COLOR}"

0 comments on commit d3f928a

Please sign in to comment.