Skip to content

Commit

Permalink
feat: GitHub action for tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsDemetrio authored Jun 15, 2024
1 parent a4632e7 commit d4a1d69
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linting and Testing

on:
push:
branches: [ main ]
pull_request:

jobs:
job:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

- name: Install Python environment
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel # Upgrade pip first
pip install -r requirements.txt # Install project dependencies
- name: Lint with Ruff
run: |
pip install ruff
ruff --output-format=github .
- name: Start MongoDB (in-memory)
uses: supercharge/[email protected]
with:
mongodb-version: "7.0"

- name: Run Pytest
run: pytest
env:
MONGO_URL: mongodb://localhost:27017
4 changes: 3 additions & 1 deletion app/get_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def get_context():
settings: Settings = Settings()
logger: Logger = Logger(settings.log_level).get_logger()
client: Client = Client(settings.mongo_url, settings.database_name)
pwd_context: CryptContext = CryptContext(schemes=["bcrypt"], deprecated="auto")
pwd_context: CryptContext = CryptContext(
schemes=["bcrypt"], deprecated="auto"
)

return {
"settings": settings,
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async def db_health(ctx: Context):
client: Client = ctx.get("client")

logger.debug("DB Health check requested")
documents_in_config_coll = client.get_config_collection().estimated_document_count(
{}
documents_in_config_coll = (
client.get_config_collection().estimated_document_count({})
)

return {"status": "OK", "existingConfigs": documents_in_config_coll}
Expand Down

0 comments on commit d4a1d69

Please sign in to comment.