Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix ci #154

Merged
merged 10 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 0 additions & 22 deletions .github/release-drafter.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

# yamllint disable-line rule:truthy
on:
push:
pull_request: ~

jobs:
shared-ci:
uses: zigpy/workflows/.github/workflows/ci.yml@main
with:
CODE_FOLDER: zigpy_xbee
CACHE_VERSION: 2
PYTHON_VERSION_DEFAULT: 3.9.15
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit
MINIMUM_COVERAGE_PERCENTAGE: 99
16 changes: 16 additions & 0 deletions .github/workflows/matchers/codespell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "codespell",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):\\s(.+)$",
"file": 1,
"line": 2,
"message": 3
}
]
}
]
}
30 changes: 30 additions & 0 deletions .github/workflows/matchers/flake8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"problemMatcher": [
{
"owner": "flake8-error",
"severity": "error",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s([EF]\\d{3}\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
},
{
"owner": "flake8-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s([CDNW]\\d{3}\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
18 changes: 18 additions & 0 deletions .github/workflows/matchers/python.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "python",
"pattern": [
{
"regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$",
"file": 1,
"line": 2
},
{
"regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$",
"message": 2
}
]
}
]
}
31 changes: 8 additions & 23 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
name: Publish distributions to PyPI and TestPyPI
name: Publish distributions to PyPI
on:
push:
tags:
- "*"
release:
types:
- published

jobs:
build-and-publish:
name: Build and publish distributions to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
version: 3.8
- name: Install wheel
run: >-
pip install wheel
- name: Build
run: >-
python3 setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_TOKEN }}
shared-build-and-publish:
uses: zigpy/workflows/.github/workflows/publish-to-pypi.yml@main
secrets:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
16 changes: 0 additions & 16 deletions .github/workflows/release-management.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ENV/

# Editor temp files
.*.swp
tags

# Visual Studio Code
.vscode
.vscode
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- Flake8-pyproject==1.2.3
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[build-system]
requires = ["setuptools>=61.0.0", "wheel", "setuptools-git-versioning<2"]
build-backend = "setuptools.build_meta"

[project]
name = "zigpy-xbee"
dynamic = ["version"]
description = "A library which communicates with XBee radios for zigpy"
urls = {repository = "https://github.com/zigpy/zigpy-xbee"}
authors = [
{name = "Russell Cloran", email = "rcloran@gmail.com"}
]
readme = "README.md"
license = {text = "GPL-3.0"}
requires-python = ">=3.8"
dependencies = [
"zigpy>=0.56.0",
]

[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]

[project.optional-dependencies]
testing = [
"pytest>=7.1.2",
"asynctest>=0.13.0",
"pytest-asyncio>=0.19.0",
]

[tool.setuptools-git-versioning]
enabled = true

[tool.isort]
profile = "black"
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
known_first_party = ["zigpy_xbee", "tests"]
forced_separate = "tests"
combine_as_imports = true

[tool.mypy]
ignore_errors = true

[tool.pytest.ini_options]
asyncio_mode = "auto"

[tool.flake8]
exclude = [".venv", ".git", ".tox", "docs", "venv", "bin", "lib", "deps", "build"]
# To work with Black
max-line-length = 88
# W503: Line break occurred before a binary operator
# E203: Whitespace before ':'
# D202 No blank lines allowed after function docstring
ignore = ["W503", "E203", "D202"]
20 changes: 20 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Test dependencies.

asynctest
isort
black
flake8
codecov
colorlog
codespell
mypy==1.2.0
pre-commit
pylint
pytest-cov
pytest-sugar
pytest-timeout
pytest-asyncio>=0.17
pytest>=7.1.3
zigpy>=0.54.1
ruff==0.0.261
Flake8-pyproject
32 changes: 0 additions & 32 deletions setup.cfg

This file was deleted.

24 changes: 4 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
"""Setup module for zigpy-xbee"""
"""Setup stub for legacy builds."""

import pathlib
import setuptools

from setuptools import find_packages, setup

import zigpy_xbee

setup(
name="zigpy-xbee",
version=zigpy_xbee.__version__,
description="A library which communicates with XBee radios for zigpy",
long_description=(pathlib.Path(__file__).parent / "README.md").read_text(),
long_description_content_type="text/markdown",
url="http://github.com/zigpy/zigpy-xbee",
author="Russell Cloran",
author_email="rcloran@gmail.com",
license="GPL-3.0",
packages=find_packages(exclude=["tests", "tests.*"]),
install_requires=["zigpy>=0.56.0"],
tests_require=["pytest", "asynctest", "pytest-asyncio"],
)
if __name__ == "__main__":
setuptools.setup()
6 changes: 4 additions & 2 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ async def test_force_remove(app):


async def test_shutdown(app):
app._api.close = mock.MagicMock()
mack_close = mock.MagicMock()
app._api.close = mack_close
await app.shutdown()
assert app._api.close.call_count == 1
assert app._api is None
assert mack_close.call_count == 1


def test_remote_at_cmd(app, device):
Expand Down
6 changes: 2 additions & 4 deletions tests/test_uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def test_command_mode_rsp(gw):
def test_command_mode_send(gw):
data = b"ATAP2\x0D"
gw.command_mode_send(data)
assert gw._transport.write.call_count == 1
assert gw._transport.write.called_once_with(data)
gw._transport.write.assert_called_once_with(data)


def test_close(gw):
Expand Down Expand Up @@ -160,9 +159,8 @@ def test_frame_received(gw):

def test_send(gw):
gw.send(b"\x23\x11")
assert gw._transport.write.call_count == 1
data = b"\x7E\x00\x02\x23\x7D\x31\xCB"
assert gw._transport.write.called_once_with(data)
gw._transport.write.assert_called_once_with(data)


def test_escape(gw):
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py37, py38, lint, black
envlist = py38, py39, py310, py311, py312, lint, black
skip_missing_interpreters = True

[testenv]
Expand All @@ -13,19 +13,19 @@ install_command = pip install {opts} {packages}
commands = py.test --cov --cov-report=
deps =
asynctest
coveralls
pytest
pytest-cov
pytest-asyncio

[testenv:lint]
basepython = python3
deps =
flake8==3.7.9
isort==4.3.21
flake8==6.1.0
isort==5.12.0
Flake8-pyproject==1.2.3
commands =
flake8
isort --check -rc {toxinidir}/zigpy_xbee {toxinidir}/tests {toxinidir}/setup.py
isort --check {toxinidir}/zigpy_xbee {toxinidir}/tests {toxinidir}/setup.py

[testenv:black]
deps=black
Expand Down