Skip to content

Commit

Permalink
Add a smoke test for the application
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienRichez committed Oct 4, 2023
1 parent b3903eb commit 8a99753
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ jobs:
distribution: 'adopt'
- name: Run tests
run: sbt test
- name: Smoke test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: .github/workflows/smoke_test.sh
36 changes: 36 additions & 0 deletions .github/workflows/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail

TRY_COUNT=30
sbt stage

cd target/universal/stage

APPLICATION_SECRET="9w/DBOjdTE?65hO5IzGu_XL5^AiK^>iUZgIF?mYVUbPNjNU[ver>zw[V@zlbb0wu" access_token=$GITHUB_TOKEN bin/lunatech-blog-engine &

PID=$!
trap "kill $! 2> /dev/null" EXIT

is_running() {
kill -0 $PID 2> /dev/null
}

is_responding() {
curl localhost:9000 -s -o /dev/null
}

for (( count=0; count < $TRY_COUNT; count++ )); do
if ! is_running; then
echo "::error::The application stopped before it could serve a page."
exit 1
fi

if is_responding; then
exit 0
fi

sleep 3
done

echo "::error::Timeout: the application did not serve a page in time."
exit 2

0 comments on commit 8a99753

Please sign in to comment.