CI/CD working Fixed a couple of linting issues. Reviewed-on: #3
This commit is contained in:
parent
4eca8e0f8e
commit
da56d7e427
20
.drone.yml
20
.drone.yml
|
|
@ -1,15 +1,29 @@
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: default
|
name: default
|
||||||
|
type: docker
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: unittest
|
- name: unitest
|
||||||
image: python
|
image: python
|
||||||
commands:
|
commands:
|
||||||
- pip install -r requirements_test.txt
|
- pip install -r requirements_test.txt
|
||||||
- ./scripts/run_tests.sh
|
- ./scripts/drone/setup.sh
|
||||||
|
- ./scripts/drone/test.sh
|
||||||
|
depends_on:
|
||||||
|
- clone
|
||||||
|
|
||||||
settings:
|
- name: lint
|
||||||
|
image: python
|
||||||
|
commands:
|
||||||
|
- pip install -r requirements_test.txt
|
||||||
|
- ./scripts/drone/lint.sh
|
||||||
|
depends_on:
|
||||||
|
- clone
|
||||||
|
|
||||||
|
settings:
|
||||||
username:
|
username:
|
||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
password:
|
password:
|
||||||
from_secret: gitea_password
|
from_secret: gitea_password
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,19 @@ load_dotenv()
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
# Configs loaded from env or defaults
|
||||||
SECRET_KEY = get_config("SECRET_KEY")
|
SECRET_KEY = get_config("SECRET_KEY")
|
||||||
DEBUG = get_config("DEBUG")
|
DEBUG = get_config("DEBUG")
|
||||||
|
|
||||||
ALLOWED_HOSTS = get_config("ALLOWED_HOSTS")
|
ALLOWED_HOSTS = get_config("ALLOWED_HOSTS")
|
||||||
|
DB_SQLITE_ABSOLUTE_PATH = get_config("DB_SQLITE_ABSOLUTE_PATH")
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
"default": {
|
||||||
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
|
"NAME": BASE_DIR / "db.sqlite3",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
|
@ -64,19 +73,6 @@ TEMPLATES = [
|
||||||
|
|
||||||
WSGI_APPLICATION = 'lockbox.wsgi.application'
|
WSGI_APPLICATION = 'lockbox.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
|
|
||||||
DB_SQLITE_ABSOLUTE_PATH = get_config("DB_SQLITE_ABSOLUTE_PATH")
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
|
@ -110,7 +106,11 @@ STATICFILES_DIRS = [
|
||||||
]
|
]
|
||||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
STORAGES = {
|
||||||
|
"staticfiles": {
|
||||||
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
MEDIA_ROOT = BASE_DIR / "media"
|
MEDIA_ROOT = BASE_DIR / "media"
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class FileChunkSerializer(serializers.ModelSerializer):
|
||||||
file = File.objects.get(lid=data["file"])
|
file = File.objects.get(lid=data["file"])
|
||||||
|
|
||||||
if data["size"] > file.max_size_chunk_bytes:
|
if data["size"] > file.max_size_chunk_bytes:
|
||||||
detail = f"'size' param is larger than max chunk size for file, {data["size"]} > {file.max_size_chunk_bytes}"
|
detail = f"'size' param is larger than max chunk size for file:\
|
||||||
|
{data["size"]} > {file.max_size_chunk_bytes}"
|
||||||
raise serializers.ValidationError(detail)
|
raise serializers.ValidationError(detail)
|
||||||
return data
|
return data
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
from common.constants import (
|
from common.constants import (
|
||||||
UPLOAD_STATUS_TYPES,
|
UPLOAD_STATUS_TYPES,
|
||||||
)
|
)
|
||||||
from common.utils import get_config
|
|
||||||
|
# from common.utils import get_config
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
from user.models import LockboxUser
|
|
||||||
|
|
||||||
|
# from user.models import LockboxUser
|
||||||
from storage.models import File, FileChunk
|
from storage.models import File, FileChunk
|
||||||
from storage.serializers import FileChunkSerializer, FileSerializer
|
from storage.serializers import FileChunkSerializer, FileSerializer
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from user.models import LockboxUser
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db()
|
@pytest.mark.django_db()
|
||||||
class TestUser:
|
class TestUser:
|
||||||
|
|
@ -7,4 +9,6 @@ class TestUser:
|
||||||
Test user related functions are working correctly.
|
Test user related functions are working correctly.
|
||||||
"""
|
"""
|
||||||
def test_stub(self):
|
def test_stub(self):
|
||||||
assert True
|
user = LockboxUser.objects.create(alias="TestUser", username="meow")
|
||||||
|
loaded_user = LockboxUser.objects.filter(alias="TestUser").first()
|
||||||
|
assert user.lid == loaded_user.lid
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ exclude = [
|
||||||
".pyenv*",
|
".pyenv*",
|
||||||
".git",
|
".git",
|
||||||
".venv",
|
".venv",
|
||||||
|
"manage.py",
|
||||||
]
|
]
|
||||||
force-exclude = true
|
force-exclude = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
printf "\n\n|| Starting ruff check ||\n\n"
|
||||||
|
ruff check --config=./pyproject.toml
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
cd lockbox
|
||||||
|
printf "\n\n|| Starting setup ||\n\n"
|
||||||
|
python manage.py migrate
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
cd lockbox
|
||||||
|
printf "\n\n|| Starting pytest run ||\n\n"
|
||||||
|
pytest --cov=. --cov-report term-missing --reuse-db
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
cd lockbox
|
|
||||||
pytest --cov=. --cov-report term-missing
|
|
||||||
Loading…
Reference in New Issue