Skip to content

Commit

Permalink
GH action CI/CD integration - #404 #443
Browse files Browse the repository at this point in the history
(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 <s.weigand.phy@gmail.com>
  • Loading branch information
dr-prodigy and s-weigand committed Feb 24, 2021
1 parent ff1a39c commit d65a8eb
Show file tree
Hide file tree
Showing 160 changed files with 12,949 additions and 8,315 deletions.
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

0 comments on commit d65a8eb

Please sign in to comment.