Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icalendar 5.0 support and test against 5.0 and 6.x #160

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor Author

@DerDreschner DerDreschner Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended by the setup-python action to set it to read. According to the GitHub documentation, the default would be none, which means that the whole action has no read permission to the content of the repository. I know it works without it for now, but well, if they they say it may not work, I introduced it here to be sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know. thanks for pointing this out


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a huge fan of extra deps in the build steps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhm, yeah, I understand. But it's more readable in my opinion and when you look at the code of the action, it doesn't do a lot different then the code before. Main difference is the encapsulation of poetry from the global python environment inside the docker container by using pipx instead of pip.

If you feel better about it, I can revert the changes. But I would keep the separation in two build steps (install poetry itself - install the project dependencies).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do that, than we can merge and publish

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! :-)

- 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
Loading