Skip to content

Commit

Permalink
Merge pull request #1933 from vacanza/dev
Browse files Browse the repository at this point in the history
v0.55
  • Loading branch information
arkid15r authored Aug 19, 2024
2 parents 0ba2fd9 + 37c356e commit c1ef720
Show file tree
Hide file tree
Showing 34 changed files with 2,003 additions and 197 deletions.
60 changes: 53 additions & 7 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check out Repository
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
Expand All @@ -33,6 +33,27 @@ jobs:
- name: Run pre-commit
uses: pre-commit/[email protected]

code-ql:
name: CodeQL
needs:
- pre-commit
permissions:
security-events: write
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: python

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: '/language:python'

test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -51,7 +72,8 @@ jobs:
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand Down Expand Up @@ -84,7 +106,8 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -111,6 +134,22 @@ jobs:
name: dist
path: dist

- name: Set version
if: startsWith(github.event.ref, 'refs/tags/v')
run: echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_ENV

- name: Generate SBOM
if: startsWith(github.event.ref, 'refs/tags/v')
run: |
make sbom > holidays-$VERSION-sbom.json
- name: Upload SBOM
if: startsWith(github.event.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: sbom
path: holidays-$VERSION-sbom.json

test-build:
name: Test build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -122,7 +161,7 @@ jobs:
- ubuntu-latest
- windows-latest
steps:
- name: Check out Repository
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
Expand Down Expand Up @@ -157,7 +196,7 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout Repository
- name: Check out repository
uses: actions/checkout@v4

- name: Set Up Python
Expand All @@ -167,7 +206,7 @@ jobs:
cache-dependency-path: requirements/docs.txt
python-version: '3.12'

- name: Install Dependencies
- name: Install dependencies
run: |
python -m pip install --requirement requirements/docs.txt
python -m pip install .
Expand All @@ -187,6 +226,7 @@ jobs:
- test-build
- test-docs
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
Expand All @@ -199,8 +239,14 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Download SBOM
uses: actions/download-artifact@v4
with:
name: sbom

- name: Update Github release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} dist/*
gh release upload --repo vacanza/python-holidays ${{ github.ref_name }} dist/*
gh release upload --repo vacanza/python-holidays ${{ github.ref_name }} holidays-*-sbom.json
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pip install pre-commit
- name: Use pre-commit environment cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ holidays/locale/pot/*.pot
!holidays/locale/pot/UA.pot
MANIFEST
Pipfile
sbom.json
venv/
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- rst

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.1
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -34,6 +34,13 @@ repos:
- --license-filepath
- docs/file_header.txt

- repo: https://github.com/pycqa/bandit
rev: 1.7.9
hooks:
- id: bandit
args:
- --configfile=pyproject.toml

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand Down
17 changes: 17 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
Version 0.55
============

Released August 19, 2024

- Add Samoa holidays (#1914 by @kasya)
- Fix misleading France subdivision (#1931 by @MichaelMure)
- Update CI/CD: add CodeQL workflow (#1910 by @arkid15r)
- Update CI/CD: simplify gh release upload (#1924 by @arkid15r)
- Update Github release upload process (#1902 by @arkid15r)
- Update SG: add 2025 official holidays (#1903 by @mborsetti, @arkid15r)
- Update UA: move martial law holidays to WORKDAY category (#1921 by @KJhellico)
- Update pre-commit: add bandit (#1913 by @arkid15r)
- Update utils.py (#1908 by @JohnRoz, @arkid15r)
- Add special weekends format for certain countries (#1923 by @PPsyrius, @arkid15r)
- Implement simple CycloneDX SBOM generation (#1925 by @arkid15r)

Version 0.54
============

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ package:
pre-commit:
pre-commit run --all-files

sbom:
@python -m cyclonedx_py requirements requirements/runtime.txt

setup:
pip install --upgrade pip
pip install --requirement requirements/dev.txt
Expand Down
11 changes: 8 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Available Countries
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 149 country codes. The standard way to refer to a country
We currently support 150 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. Some countries have common or foreign
names or abbreviations as aliases for their subdivisions. These are defined in
Expand Down Expand Up @@ -427,7 +427,7 @@ All other default values are highlighted with bold:
- UNOFFICIAL
* - France
- FR
- Départements: BL, GES, GP, GY, MF, MQ, NC, PF, RE, WF, YT
- DOM/TOM: BL, GES, GP, GY, MF, MQ, NC, PF, RE, WF, YT
- en_US, **fr**, uk
-
* - Gabon
Expand Down Expand Up @@ -760,6 +760,11 @@ All other default values are highlighted with bold:
-
- en_US, **ru**
-
* - Samoa
- WS
-
-
-
* - San Marino
- SM
-
Expand Down Expand Up @@ -859,7 +864,7 @@ All other default values are highlighted with bold:
- UA
-
- ar, en_US, **uk**
-
- WORKDAY
* - United Arab Emirates
- AE
-
Expand Down
2 changes: 1 addition & 1 deletion holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from holidays.registry import EntityLoader
from holidays.utils import *

__version__ = "0.54"
__version__ = "0.55"


EntityLoader.load("countries", globals())
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
from .puerto_rico import PuertoRico, PR, PRI, HolidaysPR
from .romania import Romania, RO, ROU
from .russia import Russia, RU, RUS
from .samoa import Samoa, WS, WSM
from .san_marino import SanMarino, SM, SMR
from .saudi_arabia import SaudiArabia, SA, SAU
from .serbia import Serbia, RS, SRB
Expand Down
11 changes: 11 additions & 0 deletions holidays/countries/algeria.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import THU, FRI, SAT, SUN
from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.holiday_base import HolidayBase

Expand All @@ -38,6 +39,16 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
# The resting days are Friday and Saturday since 2009.
# Previously, these were on Thursday and Friday as implemented in 1976.
# https://www.thenationalnews.com/mena/2021/12/07/when-is-the-weekend-in-the-arab-world/
if self._year >= 2009:
self.weekend = {FRI, SAT}
elif self._year >= 1976:
self.weekend = {THU, FRI}
else:
self.weekend = {SAT, SUN}

# New Year's Day.
self._add_new_years_day(tr("رأس السنة الميلادية"))

Expand Down
2 changes: 2 additions & 0 deletions holidays/countries/bangladesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import FRI, SAT
from holidays.groups import InternationalHolidays
from holidays.holiday_base import HolidayBase

Expand All @@ -22,6 +23,7 @@ class Bangladesh(HolidayBase, InternationalHolidays):
"""

country = "BD"
weekend = {FRI, SAT}

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
Expand Down
18 changes: 17 additions & 1 deletion holidays/countries/brunei.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@
from gettext import gettext as tr

from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import (
JAN,
FEB,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
FRI,
SUN,
)
from holidays.groups import (
ChineseCalendarHolidays,
ChristianHolidays,
Expand Down Expand Up @@ -75,6 +90,7 @@ class Brunei(
# %s (observed, estimated).
observed_estimated_label = tr("%s (diperhatikan, anggaran)")
supported_languages = ("en_US", "ms", "th")
weekend = {FRI, SUN}

def __init__(self, *args, **kwargs):
ChineseCalendarHolidays.__init__(self)
Expand Down
2 changes: 2 additions & 0 deletions holidays/countries/egypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import FRI, SAT
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.groups import ChristianHolidays, IslamicHolidays, InternationalHolidays
from holidays.holiday_base import HolidayBase
Expand All @@ -32,6 +33,7 @@ class Egypt(HolidayBase, ChristianHolidays, IslamicHolidays, InternationalHolida
# %s (estimated).
estimated_label = tr("(تقدير) %s")
supported_languages = ("ar", "en_US")
weekend = {FRI, SAT}

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self, JULIAN_CALENDAR)
Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/israel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from gettext import gettext as tr

from holidays.calendars import _HebrewLunisolar
from holidays.calendars.gregorian import _timedelta
from holidays.calendars.gregorian import _timedelta, FRI, SAT
from holidays.calendars.hebrew import (
HANUKKAH,
INDEPENDENCE_DAY,
Expand Down Expand Up @@ -53,6 +53,7 @@ class Israel(ObservedHolidayBase):
observed_label = tr("(נצפה) %s")
supported_categories = (OPTIONAL, PUBLIC, SCHOOL)
supported_languages = ("en_US", "he", "uk")
weekend = {FRI, SAT}

def __init__(self, *args, **kwargs):
kwargs.setdefault("observed_rule", FRI_TO_PREV_THU + SAT_TO_PREV_THU)
Expand Down
5 changes: 5 additions & 0 deletions holidays/countries/jordan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import THU, FRI, SAT
from holidays.groups import ChristianHolidays, InternationalHolidays, IslamicHolidays
from holidays.holiday_base import HolidayBase

Expand All @@ -36,6 +37,10 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
# The resting days are Friday and Saturday since Jan 6, 2000.
# https://archive.wfn.org/2000/01/msg00078.html
self.weekend = {FRI, SAT} if self._year >= 2000 else {THU, FRI}

# New Year's Day.
self._add_new_years_day(tr("رأس السنة الميلادية"))

Expand Down
5 changes: 5 additions & 0 deletions holidays/countries/kuwait.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import THU, FRI, SAT
from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.holiday_base import HolidayBase

Expand All @@ -36,6 +37,10 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
# The resting days are Friday and Saturday since Sep 1, 2007.
# https://www.arabnews.com/node/298933
self.weekend = {FRI, SAT} if self._year >= 2007 else {THU, FRI}

# New Year's Day.
self._add_new_years_day(tr("رأس السنة الميلادية"))

Expand Down
Loading

0 comments on commit c1ef720

Please sign in to comment.