From 1edbf6ad8be130a067016268c98b0eb2484cedc8 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 11 Aug 2024 11:58:59 +0200 Subject: [PATCH] Improve CI --- .github/workflows/tests.yml | 57 ++++++++++++++++++++++++- src/commons_codec/transform/function.py | 2 +- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 010c4c5..0cd813c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -104,7 +104,7 @@ jobs: pip install "setuptools>=64" --upgrade # Install package in editable mode. - pip install --use-pep517 --prefer-binary --editable=.[all,develop,test] + pip install --use-pep517 --prefer-binary --editable=.[mongodb,develop,test] - name: Run linters and software tests run: poe check @@ -120,3 +120,58 @@ jobs: env_vars: OS,PYTHON name: codecov-umbrella fail_ci_if_error: true + + + test-zyp: + name: " + Zyp: Python ${{ matrix.python-version }} + " + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest'] + python-version: ['3.8', '3.12'] + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + + steps: + + - name: Acquire sources + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + cache: 'pip' + cache-dependency-path: + pyproject.toml + + - name: Set up project + run: | + + # `setuptools 0.64.0` adds support for editable install hooks (PEP 660). + # https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6400 + pip install "setuptools>=64" --upgrade + + # Install package in editable mode. + pip install --use-pep517 --prefer-binary --editable=.[zyp,develop,test] + + - name: Run linters and software tests + run: poe check + + # https://github.com/codecov/codecov-action + - name: Upload coverage results to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: ./coverage.xml + flags: zyp + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: true diff --git a/src/commons_codec/transform/function.py b/src/commons_codec/transform/function.py index bc87923..093f29c 100644 --- a/src/commons_codec/transform/function.py +++ b/src/commons_codec/transform/function.py @@ -2,7 +2,6 @@ import logging import typing as t -import dateutil.parser logger = logging.getLogger(__name__) @@ -10,6 +9,7 @@ def to_datetime(value: t.Any, on_error: t.Literal["raise", "ignore"] = "ignore") -> t.Union[dt.datetime, None]: if isinstance(value, dt.datetime): return value + import dateutil.parser try: return dateutil.parser.parse(value) except (TypeError, dateutil.parser.ParserError) as ex: