Update test_user_service.yml #9
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: | |
- feature/user_service | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: user_service_db | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: 1234 | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Load Database Schema | |
run: | | |
cd user_service | |
PGPASSWORD=1234 psql -h localhost -U postgres -d user_service_db -a -f ./scheme.sql | |
- name: Install Poetry | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Install dependencies | |
run: | | |
cd user_service | |
poetry install | |
- name: Set up environment variables | |
run: | | |
echo "SECRET_KEY=random_key" >> user_service/.env | |
echo "TEST=True" >> user_service/.env | |
echo "FASTAPI_IP=127.0.0.1" >> user_service/.env | |
echo "FASTAPI_PORT=8001" >> user_service/.env | |
echo "POSTGRES_HOST=localhost" >> user_service/.env | |
echo "POSTGRES_PORT=5432" >> user_service/.env | |
echo "POSTGRES_DB=user_service_db" >> user_service/.env | |
echo "POSTGRES_USER=postgres" >> user_service/.env | |
echo "POSTGRES_PASSWORD=1234" >> user_service/.env | |
- name: Run tests | |
run: | | |
cd user_service | |
poetry run python -m pytest tests |