From 178db7508f83e55530ec3dc1ae143408d2c5ca41 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 11 Mar 2022 19:50:57 -0500 Subject: [PATCH] ci: docker: Wait for container to be healthy --- .github/workflows/docker.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e4db3663e..8d29fcef4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -39,9 +39,17 @@ jobs: - name: Test run: | - docker run --rm -d -p 9001:9001 ${{ env.TEST_TAG }} + docker run --rm -d -p 9001:9001 --name test ${{ env.TEST_TAG }} ./src/bin/installDeps.sh - sleep 3 + while true; do + echo "Waiting for Docker container to start..." + status=$(docker container inspect -f '{{.State.Health.Status}}' test) || exit 1 + case ${status} in + healthy) break;; + starting) sleep 2;; + *) printf %s\\n "unexpected status: ${status}" >&2; exit 1;; + esac + done (cd src && npm run test-container) git clean -dxf . -