From 5b68a9ea54a2d2137ce13959ca4ce51986cec5b3 Mon Sep 17 00:00:00 2001 From: Jan Gerber <j@open-video.com> Date: Mon, 25 Sep 2023 11:34:12 +0200 Subject: [PATCH 01/22] fix shapefile upload, depends on django_filters, closes CAC_SERVICE-216 --- wk_app/settings/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wk_app/settings/common.py b/wk_app/settings/common.py index 77d5b52c..b163b2e0 100644 --- a/wk_app/settings/common.py +++ b/wk_app/settings/common.py @@ -56,6 +56,7 @@ INSTALLED_APPS = [ 'django_extensions', 'ordered_model', 'django_user_agents', + 'django_filters', ] MIDDLEWARE = [ -- GitLab From da3fa0a005d3699e7b471c3fba386930aba602f0 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:26:05 +0100 Subject: [PATCH 02/22] Chane order of headings User should directly see in order what is required to setup project. --- README.md | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 166673c5..87e214fd 100644 --- a/README.md +++ b/README.md @@ -87,26 +87,6 @@ enter the virtualenv with `poetry shell`. Note: You might get errors if you are missing the [system dependencies](#system-dependencies) -### Lint - -This project uses `flake8` which is configured in `.flake8` and invoked like this. - -``` -$ flake8 -``` - -### Pre-commit checks - -To avoid checking in unlinted or untested code there is a `.pre-commit-config.yaml` for convenience. You might install it with `pre-commit`: - -``` -$ pre-commit install # install the hook -``` - -#### Remark - -Be aware this also executes tests on committing, which requires the postgres server to run. See [Database](#Database) - ### Database To develop or execute tests (which is highly recommended) you need a running postgres database. If you stick with the default settings you can easily create a local postgres (with postgis enabled!) instance with docker: @@ -181,6 +161,25 @@ $ celery -A wk_app.celery worker --loglevel=INFO -B For development disregarding the asynchronous quirks, it might also be feasible to just set `CELERY_TASK_ALWAYS_EAGER` to `True` in your local settings. This will lead to all normally dispatched tasks to be executed synchronously. +### Lint + +This project uses `flake8` which is configured in `.flake8` and invoked like this. + +``` +$ flake8 +``` + +### Pre-commit checks + +To avoid checking in unlinted or untested code there is a `.pre-commit-config.yaml` for convenience. You might install it with `pre-commit`: + +``` +$ pre-commit install # install the hook +``` + +#### Remark + +Be aware this also executes tests on committing, which requires the postgres server to run. See [Database](#Database) ### (Optional) Create Admin user -- GitLab From cd1647b084c5f16b6446a25b48c975a0332c9f4a Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:27:57 +0100 Subject: [PATCH 03/22] Add console EmailBackend for developmen Due to this E-Mails will be logged to comandline and developer doesn't need to configure E-Mail serivce. --- wk_app/settings/local.py.dist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wk_app/settings/local.py.dist b/wk_app/settings/local.py.dist index c66f3aaa..bf90ec9b 100644 --- a/wk_app/settings/local.py.dist +++ b/wk_app/settings/local.py.dist @@ -10,4 +10,6 @@ DATABASES['osm'] = { # noqa: F405 } DATABASE_ROUTERS = ('wk_app.settings.db_router.OSMDatabaseRouter',) -CSRF_TRUSTED_ORIGINS = ['http://localhost:8080'] \ No newline at end of file +CSRF_TRUSTED_ORIGINS = ['http://localhost:8080'] +CELERY_TASK_ALWAYS_EAGER = True +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' \ No newline at end of file -- GitLab From 43afc61563b5f5bd2fad5005647bf4c0ef1c21b8 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:31:21 +0100 Subject: [PATCH 04/22] Fix a too early start of api service The api service sometime was starting before postgres service was ready. --- docker-compose.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index b92d0779..f5c69883 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,9 @@ services: build: context: . dockerfile: ./Dockerfile + depends_on: + postgres: + condition: service_healthy environment: - DB_HOST=postgres - CELERY_BROKER_URL=redis://redis:6379 @@ -30,6 +33,11 @@ services: - POSTGRES_USER=wkservice - POSTGRES_HOST_AUTH_METHOD=trust container_name: wk-psql-database + healthcheck: + test: pg_isready -U $$POSTGRES_USER + interval: 5s + timeout: 5s + retries: 10 volumes: - ./.psql-data:/var/lib/postgresql/data networks: -- GitLab From ba5c6b566d9a23f4fc90e72d7ca7d698d763cebf Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:32:46 +0100 Subject: [PATCH 05/22] Use same path in docker-compose as in README.md Inside of the readme the path to store postgres files was another as in the docker-compose file. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f5c69883..3481501d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,7 +39,7 @@ services: timeout: 5s retries: 10 volumes: - - ./.psql-data:/var/lib/postgresql/data + - ./.psql_data:/var/lib/postgresql/data networks: - wk-backend -- GitLab From d5aed1ddf2fc315cdc9fd9cd1f7878955c42cd76 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:33:34 +0100 Subject: [PATCH 06/22] Correct formating of docker-compose file --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3481501d..0ea83f16 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +version: "3.8" services: api: @@ -27,7 +27,7 @@ services: - wk-backend command: python manage.py runserver 0.0.0.0:8000 - postgres: + postgres: image: postgis/postgis environment: - POSTGRES_USER=wkservice @@ -42,7 +42,7 @@ services: - ./.psql_data:/var/lib/postgresql/data networks: - wk-backend - + redis: image: redis container_name: wk-redis -- GitLab From 98484b23114f56a589b4d8c55e477812c9f4316a Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 29 Nov 2023 17:48:02 +0100 Subject: [PATCH 07/22] Add setup/update script for docker-compose --- .gitignore | 6 ++++++ README.md | 27 +++++++++++++++++++++------ setup_dev_environment.sh | 11 +++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100755 setup_dev_environment.sh diff --git a/.gitignore b/.gitignore index f143cc92..a0b995a0 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,9 @@ tmuxp.yml # Push notifications service-account-file.json apns.p8 + +# python +requirements.txt + +# Ignore lock file for update_dev_environment +.initial_setup.lock \ No newline at end of file diff --git a/README.md b/README.md index 87e214fd..c18831c0 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,22 @@ enter the virtualenv with `poetry shell`. Note: You might get errors if you are missing the [system dependencies](#system-dependencies) -### Database +### Docker-Compose (short) Setup + +If you installed [system dependencies](#system-dependencies) and docker-compose. You can run the following command to setup and update dependencies: + +```shell +$ sudo ./setup_dev_environment.sh +``` + +And to start the service you can run: +```shell +$ sudo docker-compose up +``` + +### Manual (long) Setup + +#### Database To develop or execute tests (which is highly recommended) you need a running postgres database. If you stick with the default settings you can easily create a local postgres (with postgis enabled!) instance with docker: @@ -103,7 +118,7 @@ docker run -p 5432:5432 -e POSTGRES_USER=wkservice -v `pwd`/.psql_data:/var/lib/ Variables might need adjustment if you altered the database settings. -#### DB for OSM related queries +##### DB for OSM related queries You can create your own db filled with OSM data, see [Nominatim](https://nominatim.org/release-docs/3.6.0/develop/Import/#database-layout). @@ -115,7 +130,7 @@ $ cp -n wk_app/settings/local.py.dist wk_app/settings/local.py and fill in the `PASSWORD` from shared PW store in the created `local.py`. -### Migrate schema +#### Migrate schema To update your development database to match current migration status run @@ -123,7 +138,7 @@ To update your development database to match current migration status run $ python manage.py migrate ``` -### Example Data +#### Example Data Conveniently this repository provides some example data jumpstart development and provide some basic data to get started. To use these example data fixtures use the following command: @@ -136,7 +151,7 @@ You will find some basic data filled for events, campaigns, oauth2 applications âš ï¸ Do not use this example data on production systems as it contains example secrets that are considered broken âš ï¸ -### Run service +#### Run service Run the service like any django project @@ -144,7 +159,7 @@ Run the service like any django project $ python manage.py runserver ``` -### Run celery +#### Run celery For asynchronous tasks this project uses [celery](https://docs.celeryproject.org/). If you work on asynchronous tasks it's advisable to actually run a celery runner. diff --git a/setup_dev_environment.sh b/setup_dev_environment.sh new file mode 100755 index 00000000..6a5bf4f5 --- /dev/null +++ b/setup_dev_environment.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +poetry export -f requirements.txt > requirements.txt +docker-compose build +docker-compose run --rm api python manage.py migrate +if [ ! -f .initial_setup.lock ]; +then + docker-compose run --rm api python manage.py loaddata core/fixtures/associations.json + docker-compose run --rm api python manage.py loaddata core/fixtures/example_data.json + touch .initial_setup.lock +fi -- GitLab From 7913e9a98267cd8e9a54185e3ab08d41fe4e2590 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Thu, 30 Nov 2023 14:21:33 +0100 Subject: [PATCH 08/22] Move setup of osm db up --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c18831c0..1fa2babc 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,18 @@ enter the virtualenv with `poetry shell`. Note: You might get errors if you are missing the [system dependencies](#system-dependencies) +#### DB for OSM related queries + +You can create your own db filled with OSM data, see [Nominatim](https://nominatim.org/release-docs/3.6.0/develop/Import/#database-layout). + +Or you could use our shared one. To do so: + +```bash +$ cp -n wk_app/settings/local.py.dist wk_app/settings/local.py +``` + +and fill in the `PASSWORD` from shared PW store in the created `local.py`. + ### Docker-Compose (short) Setup If you installed [system dependencies](#system-dependencies) and docker-compose. You can run the following command to setup and update dependencies: @@ -118,18 +130,6 @@ docker run -p 5432:5432 -e POSTGRES_USER=wkservice -v `pwd`/.psql_data:/var/lib/ Variables might need adjustment if you altered the database settings. -##### DB for OSM related queries - -You can create your own db filled with OSM data, see [Nominatim](https://nominatim.org/release-docs/3.6.0/develop/Import/#database-layout). - -Or you could use our shared one. To do so: - -```bash -$ cp -n wk_app/settings/local.py.dist wk_app/settings/local.py -``` - -and fill in the `PASSWORD` from shared PW store in the created `local.py`. - #### Migrate schema To update your development database to match current migration status run -- GitLab From e54137abfb654330cc31f988e59ab7f9610fb1a4 Mon Sep 17 00:00:00 2001 From: Jan Gerber <j@open-video.com> Date: Wed, 20 Sep 2023 18:47:32 +0200 Subject: [PATCH 09/22] use und-x-icu collation in user admin, fixes CAC_SERVICE-215 --- core/admin/model_admins.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/admin/model_admins.py b/core/admin/model_admins.py index f07e7ec9..aa20f46a 100644 --- a/core/admin/model_admins.py +++ b/core/admin/model_admins.py @@ -7,6 +7,7 @@ from django.contrib.auth.models import Permission from django.contrib.gis.admin import OSMGeoAdmin from django.contrib.gis.db import models from django.contrib.postgres.fields import ArrayField +from django.db.models.functions import Collate from django.http import HttpResponse from django.template.response import TemplateResponse from django.urls import reverse, path @@ -127,7 +128,7 @@ class UserAdmin(BaseUserAdmin): """ change_list_template = 'admin/user_change_list.html' readonly_fields = ('sub_association', 'archived_email') - search_fields = ('first_name', 'last_name', 'archived_email', 'email', 'username') + search_fields = ('first_name', 'last_name', 'archived_email', 'email_deterministic', 'username_deterministic') list_display = ( 'username', 'email', 'first_name', 'last_name', 'is_staff', 'is_pending_invitation', @@ -163,7 +164,10 @@ class UserAdmin(BaseUserAdmin): ) def get_queryset(self, request): - return self.model.objects_with_deleted.all() + return self.model.objects_with_deleted.all().annotate( + email_deterministic=Collate('email', 'und-x-icu'), + username_deterministic=Collate('username', 'und-x-icu'), + ) def bulk_invite(self, request, **kwargs): return TemplateResponse( -- GitLab From 9783f191b995ac109568b7515b558fbe3f7ffdbe Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Thu, 30 Nov 2023 17:44:25 +0100 Subject: [PATCH 10/22] CAC_FRONTEND-416 Omit registration with uri in first/last name --- api/locale/de/LC_MESSAGES/django.po | 12 ++++++-- api/serializer/user.py | 30 +++++++++++++++++++ api/tests/test_user_registration.py | 45 ++++++++++++++++++++++++++++ core/locale/de/LC_MESSAGES/django.po | 16 +++++----- locale/de/LC_MESSAGES/django.po | 6 ++-- 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/api/locale/de/LC_MESSAGES/django.po b/api/locale/de/LC_MESSAGES/django.po index f48eb303..eea328cf 100644 --- a/api/locale/de/LC_MESSAGES/django.po +++ b/api/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-13 14:39+0200\n" +"POT-Creation-Date: 2023-11-30 18:06+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -108,7 +108,15 @@ msgstr "Es muss ein Passwort angegeben werden" msgid "The supplied password is incorrect" msgstr "Das angegebene Passwort ist falsch" -#: api/serializer/user.py:125 +#: api/serializer/user.py:36 +msgid "The supplied first name should not contain an uri" +msgstr "Der Vorname darf keine URI enthalten." + +#: api/serializer/user.py:48 +msgid "The supplied last name should not contain an uri" +msgstr "Der Nachname darf keine URI enthalten." + +#: api/serializer/user.py:155 msgid "The username is already taken." msgstr "Der Benutzer*innenname ist bereits vergeben." diff --git a/api/serializer/user.py b/api/serializer/user.py index 65cab675..451c30db 100644 --- a/api/serializer/user.py +++ b/api/serializer/user.py @@ -27,6 +27,30 @@ def _validate_password(instance, password): return password +def _validate_first_name(instance, name): + request = instance.context.get('request') + if not request: + raise serializers.ValidationError('This serializer must be used in a request context') + # check if name contains uri + if name.find('://') != -1: + msg = _('The supplied first name should not contain an uri') + raise serializers.ValidationError(msg) + else: + return name + + +def _validate_last_name(instance, name): + request = instance.context.get('request') + if not request: + raise serializers.ValidationError('This serializer must be used in a request context') + # check if name contains uri + if name.find('://') != -1: + msg = _('The supplied last name should not contain an uri') + raise serializers.ValidationError(msg) + else: + return name + + class UserSerializer(serializers.ModelSerializer): email = serializers.EmailField(read_only=True) username = serializers.CharField(read_only=True) @@ -64,6 +88,12 @@ class UserRegistrationSerializer(serializers.ModelSerializer): password = serializers.CharField(required=True, allow_null=False, allow_blank=False, write_only=True) plz = serializers.CharField(max_length=5, min_length=5) + def validate_first_name(self, first_name): + return _validate_first_name(self, first_name) + + def validate_last_name(self, last_name): + return _validate_last_name(self, last_name) + class Meta: model = User fields = ('id', 'first_name', 'last_name', 'username', 'password', 'email', 'plz') diff --git a/api/tests/test_user_registration.py b/api/tests/test_user_registration.py index 3ac3afa2..28aaf6ca 100644 --- a/api/tests/test_user_registration.py +++ b/api/tests/test_user_registration.py @@ -38,6 +38,51 @@ class UserRegistrationTestCase(APITestCase): token_count = VerificationToken.objects.filter(user__id=created_user['id']).count() self.assertEqual(token_count, 1, msg='assert that one verification token has been created') + def test_user_registration_omit_malicious_first_name(self): + response = self.client.post(path='/api/v1/account/register/', + data={ + 'username': 'test_user', + 'email': 'admin@example.com', + 'password': 'test123', + 'first_name': 'https://ctrl.alt.coop', + 'last_name': 'last_name', + 'plz': '12345' + }) + + self.assertEqual(response.status_code, 400, msg='When user tries to register first_name with uri,' + 'then the registration should fail') + + def test_user_registration_omit_malicious_last_name(self): + response = self.client.post(path='/api/v1/account/register/', + data={ + 'username': 'test_user', + 'email': 'admin@example.com', + 'password': 'test123', + 'first_name': 'first_name', + 'last_name': 'https://control.alt.coop', + 'plz': '12345' + }) + + self.assertEqual(response.status_code, 400, msg='When user tries to register first_name with uri,' + 'then the registration should fail') + + def test_user_registration_with_valid_first_last_name(self): + user_data = { + 'username': 'test_user', + 'email': 'admin@example.com', + 'password': 'test123', + 'first_name': 'first_name', + 'plz': '12345' + } + response = self.client.post(path='/api/v1/account/register/', + data=user_data) + + self.assertEqual(response.status_code, 201, msg='When user provides valid first_name,' + 'then the registration should succeed') + + self.assertTrue(User.objects.filter(username=user_data['username']).exists(), + msg='When user provides valid first_name, then the user should be created') + def test_verification(self): user = User.objects.create( username='test_user', diff --git a/core/locale/de/LC_MESSAGES/django.po b/core/locale/de/LC_MESSAGES/django.po index 6f87e59a..c02f0f99 100644 --- a/core/locale/de/LC_MESSAGES/django.po +++ b/core/locale/de/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-13 14:39+0200\n" +"POT-Creation-Date: 2023-11-30 17:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -48,34 +48,34 @@ msgstr "Beendet" msgid "deleted" msgstr "Gelöscht" -#: core/admin/model_admins.py:148 +#: core/admin/model_admins.py:149 msgid "Personal info" msgstr "Persönliche Informationen" -#: core/admin/model_admins.py:150 +#: core/admin/model_admins.py:151 msgid "Permissions" msgstr "Berechtigungen" -#: core/admin/model_admins.py:162 +#: core/admin/model_admins.py:163 msgid "Important dates" msgstr "Wichtige Termine" -#: core/admin/model_admins.py:239 +#: core/admin/model_admins.py:243 msgid "Export Postleitzahl Areas" msgstr "Postleitzahlgebiete exportieren" -#: core/admin/model_admins.py:243 +#: core/admin/model_admins.py:247 #: core/management/commands/export_plz_areas.py:21 core/models.py:641 #: core/models.py:678 msgid "Sub association" msgstr "Kreis/Bezirksverband" -#: core/admin/model_admins.py:243 +#: core/admin/model_admins.py:247 #: core/management/commands/export_plz_areas.py:21 msgid "PLZ Areas" msgstr "Postleitzahlgebiete" -#: core/admin/model_admins.py:274 +#: core/admin/model_admins.py:278 msgid "Location (lat, lng)" msgstr "Ort (LAT, LON)" diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 679dfeef..fcab2c27 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-24 14:50+0200\n" +"POT-Creation-Date: 2023-11-30 17:46+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -18,10 +18,10 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: wk_app/settings/common.py:142 +#: wk_app/settings/common.py:143 msgid "English" msgstr "Englisch" -#: wk_app/settings/common.py:143 +#: wk_app/settings/common.py:144 msgid "German" msgstr "Deutsch" -- GitLab From c84396c6e355bc8f05f7007eeadba8c2bbba9a44 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Thu, 30 Nov 2023 17:54:31 +0100 Subject: [PATCH 11/22] Add compilemessages to update process --- setup_dev_environment.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup_dev_environment.sh b/setup_dev_environment.sh index 6a5bf4f5..7200f7a3 100755 --- a/setup_dev_environment.sh +++ b/setup_dev_environment.sh @@ -3,6 +3,7 @@ poetry export -f requirements.txt > requirements.txt docker-compose build docker-compose run --rm api python manage.py migrate +docker-compose run --rm api python manage.py compilemessages if [ ! -f .initial_setup.lock ]; then docker-compose run --rm api python manage.py loaddata core/fixtures/associations.json -- GitLab From 3fda7d06e7b935c0c1c44a41dc6ecf53cfda7b52 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 7 Feb 2024 13:51:02 +0100 Subject: [PATCH 12/22] CAC_SERVICE-421 Add missing dependency for redoc Without the dependency the page `/api/v1/docs` isn't visible and request leads to an error. --- poetry.lock | 103 +++++++++++++++++++++++++++---------------------- pyproject.toml | 1 + 2 files changed, 58 insertions(+), 46 deletions(-) diff --git a/poetry.lock b/poetry.lock index e79e1984..2771e836 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "amqp" @@ -944,11 +944,11 @@ files = [ google-auth = ">=2.14.1,<3.0.dev0" googleapis-common-protos = ">=1.56.2,<2.0.dev0" grpcio = [ - {version = ">=1.33.2,<2.0dev", optional = true, markers = "extra == \"grpc\""}, + {version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""}, {version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, ] grpcio-status = [ - {version = ">=1.33.2,<2.0.dev0", optional = true, markers = "extra == \"grpc\""}, + {version = ">=1.33.2,<2.0.dev0", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""}, {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, ] protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0" @@ -1770,8 +1770,8 @@ files = [ [package.dependencies] numpy = [ {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -2259,51 +2259,62 @@ six = ">=1.15.0" [[package]] name = "pyyaml" -version = "6.0" +version = "6.0.1" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.6" files = [ - {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, - {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, - {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, - {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, - {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, - {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, - {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, - {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, - {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, - {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, - {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, - {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, - {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, - {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, - {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, - {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, - {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, - {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, + {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, + {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, + {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, + {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, + {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, + {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, + {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, + {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, + {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, + {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, + {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, + {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, + {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, + {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, + {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, + {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, + {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, + {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, + {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, + {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, + {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, + {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, + {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] [[package]] @@ -2726,4 +2737,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "211058a6f07dc3d87ae4188445e1a1d202bb088920127225d32dd77b912d9114" +content-hash = "1e235e5fd02f56e25702f476c21be9654bd71f2c0ae962a9e1a36510425282df" diff --git a/pyproject.toml b/pyproject.toml index a05fd562..34f94495 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,7 @@ uritemplate = "^4.1.1" pywebpush = "^1.14.0" firebase-admin = "^6.2.0" pyapns-client = "^2.0.6" +pyyaml = "^6.0.1" [tool.poetry.dev-dependencies] flake8 = "^3.8.4" -- GitLab From 9bd46c299af28d6a7bb8f2320821b4700ca92614 Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 7 Feb 2024 14:42:21 +0100 Subject: [PATCH 13/22] CAC_SERVICE-421 Improve docs --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1fa2babc..6662785a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@   -This is a django based web service, used as a backend to the `Wahlkampf-App` of "DIE LINKE" +This is a django based web service, used as a backend to the `DIE LINKE. App` of "DIE LINKE" The document below will lead you through the setup of a local development environment. Also see notes on [infrastructure](INFRASTRUCTURE.md) and [architecture](ARCHITECTURE.md). @@ -13,9 +13,9 @@ Also see notes on [infrastructure](INFRASTRUCTURE.md) and [architecture](ARCHITE This project offers a auto-generated documentation page in form of a REST Swagger and ReDoc leveraging an OpenAPI 3 schema. -* /api/v1/docs <- An API Explorer powered by ReDoc -* /api/v1/swagger <- REST swagger -* /api/v1/schema <- OpenAPI3 compliant API schema +* `/api/v1/docs` <- An API Explorer powered by ReDoc (:lock: restricted) +* `/api/v1/swagger` <- REST swagger (:lock: restricted) +* `/api/v1/schema` <- OpenAPI3 compliant API schema (:lock: restricted) If you visit these Pages with your browser please note that you will only see endpoints you have sufficient permissions for. If you are not authenticated you will see an authentication error. To authenticate in you browser session see [Session-based authentication](#Session-based-authentication) @@ -45,7 +45,7 @@ bitwarden. DIE LINKE is segmented in different organizational units that map onto different administrative units in germany: [ARCHITECTURE.md#Districts_States_Associations](see architecture). To have this data in your local environment import it from the fixtures: -``` +```shell $ python manage.py loaddata core/fixtures/associations.json ``` @@ -78,7 +78,7 @@ This project uses poetry for package management To setup project make sure poetry(>=1.0.0) is installed on your computer (`pip install poetry`), then: -``` +```shell $ poetry install ``` @@ -118,14 +118,14 @@ $ sudo docker-compose up To develop or execute tests (which is highly recommended) you need a running postgres database. If you stick with the default settings you can easily create a local postgres (with postgis enabled!) instance with docker: -``` +```shell $ docker run -p 5432:5432 -e POSTGRES_USER=wkservice -e POSTGRES_HOST_AUTH_METHOD=trust postgis/postgis ``` Please not without mounting the data directory of that container all data is lost on re-instantiating/start a new container. To persist in `.psql_data` use it like this: -``` -docker run -p 5432:5432 -e POSTGRES_USER=wkservice -v `pwd`/.psql_data:/var/lib/postgresql/data -e POSTGRES_HOST_AUTH_METHOD=trust postgis/postgis +```shell +$ docker run -p 5432:5432 -e POSTGRES_USER=wkservice -v `pwd`/.psql_data:/var/lib/postgresql/data -e POSTGRES_HOST_AUTH_METHOD=trust postgis/postgis ``` Variables might need adjustment if you altered the database settings. @@ -134,7 +134,7 @@ Variables might need adjustment if you altered the database settings. To update your development database to match current migration status run -``` +```shell $ python manage.py migrate ``` @@ -142,7 +142,7 @@ $ python manage.py migrate Conveniently this repository provides some example data jumpstart development and provide some basic data to get started. To use these example data fixtures use the following command: -``` +```shell $ python manage.py loaddata core/fixtures/example_data.json ``` @@ -155,7 +155,7 @@ You will find some basic data filled for events, campaigns, oauth2 applications Run the service like any django project -``` +```shell $ python manage.py runserver ``` @@ -165,11 +165,11 @@ For asynchronous tasks this project uses [celery](https://docs.celeryproject.org If you work on asynchronous tasks it's advisable to actually run a celery runner. For minimal setup just start a redis server and a celery runner -``` +```shell $ redis-server ``` -``` +```shell $ celery -A wk_app.celery worker --loglevel=INFO -B ``` @@ -180,7 +180,7 @@ in your local settings. This will lead to all normally dispatched tasks to be ex This project uses `flake8` which is configured in `.flake8` and invoked like this. -``` +```shell $ flake8 ``` @@ -188,7 +188,7 @@ $ flake8 To avoid checking in unlinted or untested code there is a `.pre-commit-config.yaml` for convenience. You might install it with `pre-commit`: -``` +```shell $ pre-commit install # install the hook ``` -- GitLab From fb9446101b3d40387ca7f2eb7ed1a78a9af7691d Mon Sep 17 00:00:00 2001 From: Peter <peter@ctrl.alt.coop> Date: Wed, 7 Feb 2024 14:44:11 +0100 Subject: [PATCH 14/22] CAC_SERVICE-421 Improve docs --- ADMINISTRATION.md | 4 ++-- INFRASTRUCTURE.md | 1 - README.md | 2 +- REST.md | 37 +++++++++++++++++++------------------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ADMINISTRATION.md b/ADMINISTRATION.md index f1007aaa..f2a93900 100644 --- a/ADMINISTRATION.md +++ b/ADMINISTRATION.md @@ -86,7 +86,7 @@ This is a requested function for internal use. All Sub associations of DIE LINKE cover certain plz areas. This command will spatially lookup all plz areas and export the relation between those areas and their association as csv. -``` +```shell python manage.py export_plz_areas outfile.csv ``` @@ -101,7 +101,7 @@ LEAD_FORM_PUBLIC_ID = 'public id as configured in vtiger' LEAD_ACTUALLY_TRANSMIT = True # Safety switch to avoid spam to production systems, set to False to _actually_ transmit leads ``` -``` +```shell python manage.py export_plz_areas outfile.csv ``` diff --git a/INFRASTRUCTURE.md b/INFRASTRUCTURE.md index 8c7e9ccb..136369f2 100644 --- a/INFRASTRUCTURE.md +++ b/INFRASTRUCTURE.md @@ -59,7 +59,6 @@ Don't forget to [create at least one cert issuer](https://cert-manager.io/docs/c After cert manager is installed you can get certificates by annotating your ingress files accordingly: ```yaml - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/README.md b/README.md index 6662785a..658a015f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Wahlkampf-App-Backend +# die-linke-app-service    diff --git a/REST.md b/REST.md index 040be412..5b4711fa 100644 --- a/REST.md +++ b/REST.md @@ -3,21 +3,22 @@ While the word REST API creates a common understanding over some principles, it can mean different things in practice. Some companies or people ignore some requirements or add some to the principle. Instead of arguing what the _True Meaningâ„¢_ of a REST-API is we define our API endpoint critereas down on this document. <!-- TOC --> -- [General](#general) -- [Documentation](#documentation) -- [Responses](#responses) - - [Results](#results) - - [Errors](#errors) - - [Property Naming](#property-naming) - - [Response Codes](#response-codes) -- [Routing](#routing) - - [Resource routing](#resource-routing) - - [Resource Route Naming](#resource-route-naming) - - [Trailing slashes](#trailing-slashes) - - [RPC-styled endpoints](#rpc-styled-endpoints) - - [Versioning](#versioning) -- [Embedding resources](#embedding-resources) -- [Pagination](#pagination) +- [API Endpoints (REST Guideline)](#api-endpoints-rest-guideline) + - [General](#general) + - [Documentation](#documentation) + - [Responses](#responses) + - [Results](#results) + - [Errors](#errors) + - [Property Naming](#property-naming) + - [Response Codes](#response-codes) + - [Routing](#routing) + - [Resource routing](#resource-routing) + - [Resource Route Naming](#resource-route-naming) + - [Trailing slashes](#trailing-slashes) + - [RPC-styled endpoints](#rpc-styled-endpoints) + - [Versioning](#versioning) + - [Embedding resources](#embedding-resources) + - [Pagination](#pagination) <!-- /TOC --> ## General @@ -40,7 +41,7 @@ Every endpoint must be fully documented using [OpenAPI / Swagger specification]( The requested resource payload needs to be enveloped into a `data` property. That enables us to carry along metadata. Example: -``` +```json { data: {} or [], embedded: {} @@ -52,7 +53,7 @@ Example: ### Errors The payload of the message should look like this: -``` +```json { code: 'a_constant_without_whitespace', message: "A human readable message", @@ -69,7 +70,7 @@ The string in `code` should be a constant of the server code base. Property names of the responses payload must be in CamelCase. Example: -``` +```json { data: { id: 42, -- GitLab From 505baafea12f12d5194d278762bcb82a75a86486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Mon, 11 Mar 2024 17:26:37 +0100 Subject: [PATCH 15/22] Use poetry just as dependency management --- .gitlab-ci.yml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 96cdf9f3..6ca8e58f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,7 +40,7 @@ include: - pip install -U pip setuptools - pip install poetry - poetry config --local virtualenvs.in-project true - - poetry install + - poetry install --no-root cache: paths: - .cache/pip diff --git a/pyproject.toml b/pyproject.toml index 34f94495..976515c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ authors = [ "Jan Gerber <j@open-video.com>", ] license = "GPL-3.0-or-later" +package-mode = false [tool.poetry.dependencies] python = "^3.9" -- GitLab From 39a6b184e86c702aa8536d7fc8241446e0400e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Tue, 12 Mar 2024 16:08:07 +0100 Subject: [PATCH 16/22] Add unittest-xml-reporting This adds info about failed test to gitlab pipeline --- .gitignore | 5 +- .gitlab-ci.yml | 3 + poetry.lock | 122 ++++++++++++++++++++++++++++++++++++++- pyproject.toml | 2 + wk_app/settings/tests.py | 3 + 5 files changed, 132 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a0b995a0..ca1a20db 100644 --- a/.gitignore +++ b/.gitignore @@ -167,4 +167,7 @@ apns.p8 requirements.txt # Ignore lock file for update_dev_environment -.initial_setup.lock \ No newline at end of file +.initial_setup.lock + +# Ignore test report output +report.xml \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ca8e58f..8dc04158 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,7 +70,10 @@ test: - poetry run coverage run manage.py test --noinput --parallel=4 - poetry run coverage xml artifacts: + paths: + - report.xml reports: + junit: report.xml coverage_report: coverage_format: cobertura path: coverage.xml diff --git a/poetry.lock b/poetry.lock index 2771e836..e4e7102d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "amqp" @@ -1558,6 +1558,99 @@ sqs = ["boto3 (>=1.9.12)", "pycurl (>=7.44.1,<7.45.0)", "urllib3 (>=1.26.7)"] yaml = ["PyYAML (>=3.10)"] zookeeper = ["kazoo (>=1.3.1)"] +[[package]] +name = "lxml" +version = "5.1.0" +description = "Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API." +optional = false +python-versions = ">=3.6" +files = [ + {file = "lxml-5.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:704f5572ff473a5f897745abebc6df40f22d4133c1e0a1f124e4f2bd3330ff7e"}, + {file = "lxml-5.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9d3c0f8567ffe7502d969c2c1b809892dc793b5d0665f602aad19895f8d508da"}, + {file = "lxml-5.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5fcfbebdb0c5d8d18b84118842f31965d59ee3e66996ac842e21f957eb76138c"}, + {file = "lxml-5.1.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f37c6d7106a9d6f0708d4e164b707037b7380fcd0b04c5bd9cae1fb46a856fb"}, + {file = "lxml-5.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2befa20a13f1a75c751f47e00929fb3433d67eb9923c2c0b364de449121f447c"}, + {file = "lxml-5.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22b7ee4c35f374e2c20337a95502057964d7e35b996b1c667b5c65c567d2252a"}, + {file = "lxml-5.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:bf8443781533b8d37b295016a4b53c1494fa9a03573c09ca5104550c138d5c05"}, + {file = "lxml-5.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:82bddf0e72cb2af3cbba7cec1d2fd11fda0de6be8f4492223d4a268713ef2147"}, + {file = "lxml-5.1.0-cp310-cp310-win32.whl", hash = "sha256:b66aa6357b265670bb574f050ffceefb98549c721cf28351b748be1ef9577d93"}, + {file = "lxml-5.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:4946e7f59b7b6a9e27bef34422f645e9a368cb2be11bf1ef3cafc39a1f6ba68d"}, + {file = "lxml-5.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:14deca1460b4b0f6b01f1ddc9557704e8b365f55c63070463f6c18619ebf964f"}, + {file = "lxml-5.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ed8c3d2cd329bf779b7ed38db176738f3f8be637bb395ce9629fc76f78afe3d4"}, + {file = "lxml-5.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:436a943c2900bb98123b06437cdd30580a61340fbdb7b28aaf345a459c19046a"}, + {file = "lxml-5.1.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:acb6b2f96f60f70e7f34efe0c3ea34ca63f19ca63ce90019c6cbca6b676e81fa"}, + {file = "lxml-5.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:af8920ce4a55ff41167ddbc20077f5698c2e710ad3353d32a07d3264f3a2021e"}, + {file = "lxml-5.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7cfced4a069003d8913408e10ca8ed092c49a7f6cefee9bb74b6b3e860683b45"}, + {file = "lxml-5.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9e5ac3437746189a9b4121db2a7b86056ac8786b12e88838696899328fc44bb2"}, + {file = "lxml-5.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f4c9bda132ad108b387c33fabfea47866af87f4ea6ffb79418004f0521e63204"}, + {file = "lxml-5.1.0-cp311-cp311-win32.whl", hash = "sha256:bc64d1b1dab08f679fb89c368f4c05693f58a9faf744c4d390d7ed1d8223869b"}, + {file = "lxml-5.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:a5ab722ae5a873d8dcee1f5f45ddd93c34210aed44ff2dc643b5025981908cda"}, + {file = "lxml-5.1.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:9aa543980ab1fbf1720969af1d99095a548ea42e00361e727c58a40832439114"}, + {file = "lxml-5.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6f11b77ec0979f7e4dc5ae081325a2946f1fe424148d3945f943ceaede98adb8"}, + {file = "lxml-5.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a36c506e5f8aeb40680491d39ed94670487ce6614b9d27cabe45d94cd5d63e1e"}, + {file = "lxml-5.1.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f643ffd2669ffd4b5a3e9b41c909b72b2a1d5e4915da90a77e119b8d48ce867a"}, + {file = "lxml-5.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:16dd953fb719f0ffc5bc067428fc9e88f599e15723a85618c45847c96f11f431"}, + {file = "lxml-5.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:16018f7099245157564d7148165132c70adb272fb5a17c048ba70d9cc542a1a1"}, + {file = "lxml-5.1.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:82cd34f1081ae4ea2ede3d52f71b7be313756e99b4b5f829f89b12da552d3aa3"}, + {file = "lxml-5.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:19a1bc898ae9f06bccb7c3e1dfd73897ecbbd2c96afe9095a6026016e5ca97b8"}, + {file = "lxml-5.1.0-cp312-cp312-win32.whl", hash = "sha256:13521a321a25c641b9ea127ef478b580b5ec82aa2e9fc076c86169d161798b01"}, + {file = "lxml-5.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:1ad17c20e3666c035db502c78b86e58ff6b5991906e55bdbef94977700c72623"}, + {file = "lxml-5.1.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:24ef5a4631c0b6cceaf2dbca21687e29725b7c4e171f33a8f8ce23c12558ded1"}, + {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8d2900b7f5318bc7ad8631d3d40190b95ef2aa8cc59473b73b294e4a55e9f30f"}, + {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:601f4a75797d7a770daed8b42b97cd1bb1ba18bd51a9382077a6a247a12aa38d"}, + {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4b68c961b5cc402cbd99cca5eb2547e46ce77260eb705f4d117fd9c3f932b95"}, + {file = "lxml-5.1.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:afd825e30f8d1f521713a5669b63657bcfe5980a916c95855060048b88e1adb7"}, + {file = "lxml-5.1.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:262bc5f512a66b527d026518507e78c2f9c2bd9eb5c8aeeb9f0eb43fcb69dc67"}, + {file = "lxml-5.1.0-cp36-cp36m-win32.whl", hash = "sha256:e856c1c7255c739434489ec9c8aa9cdf5179785d10ff20add308b5d673bed5cd"}, + {file = "lxml-5.1.0-cp36-cp36m-win_amd64.whl", hash = "sha256:c7257171bb8d4432fe9d6fdde4d55fdbe663a63636a17f7f9aaba9bcb3153ad7"}, + {file = "lxml-5.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b9e240ae0ba96477682aa87899d94ddec1cc7926f9df29b1dd57b39e797d5ab5"}, + {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a96f02ba1bcd330807fc060ed91d1f7a20853da6dd449e5da4b09bfcc08fdcf5"}, + {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e3898ae2b58eeafedfe99e542a17859017d72d7f6a63de0f04f99c2cb125936"}, + {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61c5a7edbd7c695e54fca029ceb351fc45cd8860119a0f83e48be44e1c464862"}, + {file = "lxml-5.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:3aeca824b38ca78d9ee2ab82bd9883083d0492d9d17df065ba3b94e88e4d7ee6"}, + {file = "lxml-5.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8f52fe6859b9db71ee609b0c0a70fea5f1e71c3462ecf144ca800d3f434f0764"}, + {file = "lxml-5.1.0-cp37-cp37m-win32.whl", hash = "sha256:d42e3a3fc18acc88b838efded0e6ec3edf3e328a58c68fbd36a7263a874906c8"}, + {file = "lxml-5.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:eac68f96539b32fce2c9b47eb7c25bb2582bdaf1bbb360d25f564ee9e04c542b"}, + {file = "lxml-5.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ae15347a88cf8af0949a9872b57a320d2605ae069bcdf047677318bc0bba45b1"}, + {file = "lxml-5.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c26aab6ea9c54d3bed716b8851c8bfc40cb249b8e9880e250d1eddde9f709bf5"}, + {file = "lxml-5.1.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:342e95bddec3a698ac24378d61996b3ee5ba9acfeb253986002ac53c9a5f6f84"}, + {file = "lxml-5.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:725e171e0b99a66ec8605ac77fa12239dbe061482ac854d25720e2294652eeaa"}, + {file = "lxml-5.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d184e0d5c918cff04cdde9dbdf9600e960161d773666958c9d7b565ccc60c45"}, + {file = "lxml-5.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:98f3f020a2b736566c707c8e034945c02aa94e124c24f77ca097c446f81b01f1"}, + {file = "lxml-5.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6d48fc57e7c1e3df57be5ae8614bab6d4e7b60f65c5457915c26892c41afc59e"}, + {file = "lxml-5.1.0-cp38-cp38-win32.whl", hash = "sha256:7ec465e6549ed97e9f1e5ed51c657c9ede767bc1c11552f7f4d022c4df4a977a"}, + {file = "lxml-5.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:b21b4031b53d25b0858d4e124f2f9131ffc1530431c6d1321805c90da78388d1"}, + {file = "lxml-5.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:52427a7eadc98f9e62cb1368a5079ae826f94f05755d2d567d93ee1bc3ceb354"}, + {file = "lxml-5.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6a2a2c724d97c1eb8cf966b16ca2915566a4904b9aad2ed9a09c748ffe14f969"}, + {file = "lxml-5.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:843b9c835580d52828d8f69ea4302537337a21e6b4f1ec711a52241ba4a824f3"}, + {file = "lxml-5.1.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9b99f564659cfa704a2dd82d0684207b1aadf7d02d33e54845f9fc78e06b7581"}, + {file = "lxml-5.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4f8b0c78e7aac24979ef09b7f50da871c2de2def043d468c4b41f512d831e912"}, + {file = "lxml-5.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9bcf86dfc8ff3e992fed847c077bd875d9e0ba2fa25d859c3a0f0f76f07f0c8d"}, + {file = "lxml-5.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:49a9b4af45e8b925e1cd6f3b15bbba2c81e7dba6dce170c677c9cda547411e14"}, + {file = "lxml-5.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:280f3edf15c2a967d923bcfb1f8f15337ad36f93525828b40a0f9d6c2ad24890"}, + {file = "lxml-5.1.0-cp39-cp39-win32.whl", hash = "sha256:ed7326563024b6e91fef6b6c7a1a2ff0a71b97793ac33dbbcf38f6005e51ff6e"}, + {file = "lxml-5.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:8d7b4beebb178e9183138f552238f7e6613162a42164233e2bda00cb3afac58f"}, + {file = "lxml-5.1.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:9bd0ae7cc2b85320abd5e0abad5ccee5564ed5f0cc90245d2f9a8ef330a8deae"}, + {file = "lxml-5.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8c1d679df4361408b628f42b26a5d62bd3e9ba7f0c0e7969f925021554755aa"}, + {file = "lxml-5.1.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:2ad3a8ce9e8a767131061a22cd28fdffa3cd2dc193f399ff7b81777f3520e372"}, + {file = "lxml-5.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:304128394c9c22b6569eba2a6d98392b56fbdfbad58f83ea702530be80d0f9df"}, + {file = "lxml-5.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d74fcaf87132ffc0447b3c685a9f862ffb5b43e70ea6beec2fb8057d5d2a1fea"}, + {file = "lxml-5.1.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:8cf5877f7ed384dabfdcc37922c3191bf27e55b498fecece9fd5c2c7aaa34c33"}, + {file = "lxml-5.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:877efb968c3d7eb2dad540b6cabf2f1d3c0fbf4b2d309a3c141f79c7e0061324"}, + {file = "lxml-5.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3f14a4fb1c1c402a22e6a341a24c1341b4a3def81b41cd354386dcb795f83897"}, + {file = "lxml-5.1.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:25663d6e99659544ee8fe1b89b1a8c0aaa5e34b103fab124b17fa958c4a324a6"}, + {file = "lxml-5.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:8b9f19df998761babaa7f09e6bc169294eefafd6149aaa272081cbddc7ba4ca3"}, + {file = "lxml-5.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e53d7e6a98b64fe54775d23a7c669763451340c3d44ad5e3a3b48a1efbdc96f"}, + {file = "lxml-5.1.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:c3cd1fc1dc7c376c54440aeaaa0dcc803d2126732ff5c6b68ccd619f2e64be4f"}, + {file = "lxml-5.1.0.tar.gz", hash = "sha256:3eea6ed6e6c918e468e693c41ef07f3c3acc310b70ddd9cc72d9ef84bc9564ca"}, +] + +[package.extras] +cssselect = ["cssselect (>=0.7)"] +html5 = ["html5lib"] +htmlsoup = ["BeautifulSoup4"] +source = ["Cython (>=3.0.7)"] + [[package]] name = "matplotlib-inline" version = "0.1.6" @@ -2478,6 +2571,17 @@ dev = ["build", "flake8"] doc = ["sphinx"] test = ["pytest", "pytest-cov"] +[[package]] +name = "tblib" +version = "3.0.0" +description = "Traceback serialization library." +optional = false +python-versions = ">=3.8" +files = [ + {file = "tblib-3.0.0-py3-none-any.whl", hash = "sha256:80a6c77e59b55e83911e1e607c649836a69c103963c5f28a46cbeef44acf8129"}, + {file = "tblib-3.0.0.tar.gz", hash = "sha256:93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6"}, +] + [[package]] name = "tomli" version = "2.0.1" @@ -2537,6 +2641,20 @@ files = [ {file = "ua_parser-0.16.1-py2.py3-none-any.whl", hash = "sha256:f97126300df8ac0f8f2c9d8559669532d626a1af529265fd253cba56e73ab36e"}, ] +[[package]] +name = "unittest-xml-reporting" +version = "3.2.0" +description = "unittest-based test runner with Ant/JUnit like XML reporting." +optional = false +python-versions = ">=3.7" +files = [ + {file = "unittest-xml-reporting-3.2.0.tar.gz", hash = "sha256:edd8d3170b40c3a81b8cf910f46c6a304ae2847ec01036d02e9c0f9b85762d28"}, + {file = "unittest_xml_reporting-3.2.0-py2.py3-none-any.whl", hash = "sha256:f3d7402e5b3ac72a5ee3149278339db1a8f932ee405f48bcb9c681372f2717d5"}, +] + +[package.dependencies] +lxml = "*" + [[package]] name = "uritemplate" version = "4.1.1" @@ -2737,4 +2855,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "1e235e5fd02f56e25702f476c21be9654bd71f2c0ae962a9e1a36510425282df" +content-hash = "db6af87fc2673eb8536e9a850b337a5cd875fb7e11c7554f705bdee8a50fb329" diff --git a/pyproject.toml b/pyproject.toml index 976515c9..b79f84de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ freezegun = "^1.1.0" [tool.poetry.group.dev.dependencies] pytest = "^7.3.1" +unittest-xml-reporting = "^3.2.0" +tblib = "^3.0.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/wk_app/settings/tests.py b/wk_app/settings/tests.py index 2ddd41dd..50b4c33e 100644 --- a/wk_app/settings/tests.py +++ b/wk_app/settings/tests.py @@ -4,3 +4,6 @@ from .common import * # noqa: F403,F401 CELERY_TASK_ALWAYS_EAGER = True STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage" +TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' +TEST_OUTPUT_FILE_NAME = 'report.xml' +TEST_OUTPUT_VERBOSE = 1 -- GitLab From 2ca19329b8bf3582a5ab2e3cf14f4f54016de0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Tue, 12 Mar 2024 16:49:15 +0100 Subject: [PATCH 17/22] Improve code coverage --- .coveragerc | 6 ++++++ .gitlab-ci.yml | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..eb3310d5 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +source = . +omit = ./.venv/*,./venv/*,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py + +[report] +omit = ./.venv/*./venv/*,*tests*,*apps.py,*manage.py,*__init__.py,*migrations*,*asgi*,*wsgi*,*admin.py,*urls.py \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8dc04158..850de480 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,6 +69,8 @@ test: script: - poetry run coverage run manage.py test --noinput --parallel=4 - poetry run coverage xml + - poetry run coverage report + coverage: '/^TOTAL.*\s+(\d+\%)$/' artifacts: paths: - report.xml -- GitLab From e9bd724c09c39396a58c7a733e8762bd3686ec9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Wed, 13 Mar 2024 10:47:50 +0100 Subject: [PATCH 18/22] Remove badges from README --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 658a015f..62532b5e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@ # die-linke-app-service - - - - This is a django based web service, used as a backend to the `DIE LINKE. App` of "DIE LINKE" The document below will lead you through the setup of a local development environment. Also see notes on [infrastructure](INFRASTRUCTURE.md) and [architecture](ARCHITECTURE.md). -- GitLab From d84b2710564a142e2fd8ab6e170a89cd3ed36ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Wed, 13 Mar 2024 15:38:21 +0100 Subject: [PATCH 19/22] Add poetry-plugin-export explicitly --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 850de480..77637999 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,6 +97,7 @@ freeze: extends: .setup stage: test script: + - poetry self add poetry-plugin-export - poetry export -f requirements.txt > requirements.txt artifacts: paths: [ requirements.txt ] -- GitLab From 591b776db11e42819c055640f3efa0e0ab727c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Wed, 13 Mar 2024 15:55:22 +0100 Subject: [PATCH 20/22] Remove deployment --- .gitlab-ci.yml | 107 ---------------- INFRASTRUCTURE.md | 85 ------------- .../base/add-gitlab-annotations.template.yaml | 45 ------- kustomize/base/deployment.yaml | 119 ------------------ kustomize/base/ingress.yaml | 24 ---- kustomize/base/kustomization.yaml | 25 ---- kustomize/base/redis.yaml | 54 -------- kustomize/base/service.yaml | 10 -- kustomize/development/ingress-override.yaml | 20 --- kustomize/development/kustomization.yaml | 8 -- kustomize/hydrate_variables.sh | 34 ----- kustomize/review/deployment-patch.yaml | 16 --- .../review/ingress-override.template.yaml | 20 --- kustomize/review/kustomization.yaml | 18 --- kustomize/review/postgres.yaml | 59 --------- kustomize/review/pvc.yaml | 13 -- kustomize/staging/ingress-override.yaml | 20 --- kustomize/staging/kustomization.yaml | 8 -- 18 files changed, 685 deletions(-) delete mode 100644 INFRASTRUCTURE.md delete mode 100644 kustomize/base/add-gitlab-annotations.template.yaml delete mode 100644 kustomize/base/deployment.yaml delete mode 100644 kustomize/base/ingress.yaml delete mode 100644 kustomize/base/kustomization.yaml delete mode 100644 kustomize/base/redis.yaml delete mode 100644 kustomize/base/service.yaml delete mode 100644 kustomize/development/ingress-override.yaml delete mode 100644 kustomize/development/kustomization.yaml delete mode 100755 kustomize/hydrate_variables.sh delete mode 100644 kustomize/review/deployment-patch.yaml delete mode 100644 kustomize/review/ingress-override.template.yaml delete mode 100644 kustomize/review/kustomization.yaml delete mode 100644 kustomize/review/postgres.yaml delete mode 100644 kustomize/review/pvc.yaml delete mode 100644 kustomize/staging/ingress-override.yaml delete mode 100644 kustomize/staging/kustomization.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77637999..a70fa5b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,10 +2,6 @@ image: python:3.9.6 stages: - test - - pre-build - - build - - deploy - - cleanup services: - name: postgis/postgis:13-3.1 @@ -18,20 +14,6 @@ variables: POSTGRES_USER: wkservice POSTGRES_PASSWORD: "" POSTGRES_HOST_AUTH_METHOD: trust - KUBE_NAMESPACE: "wk-service-$CI_ENVIRONMENT_SLUG" - -prepare-autobuild: - stage: pre-build - script: - - if [ -f "$GOOGLE_SERVICE_ACCOUNT_JSON" ]; then cp "$GOOGLE_SERVICE_ACCOUNT_JSON" ./service-account.json; else echo "No service account file defined"; fi - - if [ -f "$IOS_PRIVATE_KEY_FILE" ]; then cp "$IOS_PRIVATE_KEY_FILE" ./apns.p8; else echo "No iOS private key found"; fi - artifacts: - paths: - - service-account.json - - apns.p8 - -include: - - template: Jobs/Build.gitlab-ci.yml .setup: interruptible: true @@ -80,18 +62,6 @@ test: coverage_format: cobertura path: coverage.xml -.deploy-template: - image: registry.gitlab.alt.coop/ctrlaltcoop/deployment-toolchain:v0.0.7 - before_script: - - kubectl config get-contexts - - kubectl config use-context wahlkampf-app/wk-service:do-wk-service - - kubectl create namespace $KUBE_NAMESPACE --dry-run=client -o yaml | kubectl apply -f - - - cd kustomize/base - - kustomize edit set namespace $KUBE_NAMESPACE - - kubectl create secret docker-registry gitlab-registry -n $KUBE_NAMESPACE --docker-server="$CI_REGISTRY" --docker-username="$CI_DEPLOY_USER" --docker-password="$CI_DEPLOY_PASSWORD" --docker-email="$GITLAB_USER_EMAIL" -o yaml --dry-run=client | kubectl apply -f - - - envsubst < add-gitlab-annotations.template.yaml > add-gitlab-annotations.yaml - - cd ../../ - freeze: extends: .setup @@ -101,80 +71,3 @@ freeze: - poetry export -f requirements.txt > requirements.txt artifacts: paths: [ requirements.txt ] - - -staging: - extends: .deploy-template - stage: deploy - script: - - cd kustomize/staging - - kustomize edit set namespace $KUBE_NAMESPACE - - ../hydrate_variables.sh - - kustomize build | kubectl apply -f - - only: - - /^release/(\d+\.)(\d+\.)(\d+)$/ - environment: - name: staging - url: https://staging.wk-service.haze.alt.coop - -development: - extends: .deploy-template - stage: deploy - script: - - cd kustomize/development - - kustomize edit set namespace $KUBE_NAMESPACE - - ../hydrate_variables.sh - - kustomize build | kubectl apply -f - - only: - - develop - environment: - name: development - url: https://development.wk-service.haze.alt.coop - -review: - extends: .deploy-template - stage: deploy - script: - - export DB_NAME=$CI_ENVIRONMENT_SLUG - - export DB_USER=$CI_ENVIRONMENT_SLUG - - export DB_HOST=postgres - - export DB_PORT=5432 - - cd kustomize/review - - export INGRESS_HOST=$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN - - envsubst < ingress-override.template.yaml > ingress-override.yaml - - ../hydrate_variables.sh - - kustomize edit set namespace $KUBE_NAMESPACE - - kustomize build # print to stdout to debug - - kustomize build > out.yaml - - kubectl apply -f out.yaml - except: - - /^release/(\d+\.)(\d+\.)(\d+)$/ - - main - - develop - - tags - environment: - name: review/$CI_COMMIT_REF_SLUG - url: https://$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN - on_stop: stop_review - artifacts: - paths: [ kustomize/review/out.yaml ] - -stop_review: - stage: cleanup - image: registry.gitlab.alt.coop/ctrlaltcoop/deployment-toolchain:v0.0.7 - variables: - GIT_STRATEGY: none - script: - - kubectl config get-contexts - - kubectl config use-context wahlkampf-app/wk-service:do-wk-service - - kubectl delete -f ./kustomize/review/out.yaml - - kubectl delete ns $KUBE_NAMESPACE - when: manual - except: - - /^release/(\d+\.)(\d+\.)(\d+)$/ - - main - - develop - - tags - environment: - name: review/$CI_COMMIT_REF_SLUG - action: stop diff --git a/INFRASTRUCTURE.md b/INFRASTRUCTURE.md deleted file mode 100644 index 136369f2..00000000 --- a/INFRASTRUCTURE.md +++ /dev/null @@ -1,85 +0,0 @@ -# Infrastructure - -This document aims to describe the current deployment of this project. - - -## General - -This project is deployed via kubernetes, aiming to be provider agnostic. - -## Deployment configuration (kustomize, not helm) - -For kubernetes config management it uses [kustomize](https://kustomize.io/). The files for the kustomizations are to be found in [/kustomize](/kustomize). -The rationale for not using helm (if you were asking yourself that) is that templated yaml files are near to unreadable. The per-environment overlay -system allows you to always write clean yaml (with some exceptions). - -### Injecting variables - -While general environment configurations can be done statically in overlay files (like setting a ingress hostname for staging), some variables -are dynamic and only available during the CI execution pipeline. (Such as secrets, or dynamic namespace values). In most cases we can create a config map with -the kustomize CLI tool, like executing `kustomize edit add configmap application-config --behavior=merge --from-literal=DB_HOST=$DB_HOST` in the overlay folder, which -will add the DB_HOST environment variable to a config map which is made available to our deployment. Same accounts for secrets we don't want to check into our repos. -The script [hydrate_variables.sh](./kustomize/hydrate_variables.sh) takes care adding all necessary environment variables to ConfigMaps/Secrets. Make sure to have -all necessary env vars in your shell before executing this script *inside the kustomize folder you like to deploy (i.e. staging)*. - -Earlier we stated no templating is needed with kustomize, which is (sadly) only partly true. Config maps only work for cases when we want to pass -dynamic variables to kubernetes objects after deployment. For meta configuration, like the ingress hostname or annotations for a deployment need to be substituded before -deployment. Therefore before actually being able to deploy an environment all *.template.yaml files need to be run through -`envsubst < [filename].template.yaml > [filename].yaml` with the according environment variables set. It's not optimal but we did not find a better solution yet. - -### Applying - -If your deployment configuration is complete you can review the result by typing `kustomize build` (again in the environment specific folder). -If you are satisfied you can apply it to the cluster with `kustomize build | kubectl apply -f -`. - -## CI/CD - -Note that the above steps are executed by CI/CD and ideally should only be executed from there to remain a consistent workflow where version control and deployment -are tightly coupled. - - -## Infrastructure / Provider - -As of now we use the managed kubernetes service offered by Digital Ocean, where a single cluster is reserved for this project. -The subdomain *.wk-service.haze.alt.coop is delegated to the Load-Balancer routing this cluster (see below). - -Note that below steps are already done on the current infrastructure and are instructions / a historic documentation of steps that need to be taken to set it up. - -### Ingress Controller / Load-Balancer - -To route traffic from the outside *into* the cluster we use the [ingress controller of digital ocean](https://marketplace.digitalocean.com/apps/nginx-ingress-controller). -This controller will translate Ingress configurations into a LoadBalancer with according configuration automatically. Note that you have to install -*the controller on the cluster manually*, as it's not installed by default. Once installed no further action is needed. - -### Cert manager - -To provide letsencrypt certificates cert manager is used. Follow the [install instructions for kubernetes](https://cert-manager.io/docs/installation/kubernetes/#installing-with-regular-manifests) -Don't forget to [create at least one cert issuer](https://cert-manager.io/docs/configuration/acme/#configuration), probably the http issuer for letsencrypt. - -After cert manager is installed you can get certificates by annotating your ingress files accordingly: - -```yaml -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - ingress.kubernetes.io/rewrite-target: / - cert-manager.io/cluster-issuer: "letsencrypt-prod" - name: wkservice-ingress -spec: - tls: - - hosts: - - wkservice.local # placeholder - secretName: tls-secrets - rules: - [...] -``` - -Cert manager will pick up these and issue certificates automatically. These annotations are already present on the current configuration. - -### Databases - -Review deployments contain a deployment configurations for postgres containers claiming a bit of block storage. -As maintaining production critical databases in kubernetes tend to be hard and redundancy and optimizations in postgres are hard in general, -for staging and production we'll use the managed postgres service of DigitalOcean, putting the managed database in the same private network as -the cluster making unavailable to the internet. diff --git a/kustomize/base/add-gitlab-annotations.template.yaml b/kustomize/base/add-gitlab-annotations.template.yaml deleted file mode 100644 index 58a96949..00000000 --- a/kustomize/base/add-gitlab-annotations.template.yaml +++ /dev/null @@ -1,45 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" -spec: - - template: - metadata: - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice-celery-worker - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" -spec: - - template: - metadata: - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice-celery-beat - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" -spec: - - template: - metadata: - annotations: - app.gitlab.com/app: "${CI_PROJECT_PATH_SLUG}" - app.gitlab.com/env: "${CI_ENVIRONMENT_SLUG}" diff --git a/kustomize/base/deployment.yaml b/kustomize/base/deployment.yaml deleted file mode 100644 index 80dd7d17..00000000 --- a/kustomize/base/deployment.yaml +++ /dev/null @@ -1,119 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice - labels: - app: wkservice -spec: - replicas: 1 - selector: - matchLabels: - app: wkservice - template: - metadata: - labels: - app: wkservice - spec: - imagePullSecrets: - - name: gitlab-registry - initContainers: - - name: check-db-ready - image: postgres:12 - command: [ 'sh', '-c', - 'until pg_isready -h $DB_HOST -p $DB_PORT; - do echo waiting for database; sleep 2; done;' ] - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets - - name: migrate - image: registry.gitlab.alt.coop/wahlkampf-app/wk-service - command: [ 'python', 'manage.py', 'migrate' ] - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets - env: - - name: DJANGO_SETTINGS_MODULE - value: wk_app.settings.env_based - containers: - - name: wkservice - image: registry.gitlab.alt.coop/wahlkampf-app/wk-service - imagePullPolicy: Always - ports: - - containerPort: 8000 - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets - env: - - name: DJANGO_SETTINGS_MODULE - value: wk_app.settings.env_based ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice-celery-worker - labels: - app: wkservice-celery-worker -spec: - replicas: 1 - selector: - matchLabels: - app: wkservice-celery-worker - template: - metadata: - labels: - app: wkservice-celery-worker - spec: - imagePullSecrets: - - name: gitlab-registry - containers: - - name: wkservice-celery-worker - image: registry.gitlab.alt.coop/wahlkampf-app/wk-service - command: ['celery', '-A', 'wk_app.celery', 'worker', '--loglevel=INFO'] - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets - env: - - name: DJANGO_SETTINGS_MODULE - value: wk_app.settings.env_based ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: wkservice-celery-beat - labels: - app: wkservice-celery-beat -spec: - replicas: 1 - selector: - matchLabels: - app: wkservice-celery-beat - template: - metadata: - labels: - app: wkservice-celery-beat - spec: - imagePullSecrets: - - name: gitlab-registry - containers: - - name: wkservice-celery-beat - image: registry.gitlab.alt.coop/wahlkampf-app/wk-service - ports: - - containerPort: 8000 - command: [ 'celery', '-A', 'wk_app.celery', 'beat', '--loglevel=INFO' ] - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets - env: - - name: DJANGO_SETTINGS_MODULE - value: wk_app.settings.env_based diff --git a/kustomize/base/ingress.yaml b/kustomize/base/ingress.yaml deleted file mode 100644 index 91e6adb7..00000000 --- a/kustomize/base/ingress.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - annotations: - ingress.kubernetes.io/rewrite-target: / - cert-manager.io/cluster-issuer: "letsencrypt-prod" - name: wkservice-ingress -spec: - ingressClassName: nginx - tls: - - hosts: - - wkservice.local # placeholder - secretName: tls-secrets - rules: - - host: wkservice.local # placeholder - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: wkservice - port: - number: 8000 diff --git a/kustomize/base/kustomization.yaml b/kustomize/base/kustomization.yaml deleted file mode 100644 index fcc05ec5..00000000 --- a/kustomize/base/kustomization.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: -- deployment.yaml -- ingress.yaml -- service.yaml -- redis.yaml - - -namespace: default - - -images: -- name: registry.gitlab.alt.coop/wahlkampf-app/wk-service - newName: registry.gitlab.alt.coop/wahlkampf-app/wk-service - newTag: master - -configMapGenerator: -- name: application-config - -# Cannot change to non-deprecated "patches" yet, as it needs to support multiple -# sm patches in one file: https://github.com/kubernetes-sigs/kustomize/issues/5049 -patchesStrategicMerge: -- ./add-gitlab-annotations.yaml diff --git a/kustomize/base/redis.yaml b/kustomize/base/redis.yaml deleted file mode 100644 index d62b308f..00000000 --- a/kustomize/base/redis.yaml +++ /dev/null @@ -1,54 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: redis - labels: - app: redis -spec: - replicas: 1 - selector: - matchLabels: - app: redis - template: - metadata: - labels: - app: redis - spec: - containers: - - name: redis - image: redis:6-alpine - command: ['redis-server', '/usr/local/etc/redis/redis.conf'] - ports: - - containerPort: 6379 - name: redis - volumeMounts: - - name: redis-conf - mountPath: "/usr/local/etc/redis" - readOnly: true - volumes: - - name: redis-conf - configMap: - name: redis-conf - items: - - key: "redis.conf" - path: "redis.conf" ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: redis-conf -data: - redis.conf: | - bind 0.0.0.0 ---- -apiVersion: v1 -kind: Service -metadata: - name: redis -spec: - selector: - app: redis - ports: - - protocol: TCP - port: 6379 - name: redis diff --git a/kustomize/base/service.yaml b/kustomize/base/service.yaml deleted file mode 100644 index 7283acbe..00000000 --- a/kustomize/base/service.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: wkservice -spec: - selector: - app: wkservice - ports: - - protocol: TCP - port: 8000 diff --git a/kustomize/development/ingress-override.yaml b/kustomize/development/ingress-override.yaml deleted file mode 100644 index 4b930632..00000000 --- a/kustomize/development/ingress-override.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: wkservice-ingress -spec: - tls: - - hosts: - - development.wk-service.haze.alt.coop - secretName: tls-secrets - rules: - - host: development.wk-service.haze.alt.coop - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: wkservice - port: - number: 8000 diff --git a/kustomize/development/kustomization.yaml b/kustomize/development/kustomization.yaml deleted file mode 100644 index 7a065351..00000000 --- a/kustomize/development/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -bases: -- ../base - -patchesStrategicMerge: -- ingress-override.yaml diff --git a/kustomize/hydrate_variables.sh b/kustomize/hydrate_variables.sh deleted file mode 100755 index ff476ad9..00000000 --- a/kustomize/hydrate_variables.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -kustomize edit set image $CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA -kustomize edit add configmap application-config --behavior=merge --from-literal=DB_USER=$DB_USER -kustomize edit add configmap application-config --behavior=merge --from-literal=DB_NAME=$DB_NAME -kustomize edit add configmap application-config --behavior=merge --from-literal=DB_HOST=$DB_HOST -kustomize edit add configmap application-config --behavior=merge --from-literal=DB_PORT=$DB_PORT -kustomize edit add configmap application-config --behavior=merge --from-literal=OSM_DB_USER=$OSM_DB_USER -kustomize edit add configmap application-config --behavior=merge --from-literal=OSM_DB_HOST=$OSM_DB_HOST -kustomize edit add configmap application-config --behavior=merge --from-literal=OSM_DB_NAME=$OSM_DB_NAME -kustomize edit add configmap application-config --behavior=merge --from-literal=OSM_DB_PORT=$OSM_DB_PORT -kustomize edit add configmap application-config --behavior=merge --from-literal=EMAIL_HOST=$EMAIL_HOST -kustomize edit add configmap application-config --behavior=merge --from-literal=EMAIL_PORT=$EMAIL_PORT -kustomize edit add configmap application-config --behavior=merge --from-literal=EMAIL_HOST_USER=$EMAIL_HOST_USER -kustomize edit add configmap application-config --behavior=merge --from-literal=DEFAULT_FROM_EMAIL=$DEFAULT_FROM_EMAIL -kustomize edit add configmap application-config --behavior=merge --from-literal=APP_URL=$APP_URL -kustomize edit add configmap application-config --behavior=merge --from-literal=CELERY_BROKER_URL=$CELERY_BROKER_URL -kustomize edit add configmap application-config --behavior=merge --from-literal=LEAD_ACTUALLY_TRANSMIT=$LEAD_ACTUALLY_TRANSMIT -kustomize edit add configmap application-config --behavior=merge --from-literal=LEAD_FORM_URL=$LEAD_FORM_URL -kustomize edit add configmap application-config --behavior=merge --from-literal=CSRF_COOKIE_DOMAIN=$CSRF_COOKIE_DOMAIN -kustomize edit add configmap application-config --behavior=merge --from-literal=CSRF_TRUSTED_ORIGINS=$CSRF_TRUSTED_ORIGINS -kustomize edit add configmap application-config --behavior=merge --from-literal=VAPID_PUBLIC_KEY=$VAPID_PUBLIC_KEY -kustomize edit add configmap application-config --behavior=merge --from-literal=VAPID_PRIVATE_KEY=$VAPID_PRIVATE_KEY -kustomize edit add configmap application-config --behavior=merge --from-literal=VAPID_EMAIL_ADDRESS=$VAPID_EMAIL_ADDRESS -kustomize edit add configmap application-config --behavior=merge --from-literal=GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS -kustomize edit add configmap application-config --behavior=merge --from-literal=IOS_KEY_ID=$IOS_KEY_ID -kustomize edit add configmap application-config --behavior=merge --from-literal=IOS_TEAM_ID=$IOS_TEAM_ID -kustomize edit add configmap application-config --behavior=merge --from-literal=IOS_BUNDLE_ID=$IOS_BUNDLE_ID -kustomize edit add configmap application-config --behavior=merge --from-literal=IOS_AUTH_KEY_FILE=$IOS_AUTH_KEY_FILE - -kustomize edit add secret application-secrets --from-literal=DB_PASSWORD=$DB_PASSWORD -kustomize edit add secret application-secrets --from-literal=OSM_DB_PASSWORD=$OSM_DB_PASSWORD -kustomize edit add secret application-secrets --from-literal=DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY -kustomize edit add secret application-secrets --from-literal=EMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD -kustomize edit add secret application-secrets --from-literal=LEAD_FORM_PUBLIC_ID=$LEAD_FORM_PUBLIC_ID diff --git a/kustomize/review/deployment-patch.yaml b/kustomize/review/deployment-patch.yaml deleted file mode 100644 index d1114098..00000000 --- a/kustomize/review/deployment-patch.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# We are patching the initContainers to also import our example_data on each deployment -- op: add - path: "/spec/template/spec/initContainers/-" - value: - name: load-example-data - image: registry.gitlab.alt.coop/wahlkampf-app/wk-service - command: [ 'sh', '-c', 'python manage.py loaddata core/fixtures/example_data.json || true' ] - envFrom: - - configMapRef: - name: application-config - - secretRef: - name: application-secrets -# only one replica necessary for a review deployment -- op: replace - path: "/spec/replicas" - value: 1 diff --git a/kustomize/review/ingress-override.template.yaml b/kustomize/review/ingress-override.template.yaml deleted file mode 100644 index 1df404e9..00000000 --- a/kustomize/review/ingress-override.template.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: wkservice-ingress -spec: - tls: - - hosts: - - $INGRESS_HOST # Variable for dynamically created ingress hostname - secretName: tls-secrets - rules: - - host: $INGRESS_HOST # Variable for dynamically created ingress hostname - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: wkservice - port: - number: 8000 diff --git a/kustomize/review/kustomization.yaml b/kustomize/review/kustomization.yaml deleted file mode 100644 index b83aaf4e..00000000 --- a/kustomize/review/kustomization.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - - - -resources: -- postgres.yaml -- pvc.yaml -- ../base - -patches: -- path: deployment-patch.yaml - target: - group: apps - kind: Deployment - name: wkservice - version: v1 -- path: ingress-override.yaml diff --git a/kustomize/review/postgres.yaml b/kustomize/review/postgres.yaml deleted file mode 100644 index 9f323b3c..00000000 --- a/kustomize/review/postgres.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: postgres - labels: - app: postgres -spec: - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - app: postgres - template: - metadata: - labels: - app: postgres - spec: - containers: - - name: postgres - image: postgis/postgis:13-3.1-alpine - ports: - - containerPort: 5432 - volumeMounts: - - mountPath: /var/lib/postgresql/data - name: postgres-pv-claim - subPath: data - env: - - name: POSTGRES_USER - valueFrom: - configMapKeyRef: - name: application-config - key: DB_USER - - name: POSTGRES_DB - valueFrom: - configMapKeyRef: - name: application-config - key: DB_NAME - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: application-secrets - key: DB_PASSWORD - volumes: - - name: postgres-pv-claim - persistentVolumeClaim: - claimName: postgres-pv-claim ---- -apiVersion: v1 -kind: Service -metadata: - name: postgres -spec: - selector: - app: postgres - ports: - - protocol: TCP - port: 5432 diff --git a/kustomize/review/pvc.yaml b/kustomize/review/pvc.yaml deleted file mode 100644 index 0775a0fd..00000000 --- a/kustomize/review/pvc.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - labels: - app: postgres - name: postgres-pv-claim -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 10G diff --git a/kustomize/staging/ingress-override.yaml b/kustomize/staging/ingress-override.yaml deleted file mode 100644 index 81a6bfd9..00000000 --- a/kustomize/staging/ingress-override.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: wkservice-ingress -spec: - tls: - - hosts: - - staging.wk-service.haze.alt.coop - secretName: tls-secrets - rules: - - host: staging.wk-service.haze.alt.coop - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: wkservice - port: - number: 8000 diff --git a/kustomize/staging/kustomization.yaml b/kustomize/staging/kustomization.yaml deleted file mode 100644 index 7a065351..00000000 --- a/kustomize/staging/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -bases: -- ../base - -patchesStrategicMerge: -- ingress-override.yaml -- GitLab From cddd26efaf8e07702efa5a83e84c704b3c346dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Wed, 13 Mar 2024 16:39:28 +0100 Subject: [PATCH 21/22] Ignore gilab-ci-local files --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca1a20db..d051c7be 100644 --- a/.gitignore +++ b/.gitignore @@ -170,4 +170,8 @@ requirements.txt .initial_setup.lock # Ignore test report output -report.xml \ No newline at end of file +report.xml + +# Ignore gitlab-ci-local files +.gitlab-ci-local +.gitlab-ci-local-variables.yml \ No newline at end of file -- GitLab From 9a595e773e720e604f5c64ae3835b98317bd06d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=BCmpel?= <peter@ctrl.alt.coop> Date: Mon, 8 Apr 2024 14:11:03 +0200 Subject: [PATCH 22/22] Remove deprecated osm host address --- wk_app/settings/local.py.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wk_app/settings/local.py.dist b/wk_app/settings/local.py.dist index bf90ec9b..23dc9822 100644 --- a/wk_app/settings/local.py.dist +++ b/wk_app/settings/local.py.dist @@ -5,7 +5,7 @@ DATABASES['osm'] = { # noqa: F405 'NAME': 'osm', 'USER': 'osm', 'PASSWORD': '[redacted]', - 'HOST': 'psql-ger-1.osm.alt.coop', + 'HOST': '[redacted]', 'PORT': '5432', } -- GitLab