diff --git a/.flake8 b/.flake8 index 8441f7a..6ca6783 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -application-import-names = aiopvpc +application-import-names = aiopvpc,tests import-order-style = smarkets inline-quotes = double max-complexity = 10 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..a56dd1e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: CI + +on: + pull_request: + push: + branches: [master] + +jobs: + test-and-publish-flow: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Set up python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Run Poetry image + uses: abatilo/actions-poetry@v2.0.0 + with: + poetry-version: 1.1.11 + + - name: Install library + run: poetry install --no-interaction + + - name: Run tests + run: poetry run pytest + + # upload coverage only on master branch + - name: Upload coverage + if: ${{ github.ref == 'refs/heads/master' }} + uses: codecov/codecov-action@v2 + + # publish version only when pyproject.toml is changed in master + - name: Filter changes in pyproject + uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + root: + - 'pyproject.toml' + + - if: ${{ (github.ref == 'refs/heads/master') && (steps.changes.outputs.root == 'true')}} + name: Build and publish + env: + PYPI_USER: ${{ secrets.PYPI_USER }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: poetry publish --username $PYPI_USER --password $PYPI_PASSWORD --build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb93122..494d84f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,12 @@ minimum_pre_commit_version: "2.10.0" repos: + - repo: https://github.com/pycqa/isort + rev: 5.8.0 + hooks: + - id: isort + name: isort (python) + args: + - --dont-order-by-type - repo: https://github.com/psf/black rev: "21.6b0" hooks: @@ -10,6 +17,9 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + - id: check-json + - id: check-toml + - id: check-yaml - repo: https://github.com/pycqa/flake8 rev: "3.9.2" hooks: @@ -27,6 +37,7 @@ repos: - flake8-quotes>=3.2.0 - flake8-string-format>=0.3.0 - flake8-tidy-imports>=4.2.1 + - flake8-variables-names>=0.0.3 - pep8-naming>=0.11.1 - repo: "https://github.com/pre-commit/mirrors-mypy" rev: "v0.902" @@ -34,3 +45,13 @@ repos: - id: "mypy" name: "Check type hints (mypy)" verbose: true +ci: + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit.com hooks + + for more information, see https://pre-commit.ci + autofix_prs: true + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: monthly + skip: [] + submodules: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 04fd894..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: python -dist: xenial # required for Python >= 3.7 -os: linux -python: -- 3.9 -stages: -- lint -- test -- deploy -jobs: - include: - - stage: lint - install: - - pip install pre-commit - - pre-commit install-hooks - script: - - pre-commit run --all-files - - stage: test - install: - - pip install poetry - - poetry install -v - - pip install codecov - script: - - poetry run pytest - - codecov - - stage: deploy - if: branch = master AND type != pull_request - install: - - pip install poetry - script: - - poetry publish --username $PYPI_USER --password $PYPI_PASSWORD --build - on: - branch: master -env: - global: - - secure: lsc3tqXIaxYvWE7z3C73YET/2ibSBQ0v/YJjZL3JRxx8bxtojT2c9baZTxmjEpWtNRCZaRAr4MKTJ0Qe4/wrffePNuCJ0XjypP12sAa8lO5sExt8Zp/mYeLmrjOifsutgqI7Y+MBZfX35ha3xTEaNXtbcDbXrL2+mev+P9OQWHA0GtL2E+no1PWGc9gaHxmHg0QofIm4TZKi55EBbdzodBBbQwRmOk37j+n6EyqhjfciCHwepBLRGNTcWvjQ9jwauJwo2ySdt7eWejr8LEeCiSu4XpzC84eRjaF86B87QNi05y5tfRZihEm0GiuGsrgc7AhhfBM+vFtLXh6y0980gCs6dhFILwQg+JGhhnRhlaj5JRHmsMKW9fWBTHJulE0g+E3Arxsc1uvCmFowlpvJPJXvb0P27IQ6kD8eTFT6KVs/aVkg41hALdWakAGeh9NkIvilVrNUxkz/8RAqJCYHOcInmcd785Pt6XQBJHzzXpVuMimwGWllhbzbZQklQAlM6c6C2rAmHcXXCCOF+ZJqTHIoYRjk3FlzdX3keQ2CuW3GF5Rb5OUq/gwAPrpX821+k4YgmGia24sAxJI9bFBJpSvRl/oN7crM8zI53xG91tARHbKk2SVYzxV2DR/CHARb+lorebQ2flNcZ/BKLfYgOakuUMSpDpAoP4ifL3utuYI= - - secure: WLiLzwkxePPOpeWD6Q9WmvvxRsnJXDc1ar9n0JtWavLhB4dQ3DCpl8r+JU89oFx5RI9KqaXcyj57AKeEOLJ1zEpSZPEli2dqoQfJ40GsC6SPvGjSJDvMA+vPN2/+Os9cE0WWbKbrPuTVZsGzaIxPKeeteVH1su99uiYsu1w8X04H0l8FGr1mKFZBHl+f91ssXT7mRUDugZLU7BrDx5xjoz6HZnFTAFwIaNbkgJmlEAnqQ3wUHwhYA8DmwAjTe2tBsMaSBv4hkFuWeCkggNkVxChW5J1fot1+XE84kZynV7WE/hXjdZZvTkD097BKAzDE+KcrY+/n/XxmyXauj97rGnSen7vOdLYitK4Dw4LvIUdlP+y0BmfrP+KBiSyTd3UEaOqVE1uai38BpwLSUBMdVCMnBwHs4pvU4+cLN6SGyTrZ8o9sPegM10p/AzwWHAj9qBkLYtJSgM6JIyPqOPxbYu6P3okzgBM4WrQp0g0k6/iZkMCqVyk/F4jXerMf5BXQwyfRMKHWnGXCXxGXuBPUQonCfT7IG2Y3CNq/ZbGpVIo/YOjO/6Y+qecp4g1lWVCgVzEcyfeWouwZp0jVImtzSXzHkZwvluGIUbZ6MIMWYpKXxe94aLzdVnjC2Eo1QV4BOKdKQooLX4t0b0PDvGzR+jQfIudgIEMOh/q3szqbliU= diff --git a/CHANGELOG.md b/CHANGELOG.md index df5e243..67e4f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ # Changelog -## [v2.2.1](https://github.com/azogue/aiopvpc/tree/v2.2.1) - Dependency update (2021-11-03) +## [v2.2.2](https://github.com/azogue/aiopvpc/tree/v2.2.2) - Migrate CI from travis to gh-actions (2021-11-04) + +[Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.2...v2.2.1) + +**Changes:** + +* :art: Add isort to pre-commit config +* :green_heart: Add configuration for pre-commit.ci to run linter checks there +* :green_heart: CI flow with GitHub Actions to + - install library with `poetry` + - run tests + - upload coverage when merging to master + - publish a new pypi version when merging to master if `pyproject.toml` changes +* :fire: Remove previus travis CI config + +## [v2.2.1](https://github.com/azogue/aiopvpc/tree/v2.2.1) - Quickfix for 403 status code from ESIOS API (2021-11-03) [Full Changelog](https://github.com/azogue/aiopvpc/compare/v2.2.1...v2.2.0) diff --git a/README.md b/README.md index 42b3952..afcbaf7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,16 @@ -[![PyPi](https://pypip.in/v/aiopvpc/badge.svg)](https://pypi.org/project/aiopvpc/) -[![Wheel](https://pypip.in/wheel/aiopvpc/badge.svg)](https://pypi.org/project/aiopvpc/) -[![Travis Status](https://travis-ci.org/azogue/aiopvpc.svg?branch=master)](https://travis-ci.org/azogue/aiopvpc) -[![codecov](https://codecov.io/gh/azogue/aiopvpc/branch/master/graph/badge.svg)](https://codecov.io/gh/azogue/aiopvpc) +[![PyPI Version][pypi-image]][pypi-url] +[![pre-commit.ci Status][pre-commit-ci-image]][pre-commit-ci-url] +[![Build Status][build-image]][build-url] +[![Code Coverage][coverage-image]][coverage-url] + +[pypi-image]: https://img.shields.io/pypi/v/aiopvpc +[pypi-url]: https://pypi.org/project/aiopvpc/ +[pre-commit-ci-image]: https://results.pre-commit.ci/badge/github/azogue/aiopvpc/master.svg +[pre-commit-ci-url]: https://results.pre-commit.ci/latest/github/azogue/aiopvpc/master +[build-image]: https://github.com/azogue/aiopvpc/actions/workflows/main.yml/badge.svg +[build-url]: https://github.com/azogue/aiopvpc/actions/workflows/main.yml +[coverage-image]: https://codecov.io/gh/azogue/aiopvpc/branch/master/graph/badge.svg +[coverage-url]: https://codecov.io/gh/azogue/aiopvpc # aiopvpc diff --git a/aiopvpc/pvpc_data.py b/aiopvpc/pvpc_data.py index f524094..4107105 100644 --- a/aiopvpc/pvpc_data.py +++ b/aiopvpc/pvpc_data.py @@ -30,7 +30,6 @@ ) from aiopvpc.pvpc_download import extract_pvpc_data, get_url_for_daily_json - _REQUEST_HEADERS = { "User-Agent": "aioPVPC Python library", "Accept": "application/json", diff --git a/poetry.lock b/poetry.lock index f1e076d..02bfd20 100644 --- a/poetry.lock +++ b/poetry.lock @@ -486,6 +486,21 @@ category = "main" optional = false python-versions = ">=3.5" +[[package]] +name = "importlib-resources" +version = "5.4.0" +description = "Read resources from Python packages" +category = "main" +optional = true +python-versions = ">=3.6" + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-black (>=0.3.7)", "pytest-mypy"] + [[package]] name = "iniconfig" version = "1.1.1" @@ -605,7 +620,7 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "jsonschema" -version = "4.1.2" +version = "4.2.0" description = "An implementation of JSON Schema validation for Python" category = "main" optional = true @@ -613,6 +628,7 @@ python-versions = ">=3.7" [package.dependencies] attrs = ">=17.4.0" +importlib-resources = {version = "*", markers = "python_version < \"3.9\""} pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" [package.extras] @@ -1077,7 +1093,7 @@ twisted = ["twisted"] [[package]] name = "prompt-toolkit" -version = "3.0.21" +version = "3.0.22" description = "Library for building powerful interactive command lines in Python" category = "main" optional = true @@ -1482,6 +1498,18 @@ python-versions = ">=3.6" idna = ">=2.0" multidict = ">=4.0" +[[package]] +name = "zipp" +version = "3.6.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = true +python-versions = ">=3.6" + +[package.extras] +docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] +testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] + [extras] jupyter = ["pandas", "jupyter", "matplotlib"] @@ -1936,6 +1964,10 @@ idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, ] +importlib-resources = [ + {file = "importlib_resources-5.4.0-py3-none-any.whl", hash = "sha256:33a95faed5fc19b4bc16b29a6eeae248a3fe69dd55d4d229d2b480e23eeaad45"}, + {file = "importlib_resources-5.4.0.tar.gz", hash = "sha256:d756e2f85dd4de2ba89be0b21dba2a3bbec2e871a42a3a16719258a11f87506b"}, +] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, @@ -1965,8 +1997,8 @@ jinja2 = [ {file = "Jinja2-3.0.2.tar.gz", hash = "sha256:827a0e32839ab1600d4eb1c4c33ec5a8edfbc5cb42dafa13b81f182f97784b45"}, ] jsonschema = [ - {file = "jsonschema-4.1.2-py3-none-any.whl", hash = "sha256:166870c8ab27bd712a8627e0598de4685bd8d199c4d7bd7cacc3d941ba0c6ca0"}, - {file = "jsonschema-4.1.2.tar.gz", hash = "sha256:5c1a282ee6b74235057421fd0f766ac5f2972f77440927f6471c9e8493632fac"}, + {file = "jsonschema-4.2.0-py3-none-any.whl", hash = "sha256:2b563117f3659a7f433dffe1371c88f52115b79133493f376f15724b9caa7efa"}, + {file = "jsonschema-4.2.0.tar.gz", hash = "sha256:e2d3601321ac74d38214e2853300ae740cd07e53d919a15862b8c71f9d840574"}, ] jupyter = [ {file = "jupyter-1.0.0-py2.py3-none-any.whl", hash = "sha256:5b290f93b98ffbc21c0c7e749f054b3267782166d72fa5e3ed1ed4eaf34a2b78"}, @@ -2402,8 +2434,8 @@ prometheus-client = [ {file = "prometheus_client-0.12.0.tar.gz", hash = "sha256:1b12ba48cee33b9b0b9de64a1047cbd3c5f2d0ab6ebcead7ddda613a750ec3c5"}, ] prompt-toolkit = [ - {file = "prompt_toolkit-3.0.21-py3-none-any.whl", hash = "sha256:62b3d3ea5a3ccee94dc1aac018279cf64866a76837156ebe159b981c42dd20a8"}, - {file = "prompt_toolkit-3.0.21.tar.gz", hash = "sha256:27f13ff4e4850fe8f860b77414c7880f67c6158076a7b099062cc8570f1562e5"}, + {file = "prompt_toolkit-3.0.22-py3-none-any.whl", hash = "sha256:48d85cdca8b6c4f16480c7ce03fd193666b62b0a21667ca56b4bb5ad679d1170"}, + {file = "prompt_toolkit-3.0.22.tar.gz", hash = "sha256:449f333dd120bd01f5d296a8ce1452114ba3a71fae7288d2f0ae2c918764fa72"}, ] ptyprocess = [ {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, @@ -2818,3 +2850,7 @@ yarl = [ {file = "yarl-1.7.2-cp39-cp39-win_amd64.whl", hash = "sha256:797c2c412b04403d2da075fb93c123df35239cd7b4cc4e0cd9e5839b73f52c58"}, {file = "yarl-1.7.2.tar.gz", hash = "sha256:45399b46d60c253327a460e99856752009fcee5f5d3c80b2f7c0cae1c38d56dd"}, ] +zipp = [ + {file = "zipp-3.6.0-py3-none-any.whl", hash = "sha256:9fe5ea21568a0a70e50f273397638d39b03353731e6cbbb3fd8502a33fec40bc"}, + {file = "zipp-3.6.0.tar.gz", hash = "sha256:71c644c5369f4a6e07636f0aa966270449561fcea2e3d6747b8d23efaa9d7832"}, +] diff --git a/pyproject.toml b/pyproject.toml index 613b61e..c44801e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,10 @@ +[tool.isort] +profile = "black" +line_length = 88 + [tool.black] line_length = 88 -target_version = ["py38", "py39"] +target_version = ["py39"] [tool.coverage.run] branch = true @@ -36,7 +40,7 @@ markers = [ [tool.poetry] name = "aiopvpc" -version = "2.2.1" +version = "2.2.2" description = "Retrieval of Spanish Electricity hourly prices (PVPC)" authors = ["Eugenio Panadero "] license = "MIT" diff --git a/tests/test_pvpc.py b/tests/test_pvpc.py index 99e18d4..2f0850d 100644 --- a/tests/test_pvpc.py +++ b/tests/test_pvpc.py @@ -9,7 +9,7 @@ from aiopvpc.const import OLD_TARIFS_IDS, REFERENCE_TZ from aiopvpc.pvpc_data import PVPCData -from .conftest import MockAsyncSession, TZ_TEST +from tests.conftest import MockAsyncSession, TZ_TEST @pytest.mark.parametrize(