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

GH action CI/CD integration - #404 (massive thx+kudos to s-weigand) #443

Merged
merged 43 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
afeb863
added coverage.xml to .gitignore
s-weigand Jul 23, 2020
2cbcfa6
Basic rewrite of the travis tests, with github actions
s-weigand Dec 3, 2020
9d91458
removed now obsolete travis config
s-weigand Dec 3, 2020
008607a
Added bump2version and its config
s-weigand Jul 23, 2020
a5c0c07
moved flake8 config to setup.cfg
s-weigand Dec 3, 2020
5b5bcf9
Formatted requirements with comments
s-weigand Dec 3, 2020
1e32e83
Created test file for each country and moved corresponding tests there
s-weigand Dec 3, 2020
e63f28d
Added pre-commit and a basic config containing black+its config
s-weigand Dec 4, 2020
8e47ebf
Added flake8 to pre-commit config and set flake8 to ignore E203
s-weigand Dec 4, 2020
dc06053
Replaced flake8 tests with pre-commit ones, since flake8 is included
s-weigand Dec 4, 2020
616705d
Updated workflow to use tests folder, upload coverage to coveralls.io
s-weigand Dec 4, 2020
41ce871
Added pre-commit hook that adds encoding shebang to all files
s-weigand Dec 4, 2020
aec3e1e
Added coverage config
s-weigand Dec 4, 2020
03f3673
Added tox+pytest config and added .tox to .gitignore
s-weigand Dec 4, 2020
864feef
Added rst checking tools to pre-commit and fixed rst issues
s-weigand Oct 17, 2020
5b7623b
Added workflow dispatch as an option to run the workflow
s-weigand Dec 4, 2020
1666e60
Removed py35 as was done in https://github.com/dr-prodigy/python-holi…
s-weigand Dec 7, 2020
7673946
Added dependabot config to receive automatics update PR's
s-weigand Dec 7, 2020
7035c8a
Fixed pytest config
s-weigand Dec 7, 2020
95aadcd
Replaced travis with github actions badge
s-weigand Dec 7, 2020
575a7ba
Changed contributing guide to reflect changed tooling
s-weigand Dec 7, 2020
10aa24a
Formatted setup.py again with black
s-weigand Dec 7, 2020
0b4656b
resolved conflicts, added is_leap_year
dr-prodigy Feb 10, 2021
38c2a27
Auto-format, Israel to_jd_gregorianyear fix
dr-prodigy Feb 21, 2021
1774c25
requirements_dev.txt review, Israel fixes, CHANGES+README.rst reviews
dr-prodigy Feb 21, 2021
0cc3ac2
precommit tasks run
dr-prodigy Feb 21, 2021
9041a8f
removed python 2.7 checks from github CI/CD scripts
dr-prodigy Feb 21, 2021
2cdc76f
flake8 config fixes
dr-prodigy Feb 21, 2021
dbd6426
travis build toml dependency fix
dr-prodigy Feb 21, 2021
e542366
removed duplicated flake8 tests from coverage config
dr-prodigy Feb 21, 2021
3bdfa24
old tests.py using new test classes
dr-prodigy Feb 21, 2021
d41731a
tests tree reviewed
dr-prodigy Feb 22, 2021
6f31bc4
tests cleanup (warn: coverage report -m needs fixing)
dr-prodigy Feb 22, 2021
d4fa424
Fixed usage of coveralls with gh-action after 3.0.0 release
dr-prodigy Feb 22, 2021
3d2a31c
more recent tests re-applied - #404
dr-prodigy Feb 22, 2021
4b1af4a
copyright 2021
dr-prodigy Feb 22, 2021
8629d0b
test tree refactoring, pytest running thru tests.py
dr-prodigy Feb 22, 2021
c9ad094
Flake8 test removed, pyproject.toml cleanup
dr-prodigy Feb 22, 2021
20ee170
Added .gitaddtributes file to ensure consistent '\n' line ending
s-weigand Feb 23, 2021
4dea034
Added pre-commit hook to enforce '\n' lineending and applied it on all
s-weigand Feb 23, 2021
cf62b78
Copied files from 'holiday' and 'tests' over and ran 'pre-commit run -a'
s-weigand Feb 23, 2021
61c7980
Merge branch 's-weigand-fix-diffs' into unstable
dr-prodigy Feb 24, 2021
919aa63
is_leap_year removal
dr-prodigy Feb 24, 2021
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
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=lf
*.bat text eol=crlf
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
day: friday

# Maintain dependencies for GitHub Actions
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: friday
81 changes: 81 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: "Tests"
on: [push, pull_request, workflow_dispatch]

jobs:
pre-commit:
name: Run Quality Assurance
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Run pre-commit
uses: pre-commit/action@v2.0.0

test:
name: "Test: python=${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
needs: [pre-commit]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip wheel 'coveralls>=3'
python -m pip install -U -r requirements_dev.txt
python -m pip install -e .
- name: Run tests
run: |
py.test
- name: Upload Coverage
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true

coveralls:
name: Finish Coveralls
needs: [test]
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install -U 'coveralls>=3'
coveralls --finish --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [test]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install -U pip wheel
pip install -U .
- name: Build dist
run: |
python setup.py sdist bdist_wheel

- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.pypi_password }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ MANIFEST
*.egg-info
*.pyc
.idea
<<<<<<< HEAD


# IDE Stuff
.vscode/
*.DS_Store
=======
.vscode/
coverage.xml
.tox
>>>>>>> 10aa24a6058b8a4c65e533b7fcd10948a0ffadf1
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: end-of-file-fixer
- id: trailing-whitespace
- id: fix-encoding-pragma
- id: mixed-line-ending
args: [--fix=lf]

- repo: https://github.com/python/black
rev: 20.8b1
hooks:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
hooks:
- id: rst-backticks

- repo: https://github.com/myint/rstcheck
rev: 3f92957478422df87bd730abde66f089cc1ee19b
hooks:
- id: rstcheck
additional_dependencies: [rstcheck]
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ before_install:
install:
- pip install flake8
- pip install coveralls
- pip install toml
- python setup.py install


Expand All @@ -20,9 +21,6 @@ matrix:
- python: '3.6'
- python: 'pypy3'

before_script:
- flake8

script:
- coverage run --omit=*site-packages*,*pypy* tests.py

Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version 0.10.5.3

Released -

- Github Actions CI/CD integration (s-weigand, dr-p)
- Support for Saudi Arabia #429 (OsaydAbdu)
- __init.py__ flake8 issue fix #423 (dr-p)
- Korea 2020 fix #414, #415 (dr-p, janggiKim, spar7453)
Expand Down
57 changes: 33 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ A fast, efficient Python library for generating country, province and state
specific sets of holidays on the fly. It aims to make determining whether a
specific date is a holiday as fast and flexible as possible.

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

.. image:: http://img.shields.io/coveralls/dr-prodigy/python-holidays/master
:target: https://coveralls.io/r/dr-prodigy/python-holidays
Expand Down Expand Up @@ -225,30 +225,30 @@ state
Methods:

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

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

get_list(key)
Same as `get` except returns a `list` of holiday names instead of a comma
Same as ``get`` except returns a ``list`` of holiday names instead of a comma
separated string

get_named(name)
Returns a `list` of holidays matching (even partially) the provided name
Returns a ``list`` of holidays matching (even partially) the provided name
(case insensitive check)

pop(key, default=None)
Same as `get` except the key is removed from the holiday object
Same as ``get`` except the key is removed from the holiday object

pop_named(name)
Same as `pop` but takes the name of the holiday (or part of it) rather than
Same as ``pop`` but takes the name of the holiday (or part of it) rather than
the date

update/append
Expand All @@ -267,7 +267,7 @@ More Examples
>>> import holidays
>>> date(2014, 1, 1) in holidays.US()
True
>> date(2014, 1, 2) in holidays.US()
>>> date(2014, 1, 2) in holidays.US()
False

# But this is not efficient because it is initializing a new Holiday object
Expand Down Expand Up @@ -316,7 +316,7 @@ More Examples
>>> len(us_holidays)
10

# Because by default the `expand` param is True the Holiday object will add
# Because by default the ``expand`` param is True the Holiday object will add
# holidays from other years as they are required.

>>> date(2013, 1, 1) in us_holidays
Expand All @@ -326,7 +326,7 @@ More Examples
>>> len(us_holidays)
20

# If we change the `expand` param to False the Holiday object will no longer
# If we change the ``expand`` param to False the Holiday object will no longer
# add holidays from new years

>>> us_holidays.expand = False
Expand All @@ -337,7 +337,7 @@ More Examples
True

# January 1st, 2012 fell on a Sunday so the statutory holiday was observed
# on the 2nd. By default the `observed` param is True so the holiday list
# on the 2nd. By default the ``observed`` param is True so the holiday list
# will include January 2nd, 2012 as a holiday.

>>> date(2012, 1, 1) in us_holidays
Expand All @@ -349,7 +349,7 @@ More Examples
>>> us_holidays.get(date(2012 ,1, 2))
"New Year's Day (Observed)"

# The `observed` and `expand` values can both be changed on the fly and the
# The ``observed`` and ``expand`` values can both be changed on the fly and the
# holiday list will be adjusted accordingly

>>> us_holidays.observed = False
Expand Down Expand Up @@ -384,7 +384,7 @@ More Examples
'QC', 'SK', 'YU']

# Holidays can be retrieved using their name too.
# `get_named(key)` receives a string and returns a list of holidays
# ``get_named(key)`` receives a string and returns a list of holidays
# matching it (even partially, with case insensitive check)

>>> us_holidays = holidays.UnitedStates(years=2020)
Expand Down Expand Up @@ -476,24 +476,33 @@ The latest development (beta) version can be installed directly from GitHub:
All new features are always first pushed to beta branch, then released on
master branch upon official version upgrades.

Running Tests
-------------
Running Tests and Coverage
--------------------------

.. code-block:: bash

$ pip install flake8
$ flake8
$ python tests.py
$ pip install -r requirements_dev.txt
$ python -m pytest .


Ensure all staged files are up to standard
------------------------------------------

.. _pre-commit: https://github.com/dr-prodigy/python-holidays/issues

Install the githooks with `pre-commit`_, after that the quality assurance
tests will run on all staged files before you commit them and intercept
the commit if the staged files aren't up to standard.

.. code-block:: bash

$ pre-commit install

Coverage
--------
Manually run the quality assurance tests on all tracked files.

.. code-block:: bash

$ pip install coverage
$ coverage run --omit=*site-packages* tests.py
$ coverage report -m
$ pre-commit run -a


Contributions
Expand Down
Empty file removed __init__.py
Empty file.
19 changes: 15 additions & 4 deletions holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
# License: MIT (see LICENSE file)
from holidays.countries import *
from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND
from holidays.constants import \
JAN, FEB, MAR, APR, MAY, JUN, \
JUL, AUG, SEP, OCT, NOV, DEC
from holidays.constants import (
JAN,
FEB,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
)
from holidays.holiday_base import HolidayBase, createHolidaySum
from holidays.utils import list_supported_countries, CountryHoliday

__version__ = '0.10.5.3'
__version__ = "0.10.5.3"
3 changes: 1 addition & 2 deletions holidays/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
MON, TUE, WED, THU, FRI, SAT, SUN = range(7)
WEEKEND = (SAT, SUN)

JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \
NOV, DEC = range(1, 13)
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13)
14 changes: 12 additions & 2 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
Expand Down Expand Up @@ -76,7 +77,16 @@
from .turkey import Turkey, TR, TUR
from .ukraine import Ukraine, UA, UKR
from .united_arab_emirates import UnitedArabEmirates, AE, ARE
from .united_kingdom import UnitedKingdom, UK, GB, England, Wales, Scotland,\
IsleOfMan, NorthernIreland, GBR
from .united_kingdom import (
UnitedKingdom,
UK,
GB,
England,
Wales,
Scotland,
IsleOfMan,
NorthernIreland,
GBR,
)
from .united_states import UnitedStates, US, USA
from .vietnam import Vietnam, VN, VNM
3 changes: 1 addition & 2 deletions holidays/countries/angola.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@


class Angola(HolidayBase):

def __init__(self, **kwargs):
# https://www.officeholidays.com/countries/angola/
# https://www.timeanddate.com/holidays/angola/
self.country = 'AO'
self.country = "AO"
HolidayBase.__init__(self, **kwargs)

def _populate(self, year):
Expand Down
Loading