Skip to content

Commit

Permalink
fix: trying to fix ci.yml error
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeversiane committed Jun 13, 2024
1 parent 1edb9e1 commit 95c64ae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Docker Compose
run: docker-compose -f docker-compose.ci.yml up -d --build
run: docker-compose -f docker-compose.ci.yml up -d --build --no-cache

- name: Wait for API to be ready
run: ./sh/wait-for-it.sh localhost:${{ secrets.PORT }} --timeout=60

- name: Run project
run: make ci
Expand Down
32 changes: 32 additions & 0 deletions sh/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Use this script to wait for a service to become available

TIMEOUT=15
while getopts t: option
do
case "${option}"
in
t) TIMEOUT=${OPTARG};;
esac
done

shift $((OPTIND -1))
HOST=$1
PORT=$2

if [ -z "$HOST" ] || [ -z "$PORT" ]; then
echo "Usage: $0 host port [-t timeout]"
exit 1
fi

for i in `seq $TIMEOUT` ; do
nc -z $HOST $PORT > /dev/null 2>&1
result=$?
if [ $result -eq 0 ] ; then
exit 0
fi
sleep 1
done

echo "Timeout: Unable to connect to $HOST:$PORT"
exit 1

0 comments on commit 95c64ae

Please sign in to comment.