Skip to content

Commit

Permalink
Merge pull request #160 from DerDreschner/feature/icalendar-5-support
Browse files Browse the repository at this point in the history
Add icalendar 5.0 support and test against 5.0 and 6.x
  • Loading branch information
eigenmannmartin authored Feb 17, 2025
2 parents 301bde0 + 249e22b commit d7c4a2a
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# To validate this file on changes before committing, see https://api.codecov.io/validate

codecov:
notify:
after_n_builds: 2
22 changes: 13 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 30 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit d7c4a2a

Please sign in to comment.