From 1ab9e0cf24f777a41174369e9db35dfe35079e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 9 Dec 2023 04:06:08 +0100 Subject: [PATCH 1/4] run chores on master branch --- deploy/chores/check_version | 9 +++++++++ deploy/chores/docker_buildx | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/deploy/chores/check_version b/deploy/chores/check_version index 817039d..8d150c0 100755 --- a/deploy/chores/check_version +++ b/deploy/chores/check_version @@ -7,6 +7,8 @@ script_dir="$( dirname "${script}" )" && git_status="developing" git rev-parse --abbrev-ref HEAD | grep -E 'release|hotfix/' >/dev/null \ && git_status="releasing" +git rev-parse --abbrev-ref HEAD | grep -E 'master' >/dev/null \ + && git_status="released" if [ "${git_status}" = "developing" ]; then @@ -23,6 +25,13 @@ elif [ "${git_status}" = "releasing" ]; then git rev-parse --abbrev-ref HEAD \ | cut -d '/' -f 2 )" +elif [ "${git_status}" = "released" ]; then + echo "Status: Released" + # => version from current tag + git_version="$( \ + git describe --tags \ + | sed -E 's/^v[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9])$/\1/' + )" else echo "ERROR: Invalid git branch" echo "ERROR: Chores cannot be run on '$( git rev-parse --abbrev-ref HEAD )'!" diff --git a/deploy/chores/docker_buildx b/deploy/chores/docker_buildx index f5ade1a..0249229 100755 --- a/deploy/chores/docker_buildx +++ b/deploy/chores/docker_buildx @@ -8,7 +8,7 @@ script_dir="$( dirname "${script}" )" # vars defined in `check_version` script # shellcheck disable=SC2154 -if [ "${git_status}" = "releasing" ]; then +if [ "${git_status}" = "releasing" ] || [ "${git_status}" = "released" ]; then # shellcheck disable=SC2154 image_tag="${git_version}" else From f3929438bda95b53eb77fb4493167c1f072a4690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 24 Apr 2024 15:49:34 +0200 Subject: [PATCH 2/4] fix: make all `datetime`s timezone-aware --- api/ovdashboard_api/core/calevent.py | 21 +++++++++++++++++---- api/ovdashboard_api/core/dav/caldav.py | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/api/ovdashboard_api/core/calevent.py b/api/ovdashboard_api/core/calevent.py index c22bbca..aa523e1 100644 --- a/api/ovdashboard_api/core/calevent.py +++ b/api/ovdashboard_api/core/calevent.py @@ -6,16 +6,26 @@ Caches events using `timed_alru_cache`. import functools import logging -from datetime import datetime +from datetime import UTC, datetime from typing import Annotated, Self -from pydantic import BaseModel, ConfigDict, StringConstraints +from pydantic import AfterValidator, BaseModel, ConfigDict, StringConstraints from vobject.base import Component _logger = logging.getLogger(__name__) type StrippedStr = Annotated[str, StringConstraints(strip_whitespace=True)] +def make_utc(v: datetime) -> datetime: + if v.tzinfo is None: + return v.replace(tzinfo=UTC) + + return v + + +type UTCDateTime = Annotated[datetime, AfterValidator(make_utc)] + + @functools.total_ordering class CalEvent(BaseModel): """ @@ -31,8 +41,8 @@ class CalEvent(BaseModel): summary: StrippedStr = "" description: StrippedStr = "" - dtstart: datetime = datetime.now() - dtend: datetime = datetime.now() + dtstart: UTCDateTime = datetime.now(UTC) + dtend: UTCDateTime = datetime.now(UTC) def __lt__(self, other: Self) -> bool: """ @@ -64,6 +74,9 @@ class CalEvent(BaseModel): except KeyError: pass + print(event) + print(data) + if "dtend" not in data: data["dtend"] = data["dtstart"] diff --git a/api/ovdashboard_api/core/dav/caldav.py b/api/ovdashboard_api/core/dav/caldav.py index 3a0acb7..8ac5108 100644 --- a/api/ovdashboard_api/core/dav/caldav.py +++ b/api/ovdashboard_api/core/dav/caldav.py @@ -1,5 +1,5 @@ import logging -from datetime import datetime, timedelta +from datetime import UTC, datetime, timedelta from typing import cast from asyncify import asyncify @@ -69,7 +69,7 @@ class CalDAV: _logger.info(f"downloading {calendar_name!r} ...") dt_start = datetime.combine( - datetime.now().date(), + datetime.now(UTC).date(), datetime.min.time(), ) dt_end = dt_start + timedelta(days=cfg.calendar.future_days) From 731aef52e71570ef275dfffd8c3cd822306a43b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 24 Apr 2024 15:57:01 +0200 Subject: [PATCH 3/4] version bump --- api/pyproject.toml | 4 ++-- deploy/docker-compose.yml | 2 +- deploy/install.sh | 2 +- ui/package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/pyproject.toml b/api/pyproject.toml index d1381c3..eec1a63 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -3,7 +3,7 @@ authors = ["Jörn-Michael Miehe "] description = "" include = ["ovdashboard_api/skel/*"] name = "ovdashboard_api" -version = "0.2.0" +version = "0.2.1" [tool.poetry.dependencies] Markdown = "^3.5.1" @@ -25,8 +25,8 @@ webdavclient3 = "^3.14.6" black = "^23.11.0" flake8 = "^6.1.0" flake8-isort = "^6.1.1" -types-cachetools = "^5.3.0.7" pytest = "^7.4.3" +types-cachetools = "^5.3.0.7" [tool.poetry.scripts] ovdashboard-api = "ovdashboard_api.main:main" diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 808f819..f24f864 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -11,7 +11,7 @@ services: - "127.0.0.1:6379:6379" app: - image: code.yavook.de/oekzident.de/ovdashboard:0.2.0 + image: code.yavook.de/oekzident.de/ovdashboard:0.2.1 restart: always pull_policy: always depends_on: diff --git a/deploy/install.sh b/deploy/install.sh index 0250a6d..32e3562 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -5,7 +5,7 @@ ######### # env setup -ovd_version="0.2.0" +ovd_version="0.2.1" export DEBIAN_FRONTEND="noninteractive" set -e diff --git a/ui/package.json b/ui/package.json index 24a6284..acca596 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ovdashboard-ui", - "version": "0.2.0", + "version": "0.2.1", "private": true, "scripts": { "serve": "vue-cli-service serve", From b69e2024da2ccf049c17d506f3356acc1410a33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Wed, 24 Apr 2024 16:02:30 +0200 Subject: [PATCH 4/4] fix f3929438bda95b53eb77fb4493167c1f072a4690 remove print() --- api/ovdashboard_api/core/calevent.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/api/ovdashboard_api/core/calevent.py b/api/ovdashboard_api/core/calevent.py index aa523e1..b3844db 100644 --- a/api/ovdashboard_api/core/calevent.py +++ b/api/ovdashboard_api/core/calevent.py @@ -74,9 +74,6 @@ class CalEvent(BaseModel): except KeyError: pass - print(event) - print(data) - if "dtend" not in data: data["dtend"] = data["dtstart"]