Setup test database for CI #3
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: Run Tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
test: | ||
name: Run Pytest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10.16' | ||
- name: Install Dependencies | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
pip install -U pip | ||
pip install -r requirements/dev.txt | ||
- name: Set DATABASE_URL | ||
run: echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/modernism" >> $GITHUB_ENV | ||
- name: Run Pytest | ||
run: | | ||
source venv/bin/activate | ||
PYTHONPATH=$PYTHONPATH:app/ pytest --maxfail=1 --exitfirst | ||
postgres: | ||
image: postgres:14 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: modernism | ||
options: >- | ||
--health-cmd="pg_isready -U postgres" | ||
--health-interval=10s | ||
--health-timeout=5s | ||
--health-retries=5 |