Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
abraryaser02 committed May 10, 2024
1 parent 2a2a443 commit 67b639b
Showing 1 changed file with 28 additions and 38 deletions.
66 changes: 28 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
name: Backend Test
name: Python Tests

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:

name: Run pytest
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: backend_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
# Wait until postgres is ready before running the tests
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
- 5435:5432
options: --health-check pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r services/backend/requirements.txt
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Create test database
run: |
psql -U postgres -c "CREATE DATABASE backend_test;"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- 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
pytest
- name: Run tests
env:
APP_SETTINGS: project.config.TestingConfig
DATABASE_URL: postgresql://postgres:postgres@localhost:5435/backend_test
run: |
python -m pytest services/backend/tests

0 comments on commit 67b639b

Please sign in to comment.