Skip to content

Feat/1825 comment spam detection phase 1 #1762

Feat/1825 comment spam detection phase 1

Feat/1825 comment spam detection phase 1 #1762

Workflow file for this run

name: Run Backend Unit Tests
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- "main"
concurrency:
# Cancel previous jobs
group: unit_tests-${{ github.ref }}
cancel-in-progress: true
jobs:
backend-unit-tests:
runs-on: ubuntu-latest
environment: testing_env
env:
TEST_DATABASE_URL: "postgres://postgres:postgres@localhost:5432/test_metaculus"
services:
db:
image: pgvector/pgvector:pg16
env:
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: test_metaculus
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: "bitnami/redis:7.2.5"
env:
ALLOW_EMPTY_PASSWORD: yes
ports:
- 6379:6379
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12.3"
- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
installer-parallel: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run Flake8 Linter
if: ${{ !cancelled() }}
run: poetry run flake8 . --exclude=front_end,.venv
- name: Check migrations
if: ${{ !cancelled() }}
run: poetry run python manage.py makemigrations --dry-run --check
- name: "Run he backend unit tests"
if: ${{ !cancelled() }}
run: poetry run pytest ./tests/unit