Skip to content

Commit d65a8eb

Browse files
dr-prodigys-weigand
andcommitted
GH action CI/CD integration - #404 #443
(massive thx+kudos to s-weigand) * added coverage.xml to .gitignore * Basic rewrite of the travis tests, with github actions * removed now obsolete travis config * Added bump2version and its config * moved flake8 config to setup.cfg * Formatted requirements with comments * Created test file for each country and moved corresponding tests there * Added pre-commit and a basic config containing black+its config * Added flake8 to pre-commit config and set flake8 to ignore E203 E203 needs to be ignore due to a false positive alert for slicing. See. PyCQA/pycodestyle#373 (comment) * Replaced flake8 tests with pre-commit ones, since flake8 is included * Updated workflow to use tests folder, upload coverage to coveralls.io and some minor fixes * Added pre-commit hook that adds encoding shebang to all files py27 compat * Added coverage config * Added tox+pytest config and added .tox to .gitignore * Added rst checking tools to pre-commit and fixed rst issues * Added workflow dispatch as an option to run the workflow * Removed py35 as was done in https://github.com/dr-prodigy/python-holidays/pull/402 * Added dependabot config to receive automatics update PR's for python runtime dependencies and used github-actions * Fixed pytest config quoting the addopts made them not being recognized properly * Replaced travis with github actions badge * Changed contributing guide to reflect changed tooling * Formatted setup.py again with black * Auto-format, Israel to_jd_gregorianyear fix * requirements_dev.txt review, Israel fixes, CHANGES+README.rst reviews * precommit tasks run * removed python 2.7 checks from github CI/CD scripts * flake8 config fixes * travis build toml dependency fix * removed duplicated flake8 tests from coverage config * old tests.py using new test classes * tests tree reviewed * tests cleanup (warn: coverage report -m needs fixing) * Fixed usage of coveralls with gh-action after 3.0.0 release * more recent tests re-applied - #404 * copyright 2021 * test tree refactoring, pytest running thru tests.py * Flake8 test removed, pyproject.toml cleanup * Added .gitaddtributes file to ensure consistent '\n' line ending for future commits * Added pre-commit hook to enforce '\n' lineending and applied it on all files * Copied files from 'holiday' and 'tests' over and ran 'pre-commit run -a' This should catch all changes on beta which were missing. I left changes which were added in the cleanup of 'unstable' e.g. 'holidays.utils.is_leap_year' 'test/countries/test_saudiarabia.py' was renamed to 'test/countries/test_saudi_arabia.py' to be consistent with 'holidays/countries/saudi_arabia.py' * is_leap_year removal Co-authored-by: s-weigand <[email protected]>
1 parent ff1a39c commit d65a8eb

File tree

160 files changed

+12949
-8315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+12949
-8315
lines changed

.flake8

-4
This file was deleted.

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=lf
2+
*.bat text eol=crlf

.github/dependabot.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: pip
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: friday
8+
9+
# Maintain dependencies for GitHub Actions
10+
- package-ecosystem: github-actions
11+
directory: /
12+
schedule:
13+
interval: weekly
14+
day: friday

.github/workflows/ci-cd.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: "Tests"
2+
on: [push, pull_request, workflow_dispatch]
3+
4+
jobs:
5+
pre-commit:
6+
name: Run Quality Assurance
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check out repo
10+
uses: actions/checkout@v2
11+
- name: Set up Python
12+
uses: actions/setup-python@v2
13+
- name: Run pre-commit
14+
uses: pre-commit/[email protected]
15+
16+
test:
17+
name: "Test: python=${{ matrix.python-version }} on ${{ matrix.os }}"
18+
runs-on: ${{ matrix.os }}
19+
needs: [pre-commit]
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest, macOS-latest]
23+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install -U pip wheel 'coveralls>=3'
34+
python -m pip install -U -r requirements_dev.txt
35+
python -m pip install -e .
36+
- name: Run tests
37+
run: |
38+
py.test
39+
- name: Upload Coverage
40+
run: coveralls --service=github
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
44+
COVERALLS_PARALLEL: true
45+
46+
coveralls:
47+
name: Finish Coveralls
48+
needs: [test]
49+
runs-on: ubuntu-latest
50+
container: python:3-slim
51+
steps:
52+
- name: Finished
53+
run: |
54+
pip3 install -U 'coveralls>=3'
55+
coveralls --finish --service=github
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
deploy:
60+
runs-on: ubuntu-latest
61+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
62+
needs: [test]
63+
steps:
64+
- uses: actions/checkout@v2
65+
- name: Set up Python 3.7
66+
uses: actions/setup-python@v2
67+
with:
68+
python-version: 3.7
69+
- name: Install dependencies
70+
run: |
71+
python -m pip install -U pip wheel
72+
pip install -U .
73+
- name: Build dist
74+
run: |
75+
python setup.py sdist bdist_wheel
76+
77+
- name: Publish package
78+
uses: pypa/[email protected]
79+
with:
80+
user: __token__
81+
password: ${{ secrets.pypi_password }}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ MANIFEST
66
*.egg-info
77
*.pyc
88
.idea
9+
<<<<<<< HEAD
910

1011

1112
# IDE Stuff
1213
.vscode/
1314
*.DS_Store
15+
=======
16+
.vscode/
17+
coverage.xml
18+
.tox
19+
>>>>>>> 10aa24a6058b8a4c65e533b7fcd10948a0ffadf1

.pre-commit-config.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.3.0
4+
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- id: fix-encoding-pragma
10+
- id: mixed-line-ending
11+
args: [--fix=lf]
12+
13+
- repo: https://github.com/python/black
14+
rev: 20.8b1
15+
hooks:
16+
- id: black
17+
language_version: python3
18+
19+
- repo: https://gitlab.com/pycqa/flake8
20+
rev: 3.8.4
21+
hooks:
22+
- id: flake8
23+
24+
- repo: https://github.com/pre-commit/pygrep-hooks
25+
rev: v1.7.0
26+
hooks:
27+
- id: rst-backticks
28+
29+
- repo: https://github.com/myint/rstcheck
30+
rev: 3f92957478422df87bd730abde66f089cc1ee19b
31+
hooks:
32+
- id: rstcheck
33+
additional_dependencies: [rstcheck]

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ before_install:
99
install:
1010
- pip install flake8
1111
- pip install coveralls
12+
- pip install toml
1213
- python setup.py install
1314

1415

@@ -20,9 +21,6 @@ matrix:
2021
- python: '3.6'
2122
- python: 'pypy3'
2223

23-
before_script:
24-
- flake8
25-
2624
script:
2725
- coverage run --omit=*site-packages*,*pypy* tests.py
2826

CHANGES

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Version 0.10.5.3
33

44
Released -
55

6+
- Github Actions CI/CD integration (s-weigand, dr-p)
67
- Support for Saudi Arabia #429 (OsaydAbdu)
78
- __init.py__ flake8 issue fix #423 (dr-p)
89
- Korea 2020 fix #414, #415 (dr-p, janggiKim, spar7453)

README.rst

+33-24
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ A fast, efficient Python library for generating country, province and state
66
specific sets of holidays on the fly. It aims to make determining whether a
77
specific date is a holiday as fast and flexible as possible.
88

9-
.. image:: http://img.shields.io/travis/dr-prodigy/python-holidays/master
10-
:target: https://travis-ci.org/dr-prodigy/python-holidays
9+
.. image:: https://github.com/dr-prodigy/python-holidays/workflows/Tests/badge.svg
10+
:target: https://github.com/dr-prodigy/python-holidays/actions
1111

1212
.. image:: http://img.shields.io/coveralls/dr-prodigy/python-holidays/master
1313
:target: https://coveralls.io/r/dr-prodigy/python-holidays
@@ -225,30 +225,30 @@ state
225225
Methods:
226226

227227
get(key, default=None)
228-
Returns a string containing the name of the holiday(s) in date `key`, which
228+
Returns a string containing the name of the holiday(s) in date ``key``, which
229229
can be of date, datetime, string, unicode, bytes, integer or float type. If
230230
multiple holidays fall on the same date the names will be separated by
231231
commas
232232

233233
get(key, default=None)
234-
Returns a string containing the name of the holiday(s) in date `key`, which
234+
Returns a string containing the name of the holiday(s) in date ``key``, which
235235
can be of date, datetime, string, unicode, bytes, integer or float type. If
236236
multiple holidays fall on the same date the names will be separated by
237237
commas
238238

239239
get_list(key)
240-
Same as `get` except returns a `list` of holiday names instead of a comma
240+
Same as ``get`` except returns a ``list`` of holiday names instead of a comma
241241
separated string
242242

243243
get_named(name)
244-
Returns a `list` of holidays matching (even partially) the provided name
244+
Returns a ``list`` of holidays matching (even partially) the provided name
245245
(case insensitive check)
246246

247247
pop(key, default=None)
248-
Same as `get` except the key is removed from the holiday object
248+
Same as ``get`` except the key is removed from the holiday object
249249

250250
pop_named(name)
251-
Same as `pop` but takes the name of the holiday (or part of it) rather than
251+
Same as ``pop`` but takes the name of the holiday (or part of it) rather than
252252
the date
253253

254254
update/append
@@ -267,7 +267,7 @@ More Examples
267267
>>> import holidays
268268
>>> date(2014, 1, 1) in holidays.US()
269269
True
270-
>> date(2014, 1, 2) in holidays.US()
270+
>>> date(2014, 1, 2) in holidays.US()
271271
False
272272
273273
# But this is not efficient because it is initializing a new Holiday object
@@ -316,7 +316,7 @@ More Examples
316316
>>> len(us_holidays)
317317
10
318318
319-
# Because by default the `expand` param is True the Holiday object will add
319+
# Because by default the ``expand`` param is True the Holiday object will add
320320
# holidays from other years as they are required.
321321
322322
>>> date(2013, 1, 1) in us_holidays
@@ -326,7 +326,7 @@ More Examples
326326
>>> len(us_holidays)
327327
20
328328
329-
# If we change the `expand` param to False the Holiday object will no longer
329+
# If we change the ``expand`` param to False the Holiday object will no longer
330330
# add holidays from new years
331331
332332
>>> us_holidays.expand = False
@@ -337,7 +337,7 @@ More Examples
337337
True
338338
339339
# January 1st, 2012 fell on a Sunday so the statutory holiday was observed
340-
# on the 2nd. By default the `observed` param is True so the holiday list
340+
# on the 2nd. By default the ``observed`` param is True so the holiday list
341341
# will include January 2nd, 2012 as a holiday.
342342
343343
>>> date(2012, 1, 1) in us_holidays
@@ -349,7 +349,7 @@ More Examples
349349
>>> us_holidays.get(date(2012 ,1, 2))
350350
"New Year's Day (Observed)"
351351
352-
# The `observed` and `expand` values can both be changed on the fly and the
352+
# The ``observed`` and ``expand`` values can both be changed on the fly and the
353353
# holiday list will be adjusted accordingly
354354
355355
>>> us_holidays.observed = False
@@ -384,7 +384,7 @@ More Examples
384384
'QC', 'SK', 'YU']
385385
386386
# Holidays can be retrieved using their name too.
387-
# `get_named(key)` receives a string and returns a list of holidays
387+
# ``get_named(key)`` receives a string and returns a list of holidays
388388
# matching it (even partially, with case insensitive check)
389389
390390
>>> us_holidays = holidays.UnitedStates(years=2020)
@@ -476,24 +476,33 @@ The latest development (beta) version can be installed directly from GitHub:
476476
All new features are always first pushed to beta branch, then released on
477477
master branch upon official version upgrades.
478478

479-
Running Tests
480-
-------------
479+
Running Tests and Coverage
480+
--------------------------
481481

482482
.. code-block:: bash
483483
484-
$ pip install flake8
485-
$ flake8
486-
$ python tests.py
484+
$ pip install -r requirements_dev.txt
485+
$ python -m pytest .
486+
487+
488+
Ensure all staged files are up to standard
489+
------------------------------------------
490+
491+
.. _pre-commit: https://github.com/dr-prodigy/python-holidays/issues
492+
493+
Install the githooks with `pre-commit`_, after that the quality assurance
494+
tests will run on all staged files before you commit them and intercept
495+
the commit if the staged files aren't up to standard.
496+
497+
.. code-block:: bash
487498
499+
$ pre-commit install
488500
489-
Coverage
490-
--------
501+
Manually run the quality assurance tests on all tracked files.
491502

492503
.. code-block:: bash
493504
494-
$ pip install coverage
495-
$ coverage run --omit=*site-packages* tests.py
496-
$ coverage report -m
505+
$ pre-commit run -a
497506
498507
499508
Contributions

__init__.py

Whitespace-only changes.

holidays/__init__.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@
1212
# License: MIT (see LICENSE file)
1313
from holidays.countries import *
1414
from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND
15-
from holidays.constants import \
16-
JAN, FEB, MAR, APR, MAY, JUN, \
17-
JUL, AUG, SEP, OCT, NOV, DEC
15+
from holidays.constants import (
16+
JAN,
17+
FEB,
18+
MAR,
19+
APR,
20+
MAY,
21+
JUN,
22+
JUL,
23+
AUG,
24+
SEP,
25+
OCT,
26+
NOV,
27+
DEC,
28+
)
1829
from holidays.holiday_base import HolidayBase, createHolidaySum
1930
from holidays.utils import list_supported_countries, CountryHoliday
2031

21-
__version__ = '0.10.5.3'
32+
__version__ = "0.10.5.3"

holidays/constants.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
MON, TUE, WED, THU, FRI, SAT, SUN = range(7)
1515
WEEKEND = (SAT, SUN)
1616

17-
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \
18-
NOV, DEC = range(1, 13)
17+
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13)

holidays/countries/__init__.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# python-holidays
23
# ---------------
34
# A fast, efficient Python library for generating country, province and state
@@ -76,7 +77,16 @@
7677
from .turkey import Turkey, TR, TUR
7778
from .ukraine import Ukraine, UA, UKR
7879
from .united_arab_emirates import UnitedArabEmirates, AE, ARE
79-
from .united_kingdom import UnitedKingdom, UK, GB, England, Wales, Scotland,\
80-
IsleOfMan, NorthernIreland, GBR
80+
from .united_kingdom import (
81+
UnitedKingdom,
82+
UK,
83+
GB,
84+
England,
85+
Wales,
86+
Scotland,
87+
IsleOfMan,
88+
NorthernIreland,
89+
GBR,
90+
)
8191
from .united_states import UnitedStates, US, USA
8292
from .vietnam import Vietnam, VN, VNM

holidays/countries/angola.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323

2424

2525
class Angola(HolidayBase):
26-
2726
def __init__(self, **kwargs):
2827
# https://www.officeholidays.com/countries/angola/
2928
# https://www.timeanddate.com/holidays/angola/
30-
self.country = 'AO'
29+
self.country = "AO"
3130
HolidayBase.__init__(self, **kwargs)
3231

3332
def _populate(self, year):

0 commit comments

Comments
 (0)