Skip to content

refactor: migrate from Sqlite to MongoDB #285

refactor: migrate from Sqlite to MongoDB

refactor: migrate from Sqlite to MongoDB #285

Workflow file for this run

---
name: "Automated Tests"
on:
workflow_dispatch:
push:
paths:
- ".github/workflows/automated-tests.yml"
- ".github/actions/**"
- "**.py"
- "pyproject.toml"
- "poetry.lock"
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- ".github/workflows/automated-tests.yml"
- ".github/actions/**"
- "**.py"
- "pyproject.toml"
- "poetry.lock"
env:
VALENTINA_LOG_FILE: "/tmp/valentina.log"
VALENTINA_DB_PATH: "/tmp/valentina.sqlite"
VALENTINA_TEST_MONGO_URI: "mongodb://localhost:27017"
VALENTINA_TEST_MONGO_DATABASE_NAME: "valentina-test"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-python-code:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.11", "3.12"]
mongodb-version: ["7.0.2"]
steps:
- name: Harden Security Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit
disable-sudo: true
allowed-endpoints: >
api.github.com:443
api.snapcraft.io:443
codecov.io:443
files.pythonhosted.org:443
github.com:443
install.python-poetry.org:443
pypi.org:443
python-poetry.org:443
randomuser.me:443
storage.googleapis.com:443
uploader.codecov.io:443
# ----------------------------------------------
# Install python and checkout repository
# ----------------------------------------------
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repository
uses: actions/checkout@v4
# ----------------------------------------------
# install Mongo
# ----------------------------------------------
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
# ----------------------------------------------
# Install poetry and project dependencies
# ----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# Load cached venv if cache exists
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# Install dependencies if cache does not exist
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
# ----------------------------------------------
# run linters
# ----------------------------------------------
- name: lint with ruff
run: poetry run ruff --extend-ignore=I001,D301,D401 src/
- name: check pyproject.toml
run: poetry run poetry check
# ----------------------------------------------
# run test suite
# ----------------------------------------------
- name: Run tests with pytest
run: |
poetry run coverage run
poetry run coverage report
poetry run coverage xml
# ----------------------------------------------
# upload coverage stats
# ----------------------------------------------
- name: Upload coverage
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: reports/coverage.xml
fail_ci_if_error: true