Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=shop
POSTGRES_USER=user
POSTGRES_PASSWORD=password
REDIS_HOST=localhost
REDIS_PORT=6379
74 changes: 37 additions & 37 deletions .github/workflows/hw1-tests.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
name: "HW1 Tests"

# Запускаем тесты при изменении файлов в hw1/
on:
pull_request:
branches: [ main ]
paths: [ 'hw1/**' ]
push:
branches: [ main ]
paths: [ 'hw1/**' ]

jobs:
test-hw1:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
working-directory: hw1
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
working-directory: hw1
run: |
pytest test_app.py -v
#name: "HW1 Tests"
#
## Запускаем тесты при изменении файлов в hw1/
#on:
# pull_request:
# branches: [ main ]
# paths: [ 'hw1/**' ]
# push:
# branches: [ main ]
# paths: [ 'hw1/**' ]
#
#jobs:
# test-hw1:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.12", "3.13"]
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Install dependencies
# working-directory: hw1
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
#
# - name: Run tests
# working-directory: hw1
# run: |
# pytest test_app.py -v
78 changes: 39 additions & 39 deletions .github/workflows/hw2-tests.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
name: "HW2 Tests"

# Запускаем тесты при изменении файлов в hw2/hw/
on:
pull_request:
branches: [ main ]
paths: [ 'hw2/hw/**' ]
push:
branches: [ main ]
paths: [ 'hw2/hw/**' ]

jobs:
test-hw2:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
working-directory: hw2/hw
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
working-directory: hw2/hw
env:
PYTHONPATH: ${{ github.workspace }}/hw2/hw
run: |
pytest test_homework2.py -v
#name: "HW2 Tests"
#
## Запускаем тесты при изменении файлов в hw2/hw/
#on:
# pull_request:
# branches: [ main ]
# paths: [ 'hw2/hw/**' ]
# push:
# branches: [ main ]
# paths: [ 'hw2/hw/**' ]
#
#jobs:
# test-hw2:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.12", "3.13"]
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
#
# - name: Install dependencies
# working-directory: hw2/hw
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
#
# - name: Run tests
# working-directory: hw2/hw
# env:
# PYTHONPATH: ${{ github.workspace }}/hw2/hw
# run: |
# pytest test_homework2.py -v
111 changes: 111 additions & 0 deletions .github/workflows/hw5_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Vlad's tests

on:
push:
branches: [ main, develop, hw2 ]
paths: [ 'hw2/hw/**' ]
pull_request:
branches: [ main, develop, hw2 ]
paths: [ 'hw2/hw/**' ]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_DB: shop
POSTGRES_USER: user
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

prometheus:
image: prom/prometheus
ports:
- 9090:9090
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:9090/-/healthy || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5

grafana:
image: grafana/grafana
ports:
- 3000:3000
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd hw2/hw
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio requests uvicorn asyncpg redis

- name: Install redis-cli
run: |
sudo apt-get update
sudo apt-get install -y redis-tools

- name: Wait for databases to be ready
run: |
echo "Waiting for PostgreSQL..."
until pg_isready -h localhost -p 5432; do sleep 1; done
echo "Waiting for Redis..."
until redis-cli -h localhost ping | grep -q PONG; do sleep 1; done
echo "✅ All databases are ready"

- name: Start FastAPI app in background
run: |
cd hw2/hw
python -m uvicorn shop_api.main:app --host 0.0.0.0 --port 8080 &
echo "FastAPI app starting..."
sleep 15

- name: Check app health
run: |
echo "Checking if FastAPI app is healthy..."
curl -f http://localhost:8080/ || (echo "❌ FastAPI app not healthy"; exit 1)
echo "✅ FastAPI app is healthy"

- name: Run homework tests
run: |
cd hw2/hw
pytest test_my_test.py -v --cov=. --cov-report=term-missing

- name: Stop FastAPI app
if: always()
run: |
echo "Stopping FastAPI app..."
pkill -f "uvicorn" || true
Loading