Skip to content

Commit

Permalink
ZDL-122: Convert requirements to poetry pyproject toml
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanAquino committed Aug 1, 2023
1 parent 24529df commit 251fee1
Show file tree
Hide file tree
Showing 15 changed files with 1,915 additions and 153 deletions.
12 changes: 0 additions & 12 deletions .coveragerc

This file was deleted.

25 changes: 12 additions & 13 deletions .github/workflows/django-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8 pytest mypy isort
pip install poetry==1.5.1 && poetry install --only dev
- name: Lint with flake8
run: |
flake8 . --statistics
poetry run flake8 . --statistics
- name: Typehint with mypy
run: |
mypy .
poetry run mypy .
- name: Check formatting
run: black . --exclude=venv --check
run: poetry run black . --exclude=venv --check
- name: Check isort imports
run: |
isort . --check-only
poetry run isort . --check-only
unit-test:
runs-on: ubuntu-latest
services:
Expand All @@ -43,16 +43,15 @@ jobs:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install poetry==1.5.1 && poetry install
- name: Run migrations
run: python manage.py migrate
run: poetry run python manage.py migrate
- name: Test with pytest with coverage
run: |
pytest . --cov
run: poetry run pytest . --cov
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@ dmypy.json
.pytype/

# End of https://www.toptal.com/developers/gitignore/api/django
staticfiles/
staticfiles/

.DS_Store
2 changes: 0 additions & 2 deletions .isort.cfg

This file was deleted.

8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# https://github.com/pre-commit/pre-commit-hooks
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.7.0
hooks:
- id: black
args: [--exclude=venv, --check]

- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
rev: 6.1.0
hooks:
- id: flake8
args: [--statistics]

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: [--check-only]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-added-large-files
Expand Down
4 changes: 3 additions & 1 deletion deployments/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ WORKDIR /zadala

COPY ../ .

RUN pip install -r requirements.txt
RUN pip install poetry==1.5.1

RUN poetry install

CMD ["python", "manage.py", "runserver"]
4 changes: 3 additions & 1 deletion deployments/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ WORKDIR /zadala

COPY ../ .

RUN pip install -r requirements.txt
RUN pip install poetry==1.5.1

RUN poetry install --without dev

ENTRYPOINT ["sh", "/zadala/deployments/entrypoint.sh"]
7 changes: 5 additions & 2 deletions deployments/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ x-common-variables: &common-variables
SECRET_KEY: my-secret
GOOGLE_CLIENT_ID:
GOOGLE_CLIENT_SECRET:
AWS_SECRET_KEY_ID:
AWS_SECRET_ACCESS_KEY:
AWS_SNS_ARN:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_DB: 0
Expand Down Expand Up @@ -59,9 +62,9 @@ services:
restart: always
build:
context: ../
dockerfile: deployments/Dockerfile.prod
dockerfile: deployments/Dockerfile
environment: *common-variables
command: sh -c "python manage.py rqworker high default low"
command: sh -c "poetry run python manage.py rqworker high default low"
depends_on:
- redis

Expand Down
7 changes: 5 additions & 2 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ x-common-variables: &common-variables
SECRET_KEY: my-secret
GOOGLE_CLIENT_ID:
GOOGLE_CLIENT_SECRET:
AWS_SECRET_KEY_ID:
AWS_SECRET_ACCESS_KEY:
AWS_SNS_ARN:
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_DB: 0
Expand Down Expand Up @@ -67,7 +70,7 @@ services:
expose:
- 8000
environment: *common-variables
command: sh -c "python manage.py migrate && python manage.py collectstatic --noinput && python manage.py runserver 0.0.0.0:8000"
command: sh -c "poetry run python manage.py migrate && poetry run python manage.py collectstatic --noinput && poetry run python manage.py runserver 0.0.0.0:8000"
depends_on:
db:
condition: service_healthy
Expand All @@ -78,6 +81,6 @@ services:
context: ../
dockerfile: deployments/Dockerfile
environment: *common-variables
command: sh -c "python manage.py rqworker high default low"
command: sh -c "poetry run python manage.py rqworker high default low"
depends_on:
- redis
8 changes: 4 additions & 4 deletions deployments/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

python manage.py migrate --no-input
python manage.py collectstatic --no-input
poetry run python manage.py migrate --no-input
poetry run python manage.py collectstatic --no-input

DJANGO_SUPERUSER_PASSWORD=$SUPER_USER_PASSWORD python manage.py createsuperuser --first_name $SUPER_FIRST_NAME --last_name $SUPER_LAST_NAME --email $SUPER_USER_EMAIL --noinput
DJANGO_SUPERUSER_PASSWORD=$SUPER_USER_PASSWORD poetry run python manage.py createsuperuser --first_name $SUPER_FIRST_NAME --last_name $SUPER_LAST_NAME --email $SUPER_USER_EMAIL --noinput

gunicorn zadalaAPI.wsgi --bind 0.0.0.0:8000 --workers=$GUNICORN_WORKERS
poetry run gunicorn zadalaAPI.wsgi --bind 0.0.0.0:8000 --workers=$GUNICORN_WORKERS
5 changes: 0 additions & 5 deletions mypy.ini

This file was deleted.

Loading

0 comments on commit 251fee1

Please sign in to comment.