Skip to content

Commit

Permalink
2.0.0 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 authored Mar 22, 2023
1 parent 8767ce2 commit deadefc
Show file tree
Hide file tree
Showing 73 changed files with 1,736 additions and 939 deletions.
12 changes: 8 additions & 4 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[flake8]
# spellcheck
dictionaries = en_US,python,technical

ignore =
# E201 whitespace after '('
E201,
Expand All @@ -13,6 +16,11 @@ ignore =
# E303 too many blank lines
E303,


per-file-ignores =
src/sml2mqtt/config/*:N805
tests/*:E501

max-line-length = 120
exclude =
.git,
Expand All @@ -23,7 +31,3 @@ exclude =
conf,
__init__.py,
tests/conftest.py,

# the interfaces will throw unused imports
HABApp/openhab/interface.py,
HABApp/openhab/interface_async.py,
44 changes: 44 additions & 0 deletions .github/workflows/publish-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish sml2mqtt to dockerhub
on:
release:
types: [published]
# on: [push, pull_request]


jobs:
buildx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
tags: |
spacemanspiff2007/sml2mqtt:latest
spacemanspiff2007/sml2mqtt:${{ github.ref_name }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
16 changes: 14 additions & 2 deletions .github/workflows/run_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ name: Tests
on: [push, pull_request]

jobs:
test:
pre-commit:
name:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/action@v3.0.0


tests:
needs: pre-commit
runs-on: ubuntu-latest
strategy:
max-parallel: 2
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
__pycache__
/build
/venv/

# sphinx
build
make.bat
37 changes: 36 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,52 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
# - id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace


- repo: https://github.com/pycqa/isort
rev: v5.11.3
rev: 5.12.0
hooks:
- id: isort
name: isort (python)


- repo: https://github.com/PyCQA/flake8
rev: '6.0.0'
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.2.13
- flake8-comprehensions==3.10.1
- flake8-pytest-style==1.6
# - flake8-spellcheck==0.28
# - flake8-unused-arguments==0.0.12
- flake8-noqa==1.3
- pep8-naming==0.13.3


- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py38-plus"]


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


- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
30 changes: 30 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

build:
os: ubuntu-22.04
tools:
python: "3.10"

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: requirements_setup.txt
- requirements: docs/requirements.txt
- method: pip
path: .
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.10-alpine

VOLUME /sml2mqtt

COPY . /tmp/sml2mqtt_src

RUN apk add --no-cache python3 py3-wheel py3-pip gcc musl-dev python3-dev && \
# install sml2mqtt from local dir
pip install --no-cache-dir /tmp/sml2mqtt_src && \
# cleanup
pip install --no-cache-dir pyclean && pyclean /usr && pip uninstall -y pyclean setuptools wheel pip && \
apk del py3-wheel py3-pip gcc musl-dev python3-dev && \
rm -fr /tmp/*

WORKDIR /sml2mqtt
CMD [ "sml2mqtt", "--config", "/sml2mqtt/config.yml"]
7 changes: 7 additions & 0 deletions docs/_static/theme_changes.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

/* On screens that are 767px or more */
@media screen and (min-width: 767px) {
.wy-nav-content {
max-width: 1100px !important;
}
}
92 changes: 92 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import os
import re
import sys

RTD_BUILD = os.environ.get('READTHEDOCS') == 'True'


# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'sml2mqtt'
copyright = '2023, spacemanspiff2007'
author = 'spacemanspiff2007'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx_exec_code',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx_autodoc_typehints',
'sphinxcontrib.autodoc_pydantic',
]

templates_path = ['_templates']
exclude_patterns = []


# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-add_module_names
# use class name instead of FQN
add_module_names = False


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_css_files = ['theme_changes.css']


# -- Options for autodoc -------------------------------------------------
autodoc_member_order = 'bysource'
autoclass_content = 'class'

# so autodoc does find the source
sys.path.insert(0, os.path.join(os.path.abspath('..'), 'src'))


# -- Options for autodoc pydantic -------------------------------------------------
# https://autodoc-pydantic.readthedocs.io/en/stable/

# No config on member
autodoc_pydantic_model_show_config_member = False
autodoc_pydantic_model_show_config_summary = False

# No validators
autodoc_pydantic_model_show_validator_summary = False
autodoc_pydantic_model_show_validator_members = False

# Model configuration
autodoc_pydantic_model_signature_prefix = 'settings'
autodoc_pydantic_model_show_json = False
autodoc_pydantic_model_show_field_summary = False
autodoc_pydantic_model_member_order = 'bysource'

# Field config
autodoc_pydantic_field_show_alias = False
autodoc_pydantic_field_list_validators = False
autodoc_pydantic_field_swap_name_and_alias = True

# -- Options for intersphinx -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
if RTD_BUILD:
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None)
}

# -- Options for nitpick -------------------------------------------------
# Don't show warnings for missing python references since these are created via intersphinx during the RTD build
if not RTD_BUILD:
nitpick_ignore_regex = [
(re.compile(r'^py:class'), re.compile(r'pathlib\..+')),
(re.compile(r'^py:data'), re.compile(r'typing\..+')),
(re.compile(r'^py:class'), re.compile(r'pydantic\..+|.+Constrained(?:Str|Int)Value')),
]
Loading

0 comments on commit deadefc

Please sign in to comment.