Skip to content

fix: Improve MongoDB configuration in GitHub Actions workflow #9

fix: Improve MongoDB configuration in GitHub Actions workflow

fix: Improve MongoDB configuration in GitHub Actions workflow #9

Workflow file for this run

name: Python application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:4.4
ports:
- 27017:27017
options: >-
--health-cmd mongosh --eval "db.adminCommand('ping')"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MONGODB_URI: mongodb://localhost:27017
MONGODB_DATABASE: test_db
SECRET_KEY: test_secret_key
JWT_SECRET: test_jwt_secret
PYTHONPATH: ${{ github.workspace }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
pip install pymongo pytest pytest-cov
- name: Wait for MongoDB
run: |
timeout 30 bash -c 'until mongosh --eval "db.adminCommand(\"ping\")" > /dev/null 2>&1; do sleep 1; done'
- name: Run tests
run: |
python -m pytest tests/ -v --cov=src