Skip to content

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
MarhiievHE committed Jan 26, 2024
1 parent a00a1ab commit 29672e6
Showing 1 changed file with 57 additions and 24 deletions.
81 changes: 57 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,35 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install PostgreSQL and Redis (on MacOS)
- name: Setup (on MacOS)
if: runner.os == 'macOS'
run: |
brew install redis
brew services start postgresql
brew services start redis
- name: Check services status (on MacOS)
if: runner.os == 'macOS'
run: |
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: |
createuser -s postgres
cd database
bash setup.sh
- name: Setup pg (on Windows)
# - name: Check services status (on MacOS)
# if: runner.os == 'macOS'
# run: |
# 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: |
# createuser -s postgres
# cd database
# bash setup.sh

- name: Setup (on Windows)
if: runner.os == 'Windows'
run: |
#postgres
echo "unix_socket_directories = ''" >> "$PGDATA/postgresql.conf"
echo "port = 5432" >> "$PGDATA/postgresql.conf"
$PG_BIN = "C:\Program Files\PostgreSQL\14\bin"
Expand All @@ -53,9 +60,7 @@ jobs:
cd database
bash setup.sh
- name: Setup redis (on Windows)
if: runner.os == 'Windows'
run: |
#redis
$URL = "https://github.com/redis-windows/redis-windows/releases/download/7.0.14/Redis-7.0.14-Windows-x64-with-Service.tar.gz"
$outputFolder = "C:\redis"
Expand All @@ -73,28 +78,56 @@ jobs:
sc.exe create Redis binpath=C:\redis\RedisService.exe start= auto
net start Redis
# - name: Setup redis (on Windows)
# if: runner.os == 'Windows'
# run: |
# $URL = "https://github.com/redis-windows/redis-windows/releases/download/7.0.14/Redis-7.0.14-Windows-x64-with-Service.tar.gz"
# $outputFolder = "C:\redis"

# if (-not (Test-Path $outputFolder)) {
# New-Item -ItemType Directory -Path $outputFolder | Out-Null
# }

# Invoke-WebRequest -Uri $URL -OutFile "redis.tar.gz"
# tar -xf "redis.tar.gz" -C $outputFolder
# $innerFolder = Get-ChildItem -Path $outputFolder | Select-Object -First 1
# Move-Item -Path "$outputFolder\$($innerFolder.Name)\*" -Destination $outputFolder -Force
# Remove-Item -Path "$outputFolder\$($innerFolder.Name)" -Force

# cd $outputFolder
# sc.exe create Redis binpath=C:\redis\RedisService.exe start= auto
# net start Redis

- name: Start docker containers
if: runner.os == 'Linux'
run: |
docker-compose -f test-docker-compose.yml up -d pg-example redis-example
- name: Wait for PostgreSQL to become healthy
if: runner.os == 'Linux'
run: |
while [[ "$(docker inspect --format='{{.State.Health.Status}}' pg-example)" != "healthy" ]]; do
echo "Waiting for PostgreSQL container to become healthy..."
sleep 5
echo "Waiting for PostgreSQL container to become healthy..."
sleep 5
done
timeout-minutes: 5

- name: Wait for Redis to become healthy
if: runner.os == 'Linux'
run: |
while [[ "$(docker inspect --format='{{.State.Health.Status}}' redis-example)" != "healthy" ]]; do
echo "Waiting for Redis container to become healthy..."
sleep 5
done
timeout-minutes: 5
# - name: Wait for PostgreSQL to become healthy
# if: runner.os == 'Linux'
# run: |
# while [[ "$(docker inspect --format='{{.State.Health.Status}}' pg-example)" != "healthy" ]]; do
# echo "Waiting for PostgreSQL container to become healthy..."
# sleep 5
# done
# timeout-minutes: 5

# - name: Wait for Redis to become healthy
# if: runner.os == 'Linux'
# run: |
# while [[ "$(docker inspect --format='{{.State.Health.Status}}' redis-example)" != "healthy" ]]; do
# echo "Waiting for Redis container to become healthy..."
# sleep 5
# done
# timeout-minutes: 5

- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
Expand All @@ -114,6 +147,6 @@ jobs:
env:
MODE: test

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

0 comments on commit 29672e6

Please sign in to comment.