Skip to content

Commit

Permalink
Modify github action
Browse files Browse the repository at this point in the history
  • Loading branch information
MacBook Pro authored and MacBook Pro committed Nov 14, 2024
1 parent 007ae97 commit dfad634
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,51 @@ permissions:
contents: read

jobs:
build:

test:
runs-on: ubuntu-latest

services:
# Настройка PostgreSQL сервиса
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: app_admin
POSTGRES_PASSWORD: pswd
POSTGRES_DB: test_db
options: >-
--health-cmd="pg_isready -U user"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
# Устанавливаем переменные окружения для подключения к базе
DATABASE_URL: postgresql://app_admin:pswd@localhost:5432/test_db

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Check out the code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run migrations
run: |
alembic upgrade head # или другой инструмент миграции, если используете
- name: Run tests
env:
# Устанавливаем URL базы для тестов
DATABASE_URL: postgresql://user:password@localhost:5432/test_db
run: |
pytest

0 comments on commit dfad634

Please sign in to comment.