Use poetry for dependency management
This commit is contained in:
parent
cda2654573
commit
e495d7c188
21 changed files with 1252 additions and 75 deletions
|
|
@ -34,13 +34,13 @@ python tests:
|
||||||
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||||
paths:
|
paths:
|
||||||
- .cache/pip
|
- .cache/pip
|
||||||
- env/
|
- .venv/
|
||||||
before_script:
|
before_script:
|
||||||
- python3 -m venv env
|
- pip install poetry
|
||||||
- source env/bin/activate
|
- poetry config virtualenvs.in-project true
|
||||||
- pip install -r requirements/gitlab.txt
|
- poetry install --no-interaction
|
||||||
script:
|
script:
|
||||||
- python src/manage.py test newsreader
|
- poetry run src/manage.py test newsreader
|
||||||
|
|
||||||
javascript tests:
|
javascript tests:
|
||||||
image: node:12
|
image: node:12
|
||||||
|
|
@ -76,15 +76,15 @@ python linting:
|
||||||
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||||
paths:
|
paths:
|
||||||
- .cache/pip
|
- .cache/pip
|
||||||
- env/
|
- .venv/
|
||||||
before_script:
|
before_script:
|
||||||
- python3 -m venv env
|
- pip install poetry
|
||||||
- source env/bin/activate
|
- poetry config virtualenvs.in-project true
|
||||||
- pip install -r requirements/gitlab.txt
|
- poetry install --no-interaction
|
||||||
script:
|
script:
|
||||||
- isort src/ --check-only --recursive
|
- poetry run isort src/ --check-only --recursive
|
||||||
- black src/ --line-length 88 --check
|
- poetry run black src/ --line-length 88 --check
|
||||||
- autoflake src/ --check --recursive --remove-all-unused-imports --ignore-init-module-imports
|
- poetry run autoflake src/ --check --recursive --remove-all-unused-imports --ignore-init-module-imports
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
|
|
||||||
15
Dockerfile
15
Dockerfile
|
|
@ -1,18 +1,11 @@
|
||||||
FROM python:3.7-buster
|
FROM python:3.7-buster
|
||||||
|
|
||||||
# Run project binaries from the user's local bin folder
|
RUN pip install poetry
|
||||||
ENV PATH=/home/newsreader/.local/bin:$PATH
|
|
||||||
|
|
||||||
# Set the default shell
|
|
||||||
RUN useradd -ms /bin/bash newsreader
|
|
||||||
|
|
||||||
RUN mkdir /app
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN chown newsreader:newsreader /app
|
COPY poetry.lock pyproject.toml /app/
|
||||||
USER newsreader
|
|
||||||
|
|
||||||
# Use a seperate layer for the project requirements
|
RUN poetry config virtualenvs.create false
|
||||||
COPY requirements /app/requirements
|
RUN poetry install --no-interaction
|
||||||
RUN pip install --user -r requirements/dev.txt
|
|
||||||
|
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ services:
|
||||||
celery:
|
celery:
|
||||||
build: .
|
build: .
|
||||||
container_name: celery
|
container_name: celery
|
||||||
command: celery -A newsreader worker -l INFO --beat --scheduler django --workdir=/app/src/
|
command: poetry run celery -A newsreader worker -l INFO --beat --scheduler django --workdir=/app/src/
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_HOST=$POSTGRES_HOST
|
- POSTGRES_HOST=$POSTGRES_HOST
|
||||||
- POSTGRES_NAME=$POSTGRES_NAME
|
- POSTGRES_NAME=$POSTGRES_NAME
|
||||||
|
|
|
||||||
1115
poetry.lock
generated
Normal file
1115
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
39
pyproject.toml
Normal file
39
pyproject.toml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
[tool.poetry]
|
||||||
|
name = "newsreader"
|
||||||
|
version = "0.2"
|
||||||
|
description = "Webapplication for reading RSS feeds"
|
||||||
|
authors = ["Sonny <sonnyba871@gmail.com>"]
|
||||||
|
license = "GPL-3.0"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.7"
|
||||||
|
bleach = "^3.1.4"
|
||||||
|
Django = "^3.0.5"
|
||||||
|
celery = "^4.4.2"
|
||||||
|
beautifulsoup4 = "^4.9.0"
|
||||||
|
django-axes = "^5.3.1"
|
||||||
|
django-celery-beat = "^2.0.0"
|
||||||
|
djangorestframework = "^3.11.0"
|
||||||
|
drf-yasg = "^1.17.1"
|
||||||
|
django-registration-redux = "^2.7"
|
||||||
|
lxml = "^4.5.0"
|
||||||
|
feedparser = "^5.2.1"
|
||||||
|
python-memcached = "^1.59"
|
||||||
|
requests = "^2.23.0"
|
||||||
|
psycopg2-binary = "^2.8.5"
|
||||||
|
gunicorn = "^20.0.4"
|
||||||
|
python-dotenv = "^0.12.0"
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
factory-boy = "^2.12.0"
|
||||||
|
freezegun = "^0.3.15"
|
||||||
|
django-debug-toolbar = "^2.2"
|
||||||
|
django-extensions = "^2.2.9"
|
||||||
|
black = "19.3b0"
|
||||||
|
isort = "4.3.21"
|
||||||
|
autoflake = "1.3.1"
|
||||||
|
tblib = "1.6.0"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry>=0.12"]
|
||||||
|
build-backend = "poetry.masonry.api"
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
bleach==3.1.0
|
|
||||||
beautifulsoup4==4.7.1
|
|
||||||
celery==4.3.0
|
|
||||||
certifi==2019.3.9
|
|
||||||
chardet==3.0.4
|
|
||||||
django-axes==5.2.2
|
|
||||||
Django==2.2
|
|
||||||
django-celery-beat==1.5.0
|
|
||||||
djangorestframework==3.9.4
|
|
||||||
drf-yasg==1.17.1
|
|
||||||
django-registration-redux==2.6
|
|
||||||
lxml==4.4.2
|
|
||||||
feedparser==5.2.1
|
|
||||||
idna==2.8
|
|
||||||
python-memcached==1.59
|
|
||||||
pytz==2018.9
|
|
||||||
requests==2.21.0
|
|
||||||
sqlparse==0.3.0
|
|
||||||
urllib3==1.24.1
|
|
||||||
psycopg2-binary==2.8.1
|
|
||||||
Pillow==6.0.0
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
-r base.txt
|
|
||||||
|
|
||||||
factory-boy==2.12.0
|
|
||||||
freezegun==0.3.12
|
|
||||||
django-debug-toolbar==2.0
|
|
||||||
django-extensions==2.1.9
|
|
||||||
|
|
||||||
black==19.3b0
|
|
||||||
isort==4.3.21
|
|
||||||
autoflake==1.3.1
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
-r dev.txt
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
-r base.txt
|
|
||||||
|
|
||||||
python-dotenv==0.12.0
|
|
||||||
gunicorn==20.0.4
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
-r base.txt
|
|
||||||
|
|
||||||
factory-boy==2.12.0
|
|
||||||
freezegun==0.3.12
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This file should only be used in conjuction with docker-compose
|
# This file should only be used in conjuction with docker-compose
|
||||||
|
|
||||||
python /app/src/manage.py migrate
|
poetry run /app/src/manage.py migrate
|
||||||
python /app/src/manage.py runserver 0.0.0.0:8000
|
poetry run /app/src/manage.py runserver 0.0.0.0:8000
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class Migration(migrations.Migration):
|
||||||
blank=True,
|
blank=True,
|
||||||
editable=False,
|
editable=False,
|
||||||
null=True,
|
null=True,
|
||||||
on_delete="collection task",
|
on_delete=models.SET_NULL,
|
||||||
to="django_celery_beat.PeriodicTask",
|
to="django_celery_beat.PeriodicTask",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -125,7 +125,7 @@ class Migration(migrations.Migration):
|
||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
on_delete="collection schedule",
|
on_delete=models.SET_NULL,
|
||||||
to="django_celery_beat.IntervalSchedule",
|
to="django_celery_beat.IntervalSchedule",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
||||||
blank=True,
|
blank=True,
|
||||||
editable=False,
|
editable=False,
|
||||||
null=True,
|
null=True,
|
||||||
on_delete="collection task",
|
on_delete=models.SET_NULL,
|
||||||
to="django_celery_beat.PeriodicTask",
|
to="django_celery_beat.PeriodicTask",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name="collectionrule",
|
model_name="collectionrule",
|
||||||
name="user",
|
name="user",
|
||||||
field=models.ForeignKey(on_delete="Owner", to=settings.AUTH_USER_MODEL),
|
field=models.ForeignKey(
|
||||||
|
on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ class Migration(migrations.Migration):
|
||||||
model_name="collectionrule",
|
model_name="collectionrule",
|
||||||
name="user",
|
name="user",
|
||||||
field=models.ForeignKey(
|
field=models.ForeignKey(
|
||||||
on_delete="Owner", related_name="rules", to=settings.AUTH_USER_MODEL
|
on_delete=models.CASCADE,
|
||||||
|
related_name="rules",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Generated by Django 3.0.5 on 2020-04-12 19:55
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
("collection", "0005_auto_20200303_1932"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="collectionrule",
|
||||||
|
name="user",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="rules",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="Owner",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
@ -35,7 +35,12 @@ class CollectionRule(TimeStampedModel):
|
||||||
succeeded = models.BooleanField(default=False)
|
succeeded = models.BooleanField(default=False)
|
||||||
error = models.CharField(max_length=1024, blank=True, null=True)
|
error = models.CharField(max_length=1024, blank=True, null=True)
|
||||||
|
|
||||||
user = models.ForeignKey("accounts.User", _("Owner"), related_name="rules")
|
user = models.ForeignKey(
|
||||||
|
"accounts.User",
|
||||||
|
verbose_name=_("Owner"),
|
||||||
|
related_name="rules",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ class Migration(migrations.Migration):
|
||||||
("name", models.CharField(max_length=50, unique=True)),
|
("name", models.CharField(max_length=50, unique=True)),
|
||||||
(
|
(
|
||||||
"user",
|
"user",
|
||||||
models.ForeignKey(on_delete="Owner", to=settings.AUTH_USER_MODEL),
|
models.ForeignKey(
|
||||||
|
on_delete=models.CASCADE, to=settings.AUTH_USER_MODEL
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
options={"verbose_name": "Category", "verbose_name_plural": "Categories"},
|
options={"verbose_name": "Category", "verbose_name_plural": "Categories"},
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Migration(migrations.Migration):
|
||||||
model_name="category",
|
model_name="category",
|
||||||
name="user",
|
name="user",
|
||||||
field=models.ForeignKey(
|
field=models.ForeignKey(
|
||||||
on_delete="Owner",
|
on_delete=models.CASCADE,
|
||||||
related_name="categories",
|
related_name="categories",
|
||||||
to=settings.AUTH_USER_MODEL,
|
to=settings.AUTH_USER_MODEL,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Generated by Django 3.0.5 on 2020-04-12 19:55
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
("core", "0004_auto_20191116_1315"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="category",
|
||||||
|
name="user",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="categories",
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="Owner",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
@ -27,7 +27,12 @@ class Post(TimeStampedModel):
|
||||||
|
|
||||||
class Category(TimeStampedModel):
|
class Category(TimeStampedModel):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
user = models.ForeignKey("accounts.User", _("Owner"), related_name="categories")
|
user = models.ForeignKey(
|
||||||
|
"accounts.User",
|
||||||
|
verbose_name=_("Owner"),
|
||||||
|
related_name="categories",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rule_ids(self):
|
def rule_ids(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue