Skip to content

Commit

Permalink
feat: github actions for backend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienc91 committed Sep 7, 2024
1 parent 0276595 commit c47ba78
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Lint
working-directory: ./backend/
run: |
uvx ruff check .
uvx ruff format --check .
test-backend:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: tests
POSTGRES_DB: tests
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:latest
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
env:
REDIS_PASSWORD: tests

steps:
- uses: actions/checkout@v4
- name: Install dependencies
working-directory: ./backend/
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv sync --extra tests
- name: Tests
working-directory: ./backend/
run: |
python manage.py migrate
pytest --create-db
env:
HOST_NAME: caviardeul.dev
DJANGO_SECRET_KEY: tests
POSTGRES_DB: tests
POSTGRES_USER: postgres
POSTGRES_PASSWORD: tests
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
REDIS_PASSWORD: tests
REDIS_HOST: redis
REDIS_PORT: 6379
SMTP_HOSTNAME: localhost
SMTP_PORT: 465
SMTP_LOGIN: mail
SMTP_PASSWORD: tests
EMAIL_FROM: [email protected]
1 change: 0 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
DEBUG=0
HOST_NAME=caviardeul.fr
DATABASE_URL="postgresql://postgres:5432/caviardeul"
DJANGO_SECRET_KEY=
DJANGO_SETTINGS_MODULE=caviardeul.settings

Expand Down
3 changes: 1 addition & 2 deletions backend/caviardeul/serializers/custom_article.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Literal

from pydantic import Field

from ninja import Schema
from pydantic import Field

from caviardeul.serializers.article import BaseEncryptedArticleSchema

Expand Down
2 changes: 1 addition & 1 deletion backend/caviardeul/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
if item
]
EMAIL_HOST = os.environ["SMTP_HOSTNAME"]
EMAIL_PORT = int(os.environ["SMTP_PORT"])
EMAIL_PORT = int(os.environ.get("SMTP_PORT", 465))
EMAIL_USE_SSL = os.environ.get("SMTP_USE_SSL", EMAIL_PORT == 465)
EMAIL_USE_TLS = os.environ.get("SMTP_USE_TLS", EMAIL_PORT == 587)
EMAIL_HOST_PASSWORD = os.environ["SMTP_PASSWORD"]
Expand Down

0 comments on commit c47ba78

Please sign in to comment.