diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f00e169..5e00a74 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -12,6 +12,25 @@ on: - "main" jobs: + test: + name: "Run automated tests" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout the repository" + uses: "actions/checkout@v4.2.2" + + - name: "Set up Python" + uses: actions/setup-python@v5.3.0 + with: + python-version: "3.12" + cache: "pip" + + - name: "Install test requirements" + run: python3 -m pip install -r requirements.test.txt + + - name: "Run pytest" + run: python3 -m pytest + hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest name: "Hassfest Validation" runs-on: "ubuntu-latest" @@ -32,6 +51,4 @@ jobs: - name: "Run HACS validation" uses: "hacs/action@main" with: - category: "integration" - # Remove this 'ignore' key when you have added brand images for your integration to https://github.com/home-assistant/brands - ignore: "brands" + category: "integration" \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e90d595 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,58 @@ +repos: + - repo: https://github.com/asottile/pyupgrade + rev: v3.19.1 + hooks: + - id: pyupgrade + args: [--py37-plus] + - repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black + args: + - --safe + - --quiet + files: ^((homeassistant|script|tests)/.+)?[^/]+\.py$ + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: + - --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing + - --skip="./.*,*.csv,*.json" + - --quiet-level=2 + exclude_types: [csv, json] + - repo: https://github.com/pycqa/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-docstrings==1.7.0 + - pydocstyle==6.3.0 + files: ^(homeassistant|script|tests)/.+\.py$ + - repo: https://github.com/PyCQA/bandit + rev: 1.8.0 + hooks: + - id: bandit + args: + - --quiet + - --format=custom + - --configfile=tests/bandit.yaml + files: ^(homeassistant|script|tests)/.+\.py$ + - repo: https://github.com/pre-commit/mirrors-isort + rev: v5.10.1 + hooks: + - id: isort + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-executables-have-shebangs + stages: [manual] + - id: check-json + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 + hooks: + - id: mypy + args: + - --pretty + - --show-error-codes + - --show-error-context \ No newline at end of file diff --git a/requirements.test.txt b/requirements.test.txt new file mode 100644 index 0000000..49cb893 --- /dev/null +++ b/requirements.test.txt @@ -0,0 +1 @@ +pytest-homeassistant-custom-component \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7143cdf..231bfc5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ colorlog==6.9.0 homeassistant==2024.10.3 pip>=21.3.1 ruff==0.8.1 -pymodbus==3.7.4 +pymodbus==3.7.4 \ No newline at end of file