Skip to content

Commit

Permalink
Added different way to setup docker
Browse files Browse the repository at this point in the history
  • Loading branch information
MarhiievHE committed Dec 31, 2023
1 parent 6e86274 commit 45abd34
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,41 @@ 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
mkdir pgdata
cd pgdata
# initdb
rm -rf /usr/local/var/postgresql@14/*
initdb --locale=C -E UTF-8 /usr/local/var/postgresql@14
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
until pg_isready -h localhost -p 5432 && redis-cli ping; do sleep 5; done
- name: Set up PostgreSQL (on MacOS)
if: runner.os == 'macos'
run: |
echo $PGDATA
cd database
bash setup.sh
- name: Setup pg (on Windows)
if: runner.os == 'windows'
Expand Down Expand Up @@ -73,13 +100,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..."
Expand All @@ -88,6 +116,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..."
Expand All @@ -114,4 +143,5 @@ jobs:
MODE: test

- name: Stop containers
if: runner.os == 'ubuntu'
run: docker-compose down

0 comments on commit 45abd34

Please sign in to comment.