Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in Makefile and Workflows #23

Merged
merged 5 commits into from
Apr 6, 2024
Merged
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
30 changes: 20 additions & 10 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
name: Python package
name: Python tests

on:
pull_request:


jobs:
test:
name: Unit tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-p 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up docker
uses: docker-practice/actions-setup-docker@master
- name: Run postgres
run: |
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-test postgres:15-alpine
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: |
python -m ensurepip
Expand All @@ -28,8 +33,10 @@ jobs:
run: |
DB_DSN=postgresql://postgres@localhost:5432/postgres alembic upgrade head
- name: Build coverage file
id: pytest
run: |
DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=marketing_api tests/ | tee pytest-coverage.txt
exit ${PIPESTATUS[0]}
- name: Print report
if: always()
run: |
Expand All @@ -48,6 +55,10 @@ jobs:
remove-link-from-badge: false
junitxml-path: ./pytest.xml
junitxml-title: Summary
- name: Fail on pytest errors
if: steps.pytest.outcome == 'failure'
run: exit 1

linting:
runs-on: ubuntu-latest
steps:
Expand All @@ -60,9 +71,8 @@ jobs:
requirementsFiles: "requirements.txt requirements.dev.txt"
- uses: psf/black@stable
- name: Comment if linting failed
if: ${{ failure() }}
if: failure()
uses: thollander/actions-comment-pull-request@v2
with:
message: |
:poop: Code linting failed, use `black` and `isort` to fix it.

6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ format:
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./marketing_api
source ./venv/bin/activate && isort ./marketing_api
source ./venv/bin/activate && black ./marketing_api
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests
source ./venv/bin/activate && isort ./tests
source ./venv/bin/activate && black ./tests
source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations
source ./venv/bin/activate && isort ./migrations
source ./venv/bin/activate && black ./migrations

db:
docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-marketing-backend postgres:15
Expand Down
2 changes: 1 addition & 1 deletion marketing_api/routes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
description='API для проведения маркетинговых исследований',
version=__version__,
# Настраиваем интернет документацию
root_path=settings.ROOT_PATH if __version__ != 'dev' else '/',
root_path=settings.ROOT_PATH if __version__ != 'dev' else '',
docs_url=None if __version__ != 'dev' else '/docs',
redoc_url=None,
)
Expand Down
1 change: 1 addition & 0 deletions migrations/versions/0ea7185ac58b_useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-05-05 12:25:03.383848

"""

import sqlalchemy as sa
from alembic import op

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Create Date: 2023-03-16 21:02:42.333305

"""
import sqlalchemy as sa

from alembic import op


Expand Down
1 change: 1 addition & 0 deletions migrations/versions/d1136ec942ac_no_nesessary_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-16 21:31:00.557581

"""

import sqlalchemy as sa
from alembic import op

Expand Down
1 change: 1 addition & 0 deletions migrations/versions/e2c2d4fe34f1_auth_user_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-16 21:13:20.798843

"""

import sqlalchemy as sa
from alembic import op

Expand Down
1 change: 1 addition & 0 deletions migrations/versions/f2d45b6daecf_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-08-27 00:59:23.669445

"""

import sqlalchemy as sa
from alembic import op

Expand Down
1 change: 0 additions & 1 deletion tests/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from fastapi.testclient import TestClient
from pytest_mock import MockerFixture
from sqlalchemy.orm import Session


def test_can_post_without_user_id(client: TestClient):
Expand Down
Loading