CI/CD working Fixed a couple of linting issues. Reviewed-on: #3
This commit is contained in:
parent
4eca8e0f8e
commit
da56d7e427
34
.drone.yml
34
.drone.yml
|
|
@ -1,15 +1,29 @@
|
|||
kind: pipeline
|
||||
name: default
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: unittest
|
||||
image: python
|
||||
commands:
|
||||
- pip install -r requirements_test.txt
|
||||
- ./scripts/run_tests.sh
|
||||
- name: unitest
|
||||
image: python
|
||||
commands:
|
||||
- pip install -r requirements_test.txt
|
||||
- ./scripts/drone/setup.sh
|
||||
- ./scripts/drone/test.sh
|
||||
depends_on:
|
||||
- clone
|
||||
|
||||
- name: lint
|
||||
image: python
|
||||
commands:
|
||||
- pip install -r requirements_test.txt
|
||||
- ./scripts/drone/lint.sh
|
||||
depends_on:
|
||||
- clone
|
||||
|
||||
settings:
|
||||
username:
|
||||
from_secret: gitea_username
|
||||
password:
|
||||
from_secret: gitea_password
|
||||
|
||||
|
||||
settings:
|
||||
username:
|
||||
from_secret: gitea_username
|
||||
password:
|
||||
from_secret: gitea_password
|
||||
|
|
@ -11,10 +11,19 @@ load_dotenv()
|
|||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Configs loaded from env or defaults
|
||||
SECRET_KEY = get_config("SECRET_KEY")
|
||||
DEBUG = get_config("DEBUG")
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -64,19 +73,6 @@ TEMPLATES = [
|
|||
|
||||
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
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||
|
||||
|
|
@ -110,7 +106,11 @@ STATICFILES_DIRS = [
|
|||
]
|
||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||
STATIC_URL = 'static/'
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
STORAGES = {
|
||||
"staticfiles": {
|
||||
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
||||
},
|
||||
}
|
||||
|
||||
# Storage
|
||||
MEDIA_ROOT = BASE_DIR / "media"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class FileChunkSerializer(serializers.ModelSerializer):
|
|||
file = File.objects.get(lid=data["file"])
|
||||
|
||||
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)
|
||||
return data
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
from common.constants import (
|
||||
UPLOAD_STATUS_TYPES,
|
||||
)
|
||||
from common.utils import get_config
|
||||
|
||||
# from common.utils import get_config
|
||||
from rest_framework import status
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from user.models import LockboxUser
|
||||
|
||||
# from user.models import LockboxUser
|
||||
from storage.models import File, FileChunk
|
||||
from storage.serializers import FileChunkSerializer, FileSerializer
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from user.models import LockboxUser
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
class TestUser:
|
||||
|
|
@ -7,4 +9,6 @@ class TestUser:
|
|||
Test user related functions are working correctly.
|
||||
"""
|
||||
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*",
|
||||
".git",
|
||||
".venv",
|
||||
"manage.py",
|
||||
]
|
||||
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