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

Add margin_app pipeline #635

Merged
merged 9 commits into from
Feb 24, 2025
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
50 changes: 50 additions & 0 deletions .github/workflows/margin_app_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Margin Tests

on:
push:
branches:
- main
paths:
- 'margin_app/**'
pull_request:
branches:
- main
paths:
- 'margin_app/**'
jobs:
shared:
uses: ./.github/workflows/shared_workflow.yml
with:
python-version: "3.12"

margin-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Create .env file
run: cp margin_app/.env.dev margin_app/.env

- name: Build and Start Containers
run: |
docker compose -f margin_app/docker-compose.yml --env-file margin_app/.env up -d --build
echo "Waiting for containers to be ready..."
sleep 30

- name: Run Integration Tests with Coverage
run: |
docker compose -f margin_app/docker-compose.yml exec backend python -m pytest app/tests -v

- name: Clean Up
if: always()
run: |
docker compose -f margin_app/docker-compose.yml logs > docker-logs.txt || true
docker compose -f margin_app/docker-compose.yml down -v

- name: Upload Docker Logs on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: docker-logs
path: docker-logs.txt
8 changes: 8 additions & 0 deletions margin_app/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APP_ENV=development
SECRET_KEY=SECRET_KEY

# Database creds
POSTGRES_USER=user
POSTGRES_PASSWORD=password
POSTGRES_DB=db_name
DB_HOST=db
2 changes: 0 additions & 2 deletions margin_app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ POSTGRES_USER=user
POSTGRES_PASSWORD=password
POSTGRES_DB=db_name
DB_HOST=localhost
DATABASE_URL=postgresql+asyncpg://user:***@localhost:5432/db_name

1 change: 0 additions & 1 deletion margin_app/app/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
database_url = os.getenv("DATABASE_URL")

config.set_main_option(
"sqlalchemy.url", settings.db_url.render_as_string(hide_password=False)
Expand Down
12 changes: 12 additions & 0 deletions margin_app/app/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Test to check if worklow works properly"""

import pytest

@pytest.fixture
def sample_data():
"""Test fixture"""
return {"key": "value"}

def test_sample(sample_data):
"""Test function"""
assert sample_data["key"] == "value"
4 changes: 1 addition & 3 deletions margin_app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

networks:
app_network:
driver: bridge
Expand All @@ -23,7 +21,7 @@ services:
networks:
- app_network
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${DB_USER}" ]
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER}" ]
interval: 10s
timeout: 5s
retries: 5
Expand Down
292 changes: 279 additions & 13 deletions margin_app/poetry.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions margin_app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ greenlet = "^3.1.1"
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
argon2-cffi = "^23.1.0"
alembic-postgresql-enum = "^1.7.0"
pytest = "^8.3.4"
pytest-asyncio = "^0.25.3"
pytest-mock = "^3.14.0"
pytest-env = "^1.1.5"
pytest-cov = "^6.0.0"
trio = "^0.29.0"


[build-system]
Expand Down