-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: run a server smoke test in the pipeline
This verifies the server can launch with all the default settings.
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# This script launches the Cognito Local server, then polls the server until the /health endpoint | ||
# responds with a 200. If the server doesn't respond in time, or exits with a non-zero code, the | ||
# script will fail. | ||
# | ||
# We run this in CI to prove the actual server can start. This catches some edge-cases where | ||
# everything else passes, but something in the compile produced invalid JavaScript. | ||
|
||
export PORT=59232 | ||
yarn start & | ||
PID=$! | ||
|
||
trap "kill $PID" SIGINT | ||
|
||
PORT=$PORT timeout --foreground -s TERM 30 bash -c \ | ||
'while [[ ${STATUS_RECEIVED} != 200 ]];\ | ||
do STATUS_RECEIVED=$(curl -s -o /dev/null -L -w ''%{http_code}'' http://localhost:$PORT/health) && \ | ||
echo "received status: $STATUS_RECEIVED" && \ | ||
sleep 1;\ | ||
done; | ||
echo success with status: $STATUS_RECEIVED' | ||
CURL_EXIT_CODE=$? | ||
|
||
kill $PID | ||
|
||
if [[ $CURL_EXIT_CODE -ne 0 ]]; then | ||
echo Failed to start in time >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters