Skip to content

tests

tests #15

Workflow file for this run

name: Backend Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: backend_test
ports:
- 5435:5432
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Install dependencies and set up RUM
run: |
python -m pip install --upgrade pip
pip install -r services/backend/requirements.txt
sudo apt-get update
sudo apt-get install -y git build-essential postgresql-server-dev-13 postgresql-13-rum
git clone https://github.com/postgrespro/rum /tmp/rum
cd /tmp/rum
make USE_PGXS=1
sudo make USE_PGXS=1 install
- name: Wait for Postgres
run: |
until pg_isready -h localhost -p 5435 -U postgres; do
echo "Waiting for postgres container..."
sleep 20
done
- name: Run Docker Compose
run: |
docker-compose -f docker-compose-dev.yml up --build -d
- name: Run tests
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5435/backend_dev
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5435/backend_test
APP_SETTINGS: project.config.TestingConfig
PYTHONPATH: services/backend
run: |
cd services/backend
export APP_SETTINGS=project.config.TestingConfig
export PYTHONPATH=$(pwd)
export DATABASE_TEST_URL=postgresql://postgres:postgres@localhost:5435/backend_test
export DATABASE_URL=postgresql://postgres:postgres@localhost:5435/backend_dev
pytest