From a5f61cd3107c7a675fe069d4037da61f25e49bbd Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 17:41:16 +0100 Subject: [PATCH 01/16] feature: Workaround to suppor both icalendar 5.0 and >= 6.0 --- icalevents/icalparser.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 55a8857..85a3732 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -2,26 +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(): """ From d930010f76b7ec3d36dfbedd12c0e4a972550e51 Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 17:44:09 +0100 Subject: [PATCH 02/16] chore: Add test matrix for different icalendar versions and general pipeline improvements --- .github/workflows/tests.yml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c512e49..685d91e 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,38 @@ on: pull_request: branches: [master] +permissions: + contents: read + jobs: - build: + tests: runs-on: ubuntu-latest + strategy: + matrix: + icalendar-version: + - "5.0" + - "6.0" + - "6.1" steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: "Set up Python 3.9" uses: actions/setup-python@v5 with: python-version: '3.9' - - name: Install dependencies + - name: "Install poetry" + uses: abatilo/actions-poetry@v3 + with: + poetry-version: 2.0.1 + - name: "Install 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 + poetry install --no-interaction --no-root + - 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 From 7b7f43f75fc72800bb7819eca538dee56a17408c Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 17:54:46 +0100 Subject: [PATCH 03/16] chore: Use the same actions for test and release pipeline and minor pipeline improvements --- .github/workflows/release.yml | 20 ++++++++++++-------- .github/workflows/tests.yml | 12 +++++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b241d7d..96df083 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' - - 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 685d91e..2696e81 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,23 +20,29 @@ jobs: - "6.1" steps: - - uses: actions/checkout@v4 + - name: "Checkout repository" + uses: actions/checkout@v4 + - name: "Set up Python 3.9" uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: "3.9" + - name: "Install poetry" uses: abatilo/actions-poetry@v3 with: poetry-version: 2.0.1 - - name: "Install dependencies" + + - name: "Install icalendar ${{ matrix.icalendar-version }} and other dependencies" run: | poetry add icalendar~=${{ matrix.icalendar-version }}.0 --no-interaction poetry install --no-interaction --no-root + - name: "Test with pytest" run: | poetry run coverage run test.py poetry run coverage xml + - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v5 with: From 1a394d6b7b7a9a31fe7299a3362678e0910b0b53 Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 17:55:15 +0100 Subject: [PATCH 04/16] feature: Set minimal icalendar version to 5.0.0 --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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)", From 2aa3170208fc2a68cebc2e7c7b8c373c7a67e39e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:04:06 +0000 Subject: [PATCH 05/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- icalevents/icalparser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/icalevents/icalparser.py b/icalevents/icalparser.py index 85a3732..98289d3 100644 --- a/icalevents/icalparser.py +++ b/icalevents/icalparser.py @@ -22,6 +22,7 @@ else: from icalendar.windows_to_olson import WINDOWS_TO_OLSON + def now(): """ Get current time. From a8baa3c876d90a890fc588db4afb56a5b48c275b Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 18:14:02 +0100 Subject: [PATCH 06/16] chore: Remove 'poetry install' as it seems to be already done by 'poetry add' --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2696e81..2df12f9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,6 @@ jobs: - name: "Install icalendar ${{ matrix.icalendar-version }} and other dependencies" run: | poetry add icalendar~=${{ matrix.icalendar-version }}.0 --no-interaction - poetry install --no-interaction --no-root - name: "Test with pytest" run: | From 2c1ff496a4611893ff7428eb119a180ff858132d Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 18:20:13 +0100 Subject: [PATCH 07/16] chore: Don't rename tests build --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2df12f9..edf2a3c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ permissions: contents: read jobs: - tests: + build: runs-on: ubuntu-latest strategy: matrix: From 53cd92d43640c60bf9d5655fd6bb35d364116b2a Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 18:42:00 +0100 Subject: [PATCH 08/16] chore: Fix broken build info in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 6dd957bd027e3579b137cf7bf0350e12079df173 Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 19:16:51 +0100 Subject: [PATCH 09/16] chore: Add hint to change after_n_builds on codecov after touching the test matrix --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index edf2a3c..7c42fc6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + # When changing this matrix, you _must_ also change some settings + # on codecov. 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.0" - "6.0" From 58c94c9f1faaa73e63b6e73f259cf97d56e12b5d Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 19:28:28 +0100 Subject: [PATCH 10/16] chore: Make sure poetry version is string --- .github/workflows/release.yml | 4 ++-- .github/workflows/tests.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96df083..cd0a2c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,12 @@ jobs: - name: "Set up latest Python 3 version" uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: "3.x" - name: "Install poetry" uses: abatilo/actions-poetry@v3 with: - poetry-version: 2.0.1 + poetry-version: "2.0.12" - name: "Build package" run: poetry build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c42fc6..af7a1cc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: - name: "Install poetry" uses: abatilo/actions-poetry@v3 with: - poetry-version: 2.0.1 + poetry-version: "2.0.1" - name: "Install icalendar ${{ matrix.icalendar-version }} and other dependencies" run: | From 36fbf2dfce803d261b58ef6a9f4eddc54d0c7f3d Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Sun, 19 Jan 2025 19:31:57 +0100 Subject: [PATCH 11/16] chore: Fix little typo in release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd0a2c5..d91228c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: - name: "Install poetry" uses: abatilo/actions-poetry@v3 with: - poetry-version: "2.0.12" + poetry-version: "2.0.1" - name: "Build package" run: poetry build From 7972192db79e961127f65212d356a7eee10371ad Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Fri, 24 Jan 2025 19:55:00 +0100 Subject: [PATCH 12/16] chore: Include more specific informations after_n_builds on codecov and only test against 5.x and 6.x --- .github/workflows/tests.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index af7a1cc..bf1bd9f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,14 +14,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # When changing this matrix, you _must_ also change some settings - # on codecov. See the following links for more information: + # When changing this matrix, the project lead (currently @eigenmannmartin) + # must change the "after_n_builds" parameter on codecov. 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.0" - - "6.0" - - "6.1" + - "5" # means (>=5.0.0,<6.0.0) + - "6" # means (>=6.0.0,<7.0.0) steps: - name: "Checkout repository" From e02456c3f8116bd2727b88aea9378376adf052cf Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Fri, 24 Jan 2025 20:45:39 +0100 Subject: [PATCH 13/16] chore: Introduce codecov.yml to change after_n_builds --- .github/codecov.yml | 5 +++++ .github/workflows/tests.yml | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..31b2c88 --- /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 \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bf1bd9f..b624d0e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # When changing this matrix, the project lead (currently @eigenmannmartin) - # must change the "after_n_builds" parameter on codecov. It must match - # the number of builds being started considering the matrix. + # When changing this matrix, you have to change the "after_n_builds" + # 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 From ca32b6099c7c929785631f291c20b394c99ac2aa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:45:48 +0000 Subject: [PATCH 14/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 31b2c88..f270f3c 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -2,4 +2,4 @@ codecov: notify: - after_n_builds: 2 \ No newline at end of file + after_n_builds: 2 From 8fc12683848144e01e39921d36fd2ad7b8abc237 Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Fri, 24 Jan 2025 20:48:28 +0100 Subject: [PATCH 15/16] chore: Remove parameters from codecov-action as it matches default anyway --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b624d0e..ae6e1d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,5 +49,3 @@ jobs: - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v5 - with: - fail_ci_if_error: false From 249e22b29a0b55c20baaa48d19d35fcbaeea0833 Mon Sep 17 00:00:00 2001 From: David Dreschner Date: Fri, 24 Jan 2025 20:57:44 +0100 Subject: [PATCH 16/16] chore: Fix little typo in tests.yml --- .github/workflows/tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ae6e1d8..2db91a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,10 +14,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # When changing this matrix, you have to change the "after_n_builds" - # 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: + # 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: