This commit is contained in:
56
.gitea/workflows/deploy.yml
Normal file
56
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
name: Deploy to Server
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up SSH
|
||||||
|
uses: webfactory/ssh-agent@v0.5.0
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SERVER_SSH_KEY }}
|
||||||
|
|
||||||
|
- name: Add server to known hosts
|
||||||
|
run: |
|
||||||
|
ssh-keyscan -H v3.dscrs.site >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Configure Git
|
||||||
|
run: |
|
||||||
|
git config --global user.email "gitea-actions@dscrs.site"
|
||||||
|
git config --global user.name "Gitea Actions"
|
||||||
|
|
||||||
|
- name: Prepare deployment
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git add .
|
||||||
|
git commit -m "Prepare for deployment: $(date +'%Y-%m-%d %H:%M:%S')"
|
||||||
|
|
||||||
|
- name: Deploy to Server
|
||||||
|
env:
|
||||||
|
SERVER_HOST: v3.dscrs.site
|
||||||
|
SERVER_USER: dokku
|
||||||
|
APP_NAME: core
|
||||||
|
run: |
|
||||||
|
git remote add dokku dokku@$SERVER_HOST:$APP_NAME
|
||||||
|
git push dokku HEAD:main -f
|
||||||
|
|
||||||
|
- name: Notify Deployment
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
echo "Deployment to $APP_NAME successful"
|
||||||
|
|
||||||
|
- name: Handle Deployment Failure
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
echo "Deployment failed"
|
||||||
|
exit 1
|
@@ -24,13 +24,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
branch: 'main'
|
branch: 'main'
|
||||||
git_remote_url: 'ssh://dokku@v2.discours.io:22/discoursio-api'
|
git_remote_url: 'ssh://dokku@v2.discours.io:22/discoursio-api'
|
||||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
ssh_private_key: ${{ secrets.PROD_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Push to v3.dscrs.site branch
|
- name: Push to v3.dscrs.site branch
|
||||||
if: github.ref == 'refs/heads/dev'
|
if: github.ref == 'refs/heads/dev'
|
||||||
uses: dokku/github-action@master
|
uses: dokku/github-action@master
|
||||||
with:
|
with:
|
||||||
branch: 'dev'
|
branch: 'dev'
|
||||||
git_remote_url: 'ssh://dokku@v3.dscrs.site:22/core'
|
git_remote_url: 'ssh://dokku@staging.discours.io:22/core'
|
||||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
git_push_flags: '--force'
|
git_push_flags: '--force'
|
||||||
|
65
.gitea/workflows/tests.yml
Normal file
65
.gitea/workflows/tests.yml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
name: Notification Module Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
- 'feature/*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.9', '3.10', '3.11']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y python3-dev libpq-dev
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install poetry
|
||||||
|
poetry config virtualenvs.create false
|
||||||
|
poetry install --no-interaction --no-ansi
|
||||||
|
|
||||||
|
- name: Run type checking
|
||||||
|
run: |
|
||||||
|
pip install mypy
|
||||||
|
mypy orm/notification.py
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
pip install pytest
|
||||||
|
pytest tests/test_notification.py -v
|
||||||
|
|
||||||
|
- name: Lint with ruff
|
||||||
|
run: |
|
||||||
|
pip install ruff
|
||||||
|
ruff check orm/notification.py
|
||||||
|
ruff format --check orm/notification.py
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: ./coverage.xml
|
||||||
|
flags: unittests
|
||||||
|
env_vars: OS,PYTHON
|
||||||
|
name: codecov-umbrella
|
||||||
|
fail_ci_if_error: true
|
40
.github/workflows/tests.yml
vendored
Normal file
40
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: Notification Module Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, develop, feature/* ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: [3.9, 3.10, 3.11]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install -r requirements.dev.txt
|
||||||
|
|
||||||
|
- name: Run mypy type checking
|
||||||
|
run: mypy orm/notification.py
|
||||||
|
|
||||||
|
- name: Run pytest for notification module
|
||||||
|
run: |
|
||||||
|
pytest tests/test_notification.py -v
|
||||||
|
|
||||||
|
- name: Lint with ruff
|
||||||
|
run: |
|
||||||
|
ruff check orm/notification.py
|
||||||
|
ruff format --check orm/notification.py
|
40
tests/test_notification.py
Normal file
40
tests/test_notification.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from orm.notification import (
|
||||||
|
NotificationStatus,
|
||||||
|
NotificationKind,
|
||||||
|
NotificationEntity,
|
||||||
|
NotificationAction,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_notification_status():
|
||||||
|
"""Тестирование перечисления статусов уведомлений."""
|
||||||
|
assert NotificationStatus.UNREAD == NotificationStatus.from_string("UNREAD")
|
||||||
|
assert NotificationStatus.READ == NotificationStatus.from_string("READ")
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
NotificationStatus.from_string("INVALID_STATUS")
|
||||||
|
|
||||||
|
def test_notification_kind():
|
||||||
|
"""Тестирование перечисления типов уведомлений."""
|
||||||
|
assert NotificationKind.COMMENT == NotificationKind.from_string("COMMENT")
|
||||||
|
assert NotificationKind.MENTION == NotificationKind.from_string("MENTION")
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
NotificationKind.from_string("INVALID_KIND")
|
||||||
|
|
||||||
|
def test_notification_entity():
|
||||||
|
"""Тестирование перечисления сущностей уведомлений."""
|
||||||
|
assert NotificationEntity.TOPIC == NotificationEntity.from_string("topic")
|
||||||
|
assert NotificationEntity.SHOUT == NotificationEntity.from_string("shout")
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
NotificationEntity.from_string("INVALID_ENTITY")
|
||||||
|
|
||||||
|
def test_notification_action():
|
||||||
|
"""Тестирование перечисления действий уведомлений."""
|
||||||
|
assert NotificationAction.CREATE == NotificationAction.from_string("create")
|
||||||
|
assert NotificationAction.UPDATE == NotificationAction.from_string("update")
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
NotificationAction.from_string("INVALID_ACTION")
|
Reference in New Issue
Block a user