Skip to content

Commit

Permalink
Wait and retry checking for services to be up in Github pipeline (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
andymantell authored Jan 10, 2025
1 parent e407fbf commit 8b4f57e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,23 @@ up: compose.override.yml ## Start Docker containers
.PHONY: up

verify-up: compose.override.yml ## Verify if all Docker containers have run
@docker compose ps -a --format json | jq --exit-status 'select(.ExitCode != 0 or (.Health != "healthy" and .Health != ""))' && exit 1 || echo "All services up"
@timeout=60; \
interval=5; \
while [ $$timeout -gt 0 ]; do \
if docker compose ps -a --format json | jq --exit-status 'select(.ExitCode != 0 or (.Health != "healthy" and .Health != ""))' > /dev/null; then \
echo "Waiting for services to be healthy..."; \
sleep $$interval; \
timeout=$$(($$timeout - $$interval)); \
else \
echo "All services up"; \
exit 0; \
fi; \
done; \
echo "Services did not become healthy in time"; \
exit 1
.PHONY: verify-up


down: ## Destroy Docker containers
@docker compose down
.PHONY: down
Expand Down

0 comments on commit 8b4f57e

Please sign in to comment.