Skip to content

Commit

Permalink
Add basic CI to build and test
Browse files Browse the repository at this point in the history
Use docker compose to build and start the app and then verify that it
started.
  • Loading branch information
parberge committed Sep 26, 2023
1 parent 7374281 commit 5bf7679
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build & test
on: [push]
jobs:
build:
name: Build and verify stack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup environment
run: |
cp .env-example .env
- name: Build and start the stack
run: |
docker-compose up --build -d
- name: Verify that the stack is running
run: |
bash ci-verify.sh
if [ $? -ne 0 ]; then
docker compose logs
exit 1
fi
shell: bash
20 changes: 20 additions & 0 deletions ci-verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SUCCESS=0

for try in {1..3}; do
status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:3000)
if [[ "$status_code" -eq 200 ]] ; then
SUCCESS=1
break
else
echo "Attempt $try failed with status code $status_code"
fi
sleep 10
done

if [[ "$SUCCESS" -eq 1 ]] ; then
echo "Stack seems to be working 🎉"
exit 0
else
echo "Stack is not working 😭"
exit 1
fi

0 comments on commit 5bf7679

Please sign in to comment.