Update README.md #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies and RUM extension | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r services/backend/requirements.txt | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install -y git build-essential postgresql-server-dev-13 postgresql-13 | |
git clone https://github.com/postgrespro/rum /tmp/rum | |
cd /tmp/rum | |
export PATH=/usr/lib/postgresql/13/bin:$PATH | |
export PG_CONFIG=/usr/lib/postgresql/13/bin/pg_config | |
make USE_PGXS=1 | |
sudo make USE_PGXS=1 install | |
- name: Wait for Postgres | |
run: | | |
until pg_isready -h localhost -p 5432 -U postgres; do | |
echo "Waiting for postgres container..." | |
sleep 20 | |
done | |
- name: Set up Docker | |
run: | | |
docker-compose -f docker-compose-dev.yml up --build -d | |
sleep 20 | |
- name: Run tests | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432/backend_dev | |
DATABASE_TEST_URL: postgres://postgres:postgres@localhost:5432/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:5432/backend_test | |
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/backend_dev | |
pytest |