Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow will install Python dependencies and run tests with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Create test environment file
working-directory: ./app
run: |
echo '${{ secrets.TEST_ENV_FILE }}' > .env.test
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install dependencies
working-directory: ./app
run: |
python -m pip install --upgrade pip
pip install pip-tools
pip-sync
- name: Test database connection
working-directory: ./app
run: |
python -c "
from dotenv import load_dotenv
load_dotenv('.env.test')
import psycopg2
import os
try:
conn = psycopg2.connect(
host=os.getenv('DB_HOST'),
database=os.getenv('DB_DATABASE'),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
port=os.getenv('DB_PORT')
)
print('Database connection successful')
conn.close()
except Exception as e:
print(f'Database connection failed: {e}')
exit(1)
"
- name: Test with pytest
working-directory: ./app
run: |
python -m pytest