Skip to content

Commit

Permalink
chore(deps): update dependencies to latest version
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This commit updates django to version 3.2 which is a
new major version. If this package is consumed as django app, the host
app needs to update django as well:

- https://docs.djangoproject.com/en/dev/releases/3.0/
- https://docs.djangoproject.com/en/dev/releases/3.1/
- https://docs.djangoproject.com/en/dev/releases/3.2/

In addition to this, we added support for python up to version 3.10 and
dropped support for version 3.6 and 3.7.
  • Loading branch information
anehx committed Mar 1, 2022
1 parent 78b8269 commit 4adaec2
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 113 deletions.
26 changes: 0 additions & 26 deletions .dependabot/config.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
day: friday
time: "12:00"
timezone: "Europe/Zurich"
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/"
schedule:
interval: weekly
day: friday
time: "12:00"
timezone: "Europe/Zurich"
open-pull-requests-limit: 10
5 changes: 2 additions & 3 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ on:

jobs:
publish:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade build twine
Expand Down
103 changes: 92 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,58 @@ name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 0 * * 0'
- cron: "0 0 * * 0"

jobs:
tests:
gitlint:
name: "Gitlint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install gitlint
run: pip install gitlint
- name: Run gitlint
run: gitlint --contrib contrib-title-conventional-commits

lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: "3.10"
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Install dependencies
run: pip install --upgrade --no-cache-dir --requirement requirements-dev.txt --disable-pip-version-check
- name: Run black
run: black --check .
- name: Run flake8
run: flake8

docker-tests:
name: "Docker tests"
runs-on: ubuntu-latest
needs: [gitlint, lint]

steps:
- uses: actions/checkout@v2
- name: Set UID
Expand All @@ -19,17 +64,53 @@ jobs:
run: make lint
- name: Run test suite
run: make test
commit-lint:

compatibility-tests:
name: "Compatibility tests"
runs-on: ubuntu-latest
needs: [gitlint, lint]

env:
ENV: dev

strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"

services:
postgres:
image: postgres
env:
POSTGRES_USER: ebau-gwr
POSTGRES_PASSWORD: ebau-gwr
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Install gitlint
run: pip install gitlint
- name: Run gitlint
run: gitlint --contrib contrib-title-conventional-commits --ignore B1,B5,B6
python-version: ${{ matrix.python_version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Set UID
run: echo "UID=$(id --user)" > .env
- name: Install dependencies
run: pip install --upgrade --no-cache-dir --requirement requirements-dev.txt --disable-pip-version-check
- name: Run migrations
run: ./manage.py migrate
- name: Run test suite
run: pytest --no-cov-on-fail --cov --create-db -vv
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6.12-slim-buster@sha256:09bb81730d8d3f1b208d9c5ba4be66747ef29323597bedab6404b884a016685d
FROM python:3.10.2-slim@sha256:935bff4b6c3acbe4e52b8be48c0e9961ce90355936656e6caed0179984f37acc

WORKDIR /app

Expand All @@ -24,8 +24,8 @@ ENV DJANGO_SETTINGS_MODULE ebau_gwr.settings
ENV APP_HOME=/app
ENV UWSGI_INI /app/uwsgi.ini

ARG REQUIREMENTS=requirements-prod.txt
COPY requirements-base.txt requirements-prod.txt requirements-dev.txt $APP_HOME/
ARG REQUIREMENTS=requirements.txt
COPY requirements.txt requirements-dev.txt $APP_HOME/
RUN pip install --upgrade --no-cache-dir --requirement $REQUIREMENTS --disable-pip-version-check

USER ebau-gwr
Expand Down
8 changes: 6 additions & 2 deletions ebau_gwr/linker/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json

from django.contrib.postgres.fields.jsonb import KeyTextTransform
from django.db.models import CharField
from django.db.models.fields.json import KeyTextTransform
from django.db.models.functions import Cast
from django_filters import Filter, FilterSet
from django_filters.constants import EMPTY_VALUES
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -42,7 +44,9 @@ def filter(self, qs, value):
# https://code.djangoproject.com/ticket/26511
if isinstance(expr["value"], str):
qs = qs.annotate(
field_val=KeyTextTransform(expr["key"], self.field_name)
field_val=Cast(
KeyTextTransform(expr["key"], self.field_name), CharField()
)
)
lookup = {f"field_val__{lookup_expr}": expr["value"]}
else:
Expand Down
2 changes: 1 addition & 1 deletion ebau_gwr/linker/migrations/0002_set_default_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterModelOptions(name="gwrlink", options={"ordering": ["-id"]},),
migrations.AlterModelOptions(name="gwrlink", options={"ordering": ["-id"]}),
]
16 changes: 16 additions & 0 deletions ebau_gwr/linker/migrations/0003_deprecated_json_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.12 on 2022-02-28 14:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("linker", "0002_set_default_ordering"),
]

operations = [
migrations.AlterField(
model_name="gwrlink", name="context", field=models.JSONField(default=dict)
)
]
6 changes: 2 additions & 4 deletions ebau_gwr/linker/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import uuid

from django.contrib.postgres.fields import JSONField
from django.db import models
from generic_permissions.models import PermissionModelMixin, VisibilityModelMixin


def make_uuid():
Expand All @@ -17,11 +15,11 @@ def make_uuid():
return uuid.uuid4()


class GWRLink(PermissionModelMixin, VisibilityModelMixin, models.Model):
class GWRLink(models.Model):
id = models.UUIDField(primary_key=True, default=make_uuid, editable=False)
eproid = models.CharField(max_length=255)
local_id = models.CharField(max_length=255)
context = JSONField(default=dict)
context = models.JSONField(default=dict)

class Meta:
unique_together = (("eproid", "local_id"),)
Expand Down
3 changes: 1 addition & 2 deletions ebau_gwr/linker/serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from generic_permissions.serializers import PermissionSerializerMixin
from rest_framework_json_api import serializers

from . import models


class GWRLinkSerializer(PermissionSerializerMixin, serializers.ModelSerializer):
class GWRLinkSerializer(serializers.ModelSerializer):
class Meta:
model = models.GWRLink
fields = (
Expand Down
3 changes: 2 additions & 1 deletion ebau_gwr/linker/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from generic_permissions.views import PermissionViewMixin, VisibilityViewMixin
from generic_permissions.permissions import PermissionViewMixin
from generic_permissions.visibilities import VisibilityViewMixin
from rest_framework_json_api import pagination, parsers, renderers, views

from . import models, serializers
Expand Down
12 changes: 3 additions & 9 deletions ebau_gwr/oidc_auth/tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def test_authentication(
)


def test_authentication_idp_502(
db, rf, requests_mock, settings,
):
def test_authentication_idp_502(db, rf, requests_mock, settings):
requests_mock.get(
settings.OIDC_OP_USER_ENDPOINT, status_code=status.HTTP_502_BAD_GATEWAY
)
Expand All @@ -70,9 +68,7 @@ def test_authentication_idp_502(
OIDCAuthentication().authenticate(request)


def test_authentication_idp_missing_claim(
db, rf, requests_mock, settings,
):
def test_authentication_idp_missing_claim(db, rf, requests_mock, settings):
settings.OIDC_USERNAME_CLAIM = "missing"
userinfo = {"sub": "1"}
requests_mock.get(settings.OIDC_OP_USER_ENDPOINT, text=json.dumps(userinfo))
Expand All @@ -82,9 +78,7 @@ def test_authentication_idp_missing_claim(
OIDCAuthentication().authenticate(request)


def test_authentication_no_client(
db, rf, requests_mock, settings,
):
def test_authentication_no_client(db, rf, requests_mock, settings):
requests_mock.get(
settings.OIDC_OP_USER_ENDPOINT, status_code=status.HTTP_401_UNAUTHORIZED
)
Expand Down
3 changes: 2 additions & 1 deletion ebau_gwr/token_proxy/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ class TokenProxyConfig(AppConfig):

def ready(self):
from django.conf import settings

from .app_settings import DEFAULTS, REQUIRED_SETTINGS

for setting_key, setting_value in DEFAULTS.items():
setattr(
settings, setting_key, getattr(settings, setting_key, setting_value),
settings, setting_key, getattr(settings, setting_key, setting_value)
)

missing_settings = ", ".join(
Expand Down
4 changes: 2 additions & 2 deletions ebau_gwr/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
from django.urls import path

urlpatterns = [
path("api/v1/linker/", include("ebau_gwr.linker.urls"),),
path("api/v1/", include("ebau_gwr.token_proxy.urls"),),
path("api/v1/linker/", include("ebau_gwr.linker.urls")),
path("api/v1/", include("ebau_gwr.token_proxy.urls")),
]
11 changes: 0 additions & 11 deletions requirements-base.txt

This file was deleted.

Loading

0 comments on commit 4adaec2

Please sign in to comment.