Skip to content

Commit d637e82

Browse files
authored
Merge pull request #89 from ngehrsitz/ci
CI + Docker image
2 parents 483d282 + 1340ad4 commit d637e82

17 files changed

+184
-55
lines changed

.github/workflows/black.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: psf/black@stable

.github/workflows/docker.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
6+
permissions:
7+
contents: read
8+
packages: write
9+
10+
env:
11+
DOCKER_BUILDKIT: 1
12+
IMAGE_NAME: ghcr.io/${{ github.repository }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Log in to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Build and push
33+
uses: docker/build-push-action@v6
34+
with:
35+
platforms: linux/amd64,linux/arm64
36+
push: true
37+
tags: |
38+
${{ env.IMAGE_NAME }}:${{ github.sha }}
39+
${{ github.ref_name == 'main' && format('{0}:latest', env.IMAGE_NAME) || '' }}

.github/workflows/pytest.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Run Pytest
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Install dependencies
21+
run: |
22+
pip install --upgrade pip
23+
pip install pytest .
24+
25+
- name: Run Pytest
26+
run: |
27+
pytest

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# syntax=docker/dockerfile:1
2+
FROM python:3.13-alpine
3+
4+
# mount current directory to /app
5+
# install with pip
6+
RUN --mount=type=bind,rw,source=.,target=/src \
7+
pip install --no-cache-dir /src
8+
9+
CMD echo "Available commands:" && find /usr/local/bin -type f -name 'solarman*' -exec basename {} \;

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ To install the latest development version from git, run:
4848

4949
This will also install the tools from the [utils](/utils) directory.
5050

51+
## Docker
52+
53+
To run the tools in the docker image, run:
54+
55+
`docker run --rm ghcr.io/jmccrohan/pysolarmanv5:latest`
56+
5157
## Projects using pysolarmanv5
5258

5359
- [davidrapan/ha-solarman](https://github.com/davidrapan/ha-solarman)

docs/conf.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
import sys
33
from datetime import date
44

5-
sys.path.insert(0, os.path.abspath('../'))
5+
sys.path.insert(0, os.path.abspath("../"))
66

7-
project = 'pysolarmanv5'
7+
project = "pysolarmanv5"
88
copyright = f"{date.today().year}, Jonathan McCrohan"
9-
author = 'Jonathan McCrohan <[email protected]>'
9+
author = "Jonathan McCrohan <[email protected]>"
1010

1111
extensions = [
12-
'sphinx.ext.autodoc',
13-
'sphinx.ext.autosectionlabel',
14-
'sphinx.ext.viewcode',
15-
'sphinx.ext.todo',
16-
'myst_parser',
17-
'sphinxcontrib.packetdiag',
18-
]
12+
"sphinx.ext.autodoc",
13+
"sphinx.ext.autosectionlabel",
14+
"sphinx.ext.viewcode",
15+
"sphinx.ext.todo",
16+
"myst_parser",
17+
"sphinxcontrib.packetdiag",
18+
]
1919

20-
html_theme = 'furo'
20+
html_theme = "furo"
2121

2222
html_theme_options = {
2323
"source_repository": "https://github.com/jmccrohan/pysolarmanv5/",
@@ -26,21 +26,21 @@
2626
}
2727

2828
autodoc_default_options = {
29-
'members': True,
30-
'member-order': 'bysource',
29+
"members": True,
30+
"member-order": "bysource",
3131
#'private-members': True,
32-
}
32+
}
3333

3434
autodoc_mock_imports = ["umodbus"]
3535

3636
autosectionlabel_prefix_document = True
3737

38-
packetdiag_html_image_format = 'SVG'
38+
packetdiag_html_image_format = "SVG"
3939

40-
html_static_path = ['_static']
40+
html_static_path = ["_static"]
4141

4242
html_css_files = [
43-
'css/custom.css',
44-
]
43+
"css/custom.css",
44+
]
4545

46-
#todo_include_todos = True
46+
# todo_include_todos = True

examples/async_client_example.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" A basic client demonstrating how to use the async version of pysolarmanv5."""
1+
"""A basic client demonstrating how to use the async version of pysolarmanv5."""
2+
23
from pysolarmanv5 import PySolarmanV5Async
34
import asyncio
45

@@ -11,7 +12,12 @@ async def main():
1112
respectively.
1213
"""
1314
modbus = PySolarmanV5Async(
14-
'192.168.1.121', 1234567890, port=8899, mb_slave_id=1, verbose=False, auto_reconnect=True
15+
"192.168.1.121",
16+
1234567890,
17+
port=8899,
18+
mb_slave_id=1,
19+
verbose=False,
20+
auto_reconnect=True,
1521
)
1622
await modbus.connect()
1723

@@ -27,15 +33,18 @@ async def main():
2733
"""Query single input register, apply scaling, result as a float"""
2834

2935
print(
30-
await modbus.read_input_register_formatted(register_addr=33035, quantity=1, scale=0.1)
36+
await modbus.read_input_register_formatted(
37+
register_addr=33035, quantity=1, scale=0.1
38+
)
3139
)
3240

3341
"""Query two input registers, shift first register up by 16 bits, result as a signed int, """
3442
print(
35-
await modbus.read_input_register_formatted(register_addr=33079, quantity=2, signed=1)
43+
await modbus.read_input_register_formatted(
44+
register_addr=33079, quantity=2, signed=1
45+
)
3646
)
3747

38-
3948
"""Query single holding register, apply bitmask and bitshift left (extract bit1 from register)"""
4049
print(
4150
await modbus.read_holding_register_formatted(
@@ -45,5 +54,6 @@ async def main():
4554

4655
await modbus.disconnect()
4756

57+
4858
if __name__ == "__main__":
4959
asyncio.run(main())

examples/client_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" A basic client demonstrating how to use pysolarmanv5."""
1+
"""A basic client demonstrating how to use pysolarmanv5."""
2+
23
from pysolarmanv5 import PySolarmanV5
34

45

@@ -41,5 +42,6 @@ def main():
4142

4243
modbus.disconnect()
4344

45+
4446
if __name__ == "__main__":
4547
main()

examples/register_scan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" Scan Modbus registers to find valid registers"""
1+
"""Scan Modbus registers to find valid registers"""
2+
23
from pysolarmanv5 import PySolarmanV5, V5FrameError
34
import umodbus.exceptions
45

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ version = "3.0.6"
44
description = "A Python library for interacting with Solarman (IGEN-Tech) v5 based Solar Data Loggers"
55
readme = "README.md"
66
requires-python = ">=3.8"
7-
license = {text = "MIT License"}
7+
license = "MIT"
88
authors = [{name = "Jonathan McCrohan", email = "[email protected]"}]
99
keywords = ["solarman", "igen-tech", "modbus", "solar", "inverter", "solarmanv5"]
1010
classifiers = [
1111
"Programming Language :: Python :: 3",
1212
"Topic :: Utilities",
13-
"License :: OSI Approved :: MIT License",
1413
]
1514
dependencies = [
1615
"umodbus",

0 commit comments

Comments
 (0)