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

[99] Bug pytest db rollback #105

Merged
merged 13 commits into from
Sep 23, 2024
27 changes: 26 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ on:
branches:
- '*'

env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres

jobs:
geral:
run-tests:
runs-on: ubuntu-latest

services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Check out code
Expand All @@ -20,6 +41,10 @@ jobs:
- name: Poetry Install
uses: knowsuchagency/poetry-install@v2

- name: Create Tables
run: |
PGPASSWORD=${{env.POSTGRES_PASSWORD}} psql -U ${{env.POSTGRES_USER}} -d ${{env.POSTGRES_DB}} -h ${{env.POSTGRES_HOST}} -a -f ${{github.workspace}}/database_scripts/postgres.sql

- name: Run pytest
run: poetry run pytest

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ services:
volumes:
- ./logs/:/var/log
- ./promtail.yml:/etc/promtail/config.yml
env_file:
- .env
entrypoint: >
/bin/bash -c "/usr/bin/promtail -config.expand-env=true -config.file /etc/promtail/config.yml"
8 changes: 1 addition & 7 deletions labs/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,19 @@
GITHUB_USERNAME = os.environ.get("GITHUB_USERNAME")
GITHUB_API_BASE_URL = "https://api.github.com"

TEST_ENVIRONMENT = eval(os.environ.get("TEST_ENVIRONMENT", False))
TEST_ENVIRONMENT = eval(os.environ.get("TEST_ENVIRONMENT", "False"))

LITELLM_MASTER_KEY = os.environ.get("LITELLM_MASTER_KEY")
LITELLM_API_KEY = os.environ.get("LITELLM_API_KEY")


CLONE_DESTINATION_DIR = os.getenv("CLONE_DESTINATION_DIR", "tmp/")
LLM_MODEL_NAME = os.getenv("LLM_MODEL_NAME", "openai/gpt-4o")

ACTIVELOOP_TOKEN = os.environ["ACTIVELOOP_TOKEN"]

OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
COHERE_API_KEY = os.environ.get("COHERE_API_KEY")
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")


ACTIVELOOP_TOKEN = os.environ.get("ACTIVELOOP_TOKEN")

DATABASE_HOST = os.environ.get("DATABASE_HOST")
DATABASE_USER = os.environ.get("DATABASE_USER")
DATABASE_PASS = os.environ.get("DATABASE_PASS")
Expand Down
2 changes: 1 addition & 1 deletion labs/github/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get(self, url, headers={}, params={}):
logger.exception("Missing key in access data.")
except Exception:
logger.exception("An unexpected error occurred.")
return None
return None, 500

def _post(self, url, headers={}, data={}):
try:
Expand Down
20 changes: 12 additions & 8 deletions labs/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ def setup_logger():
formatter = logging.Formatter(fmt=log_format, datefmt=LOG_FORMAT)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)

formatter = CustomJsonFormatter()
handler = RotatingFileHandler(
"logs/debug.log", maxBytes=DEFAULT_MAX_BYTES, backupCount=DEFAULT_BACKUP_COUNT
)
handler.setFormatter(formatter)

logger.addHandler(stream_handler)
logger.addHandler(handler)

try:
formatter = CustomJsonFormatter()
handler = RotatingFileHandler(
"logs/debug.log",
maxBytes=DEFAULT_MAX_BYTES,
backupCount=DEFAULT_BACKUP_COUNT,
)
handler.setFormatter(formatter)
logger.addHandler(handler)
except Exception:
pass
166 changes: 0 additions & 166 deletions labs/test/test_GithubRequests.py

This file was deleted.

Loading
Loading