Skip to content

Commit

Permalink
fix env vars and add smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Aug 2, 2024
1 parent d6617d7 commit fd3d661
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ concurrency:

jobs:
docker:
name: 🔨 Docker build
name: 🚢 Docker build
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Docker build
run: ./scripts/build
- name: 🔨 Docker build
run: ./scripts/build

- name: 🔥 Smoke test
run: ./scripts/smoke-test
4 changes: 2 additions & 2 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ NAME=epikinetics-app
ORG=seroanalytics
PACKAGE_ROOT="${HERE}/.."

if [ -z "$GITHUB_REF" ]; then
if [ -z "$GITHUB_REF_NAME" ]; then
GIT_BRANCH=$(git -C "$PACKAGE_ROOT" symbolic-ref --short HEAD)
GIT_ID=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD)
else
GIT_BRANCH=$GITHUB_REF
GIT_BRANCH=$GITHUB_REF_NAME
GIT_ID=$(echo $GITHUB_SHA | cut -c1-7)
fi

Expand Down
34 changes: 34 additions & 0 deletions scripts/smoke-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

HERE=$(realpath "$(dirname $0)")
. $HERE/common

wait_for()
{
echo "waiting up to $TIMEOUT seconds for app"
start_ts=$(date +%s)
for i in $(seq $TIMEOUT); do
result="$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:3000 2>/dev/null)"
if [[ $result -eq "200" ]]; then
end_ts=$(date +%s)
echo "App available after $((end_ts - start_ts)) seconds"
break
fi
sleep 1
echo "...still waiting"
done
return $result
}

docker run -d -p 3000:3000 $DOCKER_COMMIT_TAG

# The variable expansion below is 60s by default, or the argument provided
# to this script
TIMEOUT="${1:-60}"
wait_for
RESULT=$?
if [[ $RESULT -ne 200 ]]; then
echo "App did not become available in time"
exit 1
fi
exit 0
7 changes: 7 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
check=$(curl -s -vv -I http://localhost:3000 2>/dev/null | grep "HTTP/2 200")
#echo $check
if [[ -z $check ]] ; then
echo "Cnxn failed"
else
echo "Cnxn successful"
fi

0 comments on commit fd3d661

Please sign in to comment.