Skip to content

Commit 75ff1e3

Browse files
Initial Version (#4)
* initial commit * Adding requirements * move script, paste initial code frame and add library to translate weather codes * addadd unit test * ignore .envrc * ignore .github/copilot-instructions.md * some initial code * load configuration file * add some configuration defaults, implement MQTT Retain and load configuration file * upgrade dependencies * Add more tests, create initial documentation, add code validation pipeline * do some optimizations and tests * prepare imports * update dependencies * fixing linter issus * push lib * add envrc exampe * request data from open mateo api * add some default data to output * fix linter issues * Fix logger initialization * upgrade dependencies * issue#1 1Implement parser to parse daily weather (#2) Added environment file for testing and added code for parsing daily weather. Signed-off-by: Sathishkumar Duraisamy <sathishkumar.d.cbe@gmail.com> * upgrade dependencies * make caching configurable, specials ops for tomorrow mode * fix copyright year * enhance documentation * upgrade pre-commit dependencies, fix linter issues * small fix * fix assertion --------- Signed-off-by: Sathishkumar Duraisamy <sathishkumar.d.cbe@gmail.com> Co-authored-by: Sathishkumar Duraisamy <6611160+sduraiengineer@users.noreply.github.com>
1 parent 0c0da38 commit 75ff1e3

25 files changed

+1499
-3
lines changed

.github/FUNDING.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14+
- https://www.paypal.com/donate/?hosted_button_id=BHGJGGUS6RH44
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: build-and-push-container-image
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
jobs:
8+
build-and-push-container-image:
9+
name: Build and push container image
10+
runs-on: ubuntu-latest
11+
if: |
12+
github.event_name == 'pull_request' &&
13+
github.event.pull_request.merged == true &&
14+
github.event.action == 'closed' &&
15+
(
16+
contains(github.event.pull_request.labels.*.name, 'major') ||
17+
contains(github.event.pull_request.labels.*.name, 'minor') ||
18+
contains(github.event.pull_request.labels.*.name, 'patch')
19+
) &&
20+
!contains(github.event.pull_request.labels.*.name, 'chore')
21+
steps:
22+
- name: Checkout GIT repository
23+
uses: actions/checkout@v3
24+
- name: Get the application version
25+
id: application-version
26+
run: |
27+
image_version=$(grep "^LABEL site.local.program.version=" Dockerfile | cut -d= -f2 | sed -e 's/"//g')
28+
if [ -z "${image_version}" ]; then
29+
echo "ERROR: unable to detect version number!" >&2
30+
exit 1
31+
fi
32+
echo "tag=${image_version}" >> $GITHUB_OUTPUT
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
- name: Login to container registry
38+
uses: docker/login-action@v3
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
42+
- name: Build and push
43+
uses: docker/build-push-action@v6
44+
with:
45+
push: true
46+
context: .
47+
platforms: linux/amd64, linux/arm64
48+
tags: oitc/mqtt2elasticsearch:${{ steps.application-version.outputs.tag }},oitc/mqtt2elasticsearch:latest
49+
labels: |
50+
site.local.program.version=${{ steps.application-version.outputs.tag }}
51+
context.github.repositoryUrl=${{ github.repositoryUrl }}
52+
context.github.actor=${{ github.actor }}
53+
context.github.event.repository.updated_at=${{ github.event.repository.updated_at}}
54+
context.github.ref=${{ github.ref }}
55+
context.github.job=${{ github.job }}
56+
context.runner.os=${{ runner.os }}
57+
context.runner.arch=${{ runner.arch }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install ruff pytest
26+
pip install -r ./src/requirements.txt
27+
- name: Lint with ruff
28+
run: |
29+
# stop the build if there are Python syntax errors or undefined names
30+
ruff check --select=E9,F63,F7,F82 --target-version=py312 .
31+
# default set of ruff rules with GitHub Annotations
32+
ruff check --target-version=py312 .
33+
- name: Test with pytest
34+
run: |
35+
pytest
36+
- name: Test with unittest
37+
run: |
38+
python -m unittest
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: container-image-build-validation
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
- synchronize
8+
- reopened
9+
jobs:
10+
container-build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout GIT repository
15+
uses: actions/checkout@v4
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
- name: Test build
21+
uses: docker/build-push-action@v6
22+
with:
23+
push: false
24+
load: false
25+
context: .
26+
platforms: linux/amd64, linux/arm64
27+
tags: container-build:test
28+
- name: Test build and export for further validation
29+
uses: docker/build-push-action@v6
30+
with:
31+
push: false
32+
load: true
33+
context: .
34+
tags: container-build:test
35+
outputs: type=docker,dest=/tmp/container.tar
36+
- name: Upload container image as artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: container-build
40+
path: /tmp/container.tar
41+
scan:
42+
name: Container vulnerability scan
43+
needs: container-build
44+
uses: cybcon/github_workflows/.github/workflows/container-vulnerability-scan.yaml@v1.4.0
45+
with:
46+
image_name: container-build:test
47+
image_artifact_filename: container.tar
48+
image_artifact_name: container-build
49+
login_dockerhub: false
50+
trivy_tag: latest

.github/workflows/pre-commit.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: pre-commit
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
pre-commit:
9+
uses: cybcon/github_workflows/.github/workflows/pre-commit.yaml@v1.4.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: release
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
jobs:
7+
release:
8+
uses: cybcon/github_workflows/.github/workflows/release-from-label.yaml@v1.4.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: release-label-validation
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
- synchronize
8+
- reopened
9+
- labeled
10+
- unlabeled
11+
jobs:
12+
release-label-validation:
13+
uses: cybcon/github_workflows/.github/workflows/release-label-validation.yaml@v1.4.0

.gitignore

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
.project
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
.envrc
9+
.github/copilot-instructions.md
10+
.cache.sqlite
11+
12+
# C extensions
13+
*.so
14+
15+
# Distribution / packaging
16+
.Python
17+
build/
18+
develop-eggs/
19+
dist/
20+
downloads/
21+
eggs/
22+
.eggs/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
share/python-wheels/
29+
*.egg-info/
30+
.installed.cfg
31+
*.egg
32+
MANIFEST
33+
34+
# PyInstaller
35+
# Usually these files are written by a python script from a template
36+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
37+
*.manifest
38+
*.spec
39+
40+
# Installer logs
41+
pip-log.txt
42+
pip-delete-this-directory.txt
43+
44+
# Unit test / coverage reports
45+
htmlcov/
46+
.tox/
47+
.nox/
48+
.coverage
49+
.coverage.*
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
*.cover
54+
*.py,cover
55+
.hypothesis/
56+
.pytest_cache/
57+
cover/
58+
59+
# Translations
60+
*.mo
61+
*.pot
62+
63+
# Django stuff:
64+
*.log
65+
local_settings.py
66+
db.sqlite3
67+
db.sqlite3-journal
68+
69+
# Flask stuff:
70+
instance/
71+
.webassets-cache
72+
73+
# Scrapy stuff:
74+
.scrapy
75+
76+
# Sphinx documentation
77+
docs/_build/
78+
79+
# PyBuilder
80+
.pybuilder/
81+
target/
82+
83+
# Jupyter Notebook
84+
.ipynb_checkpoints
85+
86+
# IPython
87+
profile_default/
88+
ipython_config.py
89+
90+
# pyenv
91+
# For a library or package, you might want to ignore these files since the code is
92+
# intended to run in multiple environments; otherwise, check them in:
93+
# .python-version
94+
95+
# pipenv
96+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
98+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
99+
# install all needed dependencies.
100+
#Pipfile.lock
101+
102+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103+
__pypackages__/
104+
105+
# Celery stuff
106+
celerybeat-schedule
107+
celerybeat.pid
108+
109+
# SageMath parsed files
110+
*.sage.py
111+
112+
# Environments
113+
.env
114+
.venv
115+
env/
116+
venv/
117+
ENV/
118+
env.bak/
119+
venv.bak/
120+
121+
# Spyder project settings
122+
.spyderproject
123+
.spyproject
124+
125+
# Rope project settings
126+
.ropeproject
127+
128+
# mkdocs documentation
129+
/site
130+
131+
# mypy
132+
.mypy_cache/
133+
.dmypy.json
134+
dmypy.json
135+
136+
# Pyre type checker
137+
.pyre/
138+
139+
# pytype static type analyzer
140+
.pytype/
141+
142+
# Cython debug symbols
143+
cython_debug/

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: fix-byte-order-marker
6+
- id: check-json
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
- id: mixed-line-ending
11+
args: ['--fix=lf']
12+
description: Forces to replace line ending by the UNIX 'lf' character
13+
- id: detect-aws-credentials
14+
args: ['--allow-missing-credentials']
15+
- id: detect-private-key
16+
- repo: https://github.com/myint/autoflake
17+
rev: v2.3.1
18+
hooks:
19+
- id: autoflake
20+
args:
21+
- --in-place
22+
- --remove-unused-variables
23+
- --remove-all-unused-imports
24+
- repo: https://github.com/hadolint/hadolint
25+
rev: v2.14.0
26+
hooks:
27+
- id: hadolint-docker
28+
- repo: https://github.com/charliermarsh/ruff-pre-commit
29+
rev: v0.14.10
30+
hooks:
31+
- id: ruff
32+
args:
33+
- '--line-length=120'
34+
- '--fix'
35+
- '--exit-non-zero-on-fix'
36+
- repo: https://github.com/pycqa/isort
37+
rev: 7.0.0
38+
hooks:
39+
- id: isort
40+
name: isort (python)
41+
args:
42+
- '--profile'
43+
- black
44+
- '--filter-files'
45+
- repo: https://github.com/psf/black
46+
rev: 25.12.0
47+
hooks:
48+
- id: black
49+
args:
50+
- '--line-length=120'

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit 4.5.1

0 commit comments

Comments
 (0)