Skip to content

Commit 14c1923

Browse files
Initial commit
1 parent 1101caf commit 14c1923

35 files changed

+7435
-0
lines changed

.dockerignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
*.so
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# Virtual environments
29+
venv/
30+
env/
31+
ENV/
32+
33+
# IDE
34+
.vscode/
35+
.idea/
36+
*.swp
37+
*.swo
38+
*~
39+
40+
# Testing
41+
.pytest_cache/
42+
.coverage
43+
htmlcov/
44+
.tox/
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
.hypothesis/
50+
51+
# Documentation
52+
docs/_build/
53+
.readthedocs.yml
54+
55+
# OS
56+
.DS_Store
57+
.DS_Store?
58+
._*
59+
.Spotlight-V100
60+
.Trashes
61+
ehthumbs.db
62+
Thumbs.db
63+
64+
# Logs
65+
*.log
66+
logs/
67+
68+
# Temporary files
69+
*.tmp
70+
*.temp
71+
72+
# Development files that aren't needed in container
73+
.pre-commit-config.yaml
74+
.flake8
75+
.mypy_cache/
76+
tasks.md
77+
spec.md
78+
CLAUDE.md
79+
80+
# GitHub Actions
81+
.github/
82+
83+
# Example files (not needed in production)
84+
config.example.*
85+
=3.6.0
86+
87+
# Claude commands
88+
.claude/

.env.docker.example

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Docker environment file example for MeshCore MQTT Bridge
2+
# Copy this file to .env.docker and modify the values as needed
3+
4+
# Logging Configuration
5+
LOG_LEVEL=INFO
6+
7+
# MQTT Broker Configuration
8+
MQTT_BROKER=localhost
9+
MQTT_PORT=1883
10+
MQTT_USERNAME=
11+
MQTT_PASSWORD=
12+
MQTT_TOPIC_PREFIX=meshcore
13+
MQTT_QOS=1
14+
MQTT_RETAIN=true
15+
16+
# MeshCore Device Configuration (serial default)
17+
MESHCORE_CONNECTION=serial
18+
MESHCORE_ADDRESS=/dev/ttyUSB0
19+
MESHCORE_BAUDRATE=115200
20+
MESHCORE_TIMEOUT=30
21+
22+
# Configurable Events (comma-separated list)
23+
MESHCORE_EVENTS=CONTACT_MSG_RECV,CHANNEL_MSG_RECV,CONNECTED,DISCONNECTED,LOGIN_SUCCESS,LOGIN_FAILED,MESSAGES_WAITING,DEVICE_INFO,BATTERY,NEW_CONTACT,ADVERTISEMENT
24+
25+
# TCP Connection Example (for network connections)
26+
# MESHCORE_CONNECTION=tcp
27+
# MESHCORE_ADDRESS=192.168.1.100
28+
# MESHCORE_PORT=4403
29+
30+
# BLE Connection Example (use MAC address as address)
31+
# MESHCORE_CONNECTION=ble
32+
# MESHCORE_ADDRESS=AA:BB:CC:DD:EE:FF

.flake8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, W503
4+
exclude =
5+
.git,
6+
__pycache__,
7+
.venv,
8+
venv,
9+
build,
10+
dist,
11+
*.egg-info
12+
per-file-ignores =
13+
__init__.py:F401

.github/workflows/ci.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
code-quality:
11+
name: Code Quality
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Cache pip dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install -e ".[dev]"
37+
38+
- name: Code formatting with Black
39+
run: |
40+
black --check --diff meshcore_mqtt/ tests/
41+
42+
- name: Linting with Flake8
43+
run: |
44+
flake8 meshcore_mqtt/ tests/
45+
46+
- name: Type checking with MyPy
47+
run: |
48+
mypy meshcore_mqtt/ tests/
49+
50+
- name: Import sorting with isort
51+
run: |
52+
isort --check-only --diff meshcore_mqtt/ tests/
53+
54+
test:
55+
name: Tests
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
python-version: ["3.11", "3.12"]
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Set up Python ${{ matrix.python-version }}
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
69+
- name: Cache pip dependencies
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.cache/pip
73+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }}
74+
restore-keys: |
75+
${{ runner.os }}-pip-
76+
77+
- name: Install dependencies
78+
run: |
79+
python -m pip install --upgrade pip
80+
pip install -e ".[dev]"
81+
82+
- name: Run tests with pytest
83+
run: |
84+
pytest -v --cov=meshcore_mqtt --cov-report=xml --cov-report=term-missing
85+
86+
- name: Upload coverage to Codecov
87+
uses: codecov/codecov-action@v3
88+
with:
89+
file: ./coverage.xml
90+
flags: unittests
91+
name: codecov-umbrella
92+
fail_ci_if_error: false
93+
94+
security:
95+
name: Security Scan
96+
runs-on: ubuntu-latest
97+
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- name: Set up Python
102+
uses: actions/setup-python@v5
103+
with:
104+
python-version: "3.12"
105+
106+
- name: Install dependencies
107+
run: |
108+
python -m pip install --upgrade pip
109+
pip install -e ".[dev]"
110+
111+
- name: Run Bandit security scan
112+
run: |
113+
bandit -r meshcore_mqtt/ -f json -o bandit-report.json || true
114+
bandit -r meshcore_mqtt/
115+
116+
# - name: Run Safety check
117+
# run: |
118+
# safety check --json --output safety-report.json || true
119+
# safety check
120+
121+
build-test:
122+
name: Build Test
123+
runs-on: ubuntu-latest
124+
125+
steps:
126+
- uses: actions/checkout@v4
127+
128+
- name: Set up Python
129+
uses: actions/setup-python@v5
130+
with:
131+
python-version: "3.12"
132+
133+
- name: Install build dependencies
134+
run: |
135+
python -m pip install --upgrade pip
136+
pip install build twine
137+
138+
- name: Build package
139+
run: |
140+
python -m build
141+
142+
- name: Check package
143+
run: |
144+
twine check dist/*
145+
146+
- name: Test installation
147+
run: |
148+
pip install dist/*.whl
149+
python -c "import meshcore_mqtt; print('Package installed successfully')"

.github/workflows/code-quality.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
lint:
11+
name: Lint and Format Check
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Cache pip dependencies
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.cache/pip
26+
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/requirements-dev.txt') }}
27+
restore-keys: |
28+
${{ runner.os }}-pip-lint-
29+
30+
- name: Install linting dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install black flake8 mypy isort bandit
34+
35+
- name: Check code formatting with Black
36+
run: |
37+
echo "::group::Black formatting check"
38+
black --check --diff --color meshcore_mqtt/ tests/
39+
echo "::endgroup::"
40+
41+
- name: Check import sorting with isort
42+
run: |
43+
echo "::group::Import sorting check"
44+
isort --check-only --diff meshcore_mqtt/ tests/
45+
echo "::endgroup::"
46+
47+
- name: Lint with Flake8
48+
run: |
49+
echo "::group::Flake8 linting"
50+
flake8 meshcore_mqtt/ tests/ --statistics
51+
echo "::endgroup::"
52+
53+
- name: Type check with MyPy
54+
run: |
55+
echo "::group::MyPy type checking"
56+
# Install package dependencies for type checking
57+
pip install -r requirements-dev.txt
58+
mypy meshcore_mqtt/ tests/
59+
echo "::endgroup::"
60+
61+
- name: Security check with Bandit
62+
run: |
63+
echo "::group::Bandit security scan"
64+
bandit -r meshcore_mqtt/ -ll
65+
echo "::endgroup::"
66+
67+
# - name: Dependency security check with Safety
68+
# run: |
69+
# echo "::group::Safety dependency check"
70+
# pip install -r requirements.txt
71+
# safety check
72+
# echo "::endgroup::"

0 commit comments

Comments
 (0)