From bd05378197d2f909a9777426e3b72588f039c380 Mon Sep 17 00:00:00 2001 From: Heorhii Date: Sun, 31 Dec 2023 00:52:11 +0100 Subject: [PATCH] Added different way to setup docker --- .github/workflows/test-macos.yml | 41 +++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index e63b59b9..691772be 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -24,14 +24,34 @@ jobs: - name: Setup docker (missing on MacOS) if: runner.os == 'macos' run: | - brew install docker - brew install docker-compose - mkdir -p ~/.docker/cli-plugins - ln -sfn /usr/local/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose - colima start - # For testcontainers to find the Colima socket - # https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running - sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock + # brew install docker + # brew install docker-compose + # mkdir -p ~/.docker/cli-plugins + # ln -sfn /usr/local/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose + + # colima start + # # For testcontainers to find the Colima socket + # # https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running + # sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker. + + - name: Install PostgreSQL and Redis (on MacOS) + if: runner.os == 'macos' + run: | + brew install postgresql + brew install redis + brew services start postgresql + brew services start redis + + - name: Check services status (on MacOS) + if: runner.os == 'macos' + run: | + until brew services list | grep -E 'postgresql[[:space:]]+started' && brew services list | grep -E 'redis[[:space:]]+started'; do sleep 5; done + + - name: Set up PostgreSQL (on MacOS) + if: runner.os == 'macos' + run: | + cd atabase + ./setup.sh - name: Setup pg (on Windows) if: runner.os == 'windows' @@ -73,13 +93,14 @@ jobs: net start Redis - name: Start docker containers - if: runner.os != 'windows' + if: runner.os == 'ubuntu' run: | docker-compose -f test-docker-compose.yml up -d pg-example redis-example # sleep 15 # wait for database to be ready # docker ps - name: Wait for PostgreSQL to become healthy + if: runner.os == 'ubuntu' run: | while [[ "$(docker inspect --format='{{.State.Health.Status}}' pg-example)" != "healthy" ]]; do echo "Waiting for PostgreSQL container to become healthy..." @@ -88,6 +109,7 @@ jobs: timeout-minutes: 5 - name: Wait for Redis to become healthy + if: runner.os == 'ubuntu' run: | while [[ "$(docker inspect --format='{{.State.Health.Status}}' redis-example)" != "healthy" ]]; do echo "Waiting for Redis container to become healthy..." @@ -114,4 +136,5 @@ jobs: MODE: test - name: Stop containers + if: runner.os == 'ubuntu' run: docker-compose down