Skip to content

CI test workflow LFG #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
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
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test

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

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
poetry-version: [latest]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: test_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Install project
run: poetry install

- name: Set env variables for pytest
run: |
echo "DB_USER=postgres" >> $GITHUB_ENV
echo "DB_PASSWORD=postgres" >> $GITHUB_ENV
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=5432" >> $GITHUB_ENV
echo "DB_NAME=test_db" >> $GITHUB_ENV
echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV

- name: Verify environment variables
run: |
echo "Checking if required environment variables are set..."
[ -n "$DB_USER" ] && \
[ -n "$DB_PASSWORD" ] && \
[ -n "$DB_HOST" ] && \
[ -n "$DB_PORT" ] && \
[ -n "$DB_NAME" ] && \
[ -n "$SECRET_KEY" ]

- name: Run type checking with mypy
run: poetry run mypy .

- name: Run tests with pytest
run: poetry run pytest -s tests/
4 changes: 1 addition & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ToDo: Add CSRF protection to all POST, download, and sensitive data routes

import logging
from typing import Optional
from contextlib import asynccontextmanager
Expand Down Expand Up @@ -201,7 +199,7 @@ async def read_terms_of_service(params: dict = Depends(common_unauthenticated_pa
return templates.TemplateResponse(params["request"], "terms_of_service.html", params)


@app.get("/reset_password")
@app.get("/auth/reset_password")
async def read_reset_password(
email: str,
token: str,
Expand Down