diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..f270f3c --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,5 @@ +# To validate this file on changes before committing, see https://api.codecov.io/validate + +codecov: + notify: + after_n_builds: 2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b241d7d..d91228c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,30 +5,34 @@ on: tags: - '*' +permissions: + contents: read + jobs: deploy: if: github.repository == 'jazzband/icalevents' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: "Checkout repository with all history for all branches and tags" + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python + - name: "Set up latest Python 3 version" uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install poetry==2.0.1 + - name: "Install poetry" + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "2.0.1" - - name: Build package + - name: "Build package" run: poetry build - - name: Upload packages to Jazzband + - name: "Upload packages to Jazzband" if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c512e49..2db91a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Run pytest on: @@ -9,26 +6,45 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + # When changing this matrix, you have to change the "after_n_builds" parameter + # in the .github/codecov.yml file. It must match the number of builds being + # started considering the matrix. See the following links for more information: + # https://docs.codecov.com/docs/notifications#preventing-notifications-until-after-n-builds + # https://docs.codecov.com/docs/pull-request-comments#after_n_builds + icalendar-version: + - "5" # means (>=5.0.0,<6.0.0) + - "6" # means (>=6.0.0,<7.0.0) steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Set up Python 3.9" uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Install dependencies + python-version: "3.9" + + - name: "Install poetry" + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "2.0.1" + + - name: "Install icalendar ${{ matrix.icalendar-version }} and other dependencies" run: | - python -m pip install --upgrade pip - pip install poetry==2.0.1 - poetry install - - name: Test with pytest + poetry add icalendar~=${{ matrix.icalendar-version }}.0 --no-interaction + + - name: "Test with pytest" run: | poetry run coverage run test.py poetry run coverage xml - - name: 'Upload coverage to Codecov' + + - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v5 - with: - fail_ci_if_error: false diff --git a/README.md b/README.md index e717e9f..0b028fd 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Simple Python 3 library to download, parse and query iCal sources. ## Build info -last push: ![run pytest](https://github.com/jazzband/icalevents/actions/workflows/python-test.yml/badge.svg) +last push: [![Run pytest](https://github.com/jazzband/icalevents/actions/workflows/tests.yml/badge.svg)](https://github.com/jazzband/icalevents/actions/workflows/tests.yml) -master: [![Run pytest](https://github.com/jazzband/icalevents/actions/workflows/python-test.yml/badge.svg?branch=master)](https://github.com/jazzband/icalevents/actions/workflows/python-test.yml) +master: [![Run pytest](https://github.com/jazzband/icalevents/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/jazzband/icalevents/actions/workflows/tests.yml?query=branch%3Amaster++) ## Documentation diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 55a8857..98289d3 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -2,25 +2,25 @@ Parse iCal data to Events. """ -# for UID generation -from faulthandler import is_enabled +from datetime import datetime, timedelta, date +from importlib.metadata import version from random import randint -from datetime import datetime, timedelta, date, tzinfo from typing import Optional +from uuid import uuid4 from dateutil.rrule import rrulestr from dateutil.tz import UTC, gettz - from icalendar import Calendar from icalendar.prop import vDDDLists, vText -from uuid import uuid4 - -from icalendar import use_pytz -from icalendar.timezone.windows_to_olson import WINDOWS_TO_OLSON from pytz import timezone +if version("icalendar") >= "6.0": + from icalendar import use_pytz + from icalendar.timezone.windows_to_olson import WINDOWS_TO_OLSON -use_pytz() + use_pytz() +else: + from icalendar.windows_to_olson import WINDOWS_TO_OLSON def now(): diff --git a/poetry.lock b/poetry.lock index 90bb93b..3e6a4a1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -221,14 +221,14 @@ six = ">=1.8.0" [[package]] name = "icalendar" -version = "6.1.0" +version = "6.1.1" description = "iCalendar parser/generator" optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "icalendar-6.1.0-py3-none-any.whl", hash = "sha256:46c09b774a6e6948495dafcb166dc15135c8259d0ae25491f154cbc822714b69"}, - {file = "icalendar-6.1.0.tar.gz", hash = "sha256:43c2db8632959d634f4e48f6e6131e706bf2cdddad488cf0b72fda079b796bad"}, + {file = "icalendar-6.1.1-py3-none-any.whl", hash = "sha256:accf3a4be9a1f89bad00e0bf14103b02cd9b02dcb9b4258eb717f39d24cf58e9"}, + {file = "icalendar-6.1.1.tar.gz", hash = "sha256:2c44355a8f006de5ae73fa3f022a1cbe2a0de6b1607ce8879739eb887c4f3471"}, ] [package.dependencies] @@ -717,4 +717,4 @@ files = [ [metadata] lock-version = "2.1" python-versions = ">=3.9" -content-hash = "8fc64de4f55b234589828215b2dca5a673f1772127f00a7eb4708a634ed109a4" +content-hash = "21197e64a2880ca0c132fb21c5fc84e6096b4586e5cfc41a31a44eebd08fe237" diff --git a/pyproject.toml b/pyproject.toml index a08d5c4..f819353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ license = "MIT" requires-python = ">=3.9" dependencies = [ - "icalendar (~=6.0)", + "icalendar (>=5.0.0)", "python-dateutil (~=2.9)", "pytz (>=2024.2)", "urllib3 (>=1.26.5)",