diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index e3e9b28..89a9c48 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -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 diff --git a/.github/workflows/smoke_test.sh b/.github/workflows/smoke_test.sh new file mode 100755 index 0000000..b220b47 --- /dev/null +++ b/.github/workflows/smoke_test.sh @@ -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