Skip to content

Commit ebd7862

Browse files
committed
Refactor MQTT Discovery and Add System Entity Publishing
- Cleaned up includes in mqttDiscovery.cpp and organized them. - Added new function `publishSystemEntities()` to publish various system-related entities such as connectivity, uptime, memory, and IP. - Implemented a restart button and an erase credentials button for system management. - Updated the main MQTT discovery function to call the new system entities publishing function. - Introduced unit testing framework using Google Test and Google Mock. - Created test runner for unit tests and added initial dummy tests. - Added comprehensive unit tests for `HassValidators` to validate device classes and measurement units. - Implemented coverage report generation script for test coverage analysis. - Removed outdated test file `test_hass_discovery.cpp`. - Updated platformio.ini to include configurations for testing environments. Add unit tests for HassValidators to validate device classes and measurement units Add unit tests for HassEntity and HassTopicBuilder - Implemented comprehensive unit tests for the HassEntity class, covering entity configuration, publishing, and JSON generation. - Created a mock for IMqttPublisher and ISettingsProvider to facilitate testing. - Added tests for various scenarios including valid and invalid configurations, discovery topic generation, and MQTT publishing behavior. - Developed unit tests for the HassTopicBuilder class, ensuring correct topic construction for discovery, state, command, and availability topics. - Included edge case handling and performance tests for both classes. Refactor GitHub Actions workflow and enhance test documentation for HMD module Refactor unit tests for HassValidators - Organized and structured the test cases for device classes and measurement units. - Added tests for valid and invalid device classes, including edge cases. - Included tests for measurement units, ensuring correct validation and handling of special cases. - Verified performance of validation methods with a quick test. - Ensured consistency in counts of valid device classes and units. - Enhanced readability and maintainability of the test code.
1 parent 9004fda commit ebd7862

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4291
-2217
lines changed
Lines changed: 139 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,139 @@
1-
name: 🚀 Custom Release Build
2-
3-
on:
4-
push:
5-
tags:
6-
- "v*-o*" # Matches tags like v1.8.0-o1, v1.8.1-o2, etc.
7-
workflow_dispatch:
8-
inputs:
9-
version_type:
10-
description: "Version bump type"
11-
required: true
12-
default: "patch"
13-
type: choice
14-
options:
15-
- patch
16-
- minor
17-
- major
18-
19-
env:
20-
CUSTOM_SUFFIX: "o"
21-
22-
jobs:
23-
version-bump:
24-
if: github.event_name == 'workflow_dispatch'
25-
runs-on: ubuntu-latest
26-
outputs:
27-
new_version: ${{ steps.bump.outputs.new_version }}
28-
steps:
29-
- uses: actions/checkout@v4
30-
with:
31-
token: ${{ secrets.GITHUB_TOKEN }}
32-
fetch-depth: 0
33-
34-
- name: Setup PowerShell
35-
shell: pwsh
36-
run: |
37-
# Install required modules if needed
38-
Write-Host "PowerShell setup complete"
39-
40-
- name: Bump Version
41-
id: bump
42-
shell: pwsh
43-
run: |
44-
$newVersion = .\scripts\version-manager.ps1 ${{ github.event.inputs.version_type }}
45-
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
46-
47-
- name: Commit and Push
48-
run: |
49-
git config --local user.email "[email protected]"
50-
git config --local user.name "GitHub Action"
51-
git push origin HEAD:${{ github.ref_name }}
52-
53-
build:
54-
needs: [version-bump]
55-
if: always() && !cancelled()
56-
runs-on: ubuntu-latest
57-
strategy:
58-
matrix:
59-
environment:
60-
- esp32dev-all-test
61-
- esp32-theengs-bridge
62-
- esp8266-rf
63-
64-
steps:
65-
- uses: actions/checkout@v4
66-
with:
67-
fetch-depth: 0
68-
69-
- name: Cache pip
70-
uses: actions/cache@v4
71-
with:
72-
path: ~/.cache/pip
73-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
74-
75-
- name: Cache PlatformIO
76-
uses: actions/cache@v4
77-
with:
78-
path: ~/.platformio
79-
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
80-
81-
- name: Set up Python
82-
uses: actions/setup-python@v5
83-
with:
84-
python-version: "3.11"
85-
86-
- name: Install PlatformIO
87-
run: |
88-
python -m pip install --upgrade pip
89-
pip install --upgrade platformio
90-
91-
- name: Build firmware
92-
run: pio run -e ${{ matrix.environment }}
93-
94-
- name: Run tests
95-
run: pio test -e test
96-
97-
- name: Upload artifacts
98-
uses: actions/upload-artifact@v4
99-
with:
100-
name: firmware-${{ matrix.environment }}
101-
path: .pio/build/${{ matrix.environment }}/firmware.*
102-
103-
release:
104-
needs: [build]
105-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
106-
runs-on: ubuntu-latest
107-
steps:
108-
- uses: actions/checkout@v4
109-
110-
- name: Download artifacts
111-
uses: actions/download-artifact@v4
112-
with:
113-
path: artifacts
114-
115-
- name: Create Release
116-
uses: softprops/action-gh-release@v1
117-
with:
118-
files: artifacts/**/*
119-
body: |
120-
## Custom OpenMQTTGateway Build ${{ github.ref_name }}
121-
122-
### Features
123-
- Custom RF signal filtering
124-
- Enhanced BLE connectivity
125-
- Optimized for specific hardware configurations
126-
127-
### Changes
128-
- Based on upstream OpenMQTTGateway
129-
- Custom modifications for enhanced performance
130-
131-
### Installation
132-
1. Download the appropriate firmware for your board
133-
2. Flash using your preferred method (OTA, esptool, etc.)
134-
135-
### Support
136-
For issues specific to these custom builds, please open an issue in this repository.
137-
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') }}
138-
env:
139-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1+
name: 🚀 Custom Release Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*-o*" # Matches tags like v1.8.0-o1, v1.8.1-o2, etc.
7+
workflow_dispatch:
8+
inputs:
9+
version_type:
10+
description: "Version bump type"
11+
required: true
12+
default: "patch"
13+
type: choice
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
19+
env:
20+
CUSTOM_SUFFIX: "o"
21+
22+
jobs:
23+
version-bump:
24+
if: github.event_name == 'workflow_dispatch'
25+
runs-on: ubuntu-latest
26+
outputs:
27+
new_version: ${{ steps.bump.outputs.new_version }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
fetch-depth: 0
33+
34+
- name: Setup PowerShell
35+
shell: pwsh
36+
run: |
37+
# Install required modules if needed
38+
Write-Host "PowerShell setup complete"
39+
40+
- name: Bump Version
41+
id: bump
42+
shell: pwsh
43+
run: |
44+
$newVersion = .\scripts\version-manager.ps1 ${{ github.event.inputs.version_type }}
45+
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
46+
47+
- name: Commit and Push
48+
run: |
49+
git config --local user.email "[email protected]"
50+
git config --local user.name "GitHub Action"
51+
git push origin HEAD:${{ github.ref_name }}
52+
53+
build:
54+
needs: [version-bump]
55+
if: always() && !cancelled()
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
environment:
60+
- esp32dev-all-test
61+
- esp32-theengs-bridge
62+
- esp8266-rf
63+
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Cache pip
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.cache/pip
73+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
74+
75+
- name: Cache PlatformIO
76+
uses: actions/cache@v4
77+
with:
78+
path: ~/.platformio
79+
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
80+
81+
- name: Set up Python
82+
uses: actions/setup-python@v5
83+
with:
84+
python-version: "3.11"
85+
86+
- name: Install PlatformIO
87+
run: |
88+
python -m pip install --upgrade pip
89+
pip install --upgrade platformio
90+
91+
- name: Build firmware
92+
run: pio run -e ${{ matrix.environment }}
93+
94+
- name: Run tests
95+
run: pio test -e test
96+
97+
- name: Upload artifacts
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: firmware-${{ matrix.environment }}
101+
path: .pio/build/${{ matrix.environment }}/firmware.*
102+
103+
release:
104+
needs: [build]
105+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- name: Download artifacts
111+
uses: actions/download-artifact@v4
112+
with:
113+
path: artifacts
114+
115+
- name: Create Release
116+
uses: softprops/action-gh-release@v1
117+
with:
118+
files: artifacts/**/*
119+
body: |
120+
## Custom OpenMQTTGateway Build ${{ github.ref_name }}
121+
122+
### Features
123+
- Custom RF signal filtering
124+
- Enhanced BLE connectivity
125+
- Optimized for specific hardware configurations
126+
127+
### Changes
128+
- Based on upstream OpenMQTTGateway
129+
- Custom modifications for enhanced performance
130+
131+
### Installation
132+
1. Download the appropriate firmware for your board
133+
2. Flash using your preferred method (OTA, esptool, etc.)
134+
135+
### Support
136+
For issues specific to these custom builds, please open an issue in this repository.
137+
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') }}
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/run-tests.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 🧪 Run Tests
2+
3+
on:
4+
push:
5+
branches: [main, development, feature/*]
6+
pull_request:
7+
branches: [main, development]
8+
9+
jobs:
10+
native-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.11"
17+
- name: Install PlatformIO
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install platformio
21+
- name: Run Native Tests
22+
run: pio test -e test
23+
- name: Test Results Summary
24+
if: always()
25+
run: |
26+
echo "Test execution completed"
27+
echo "Check the logs above for detailed results"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lib/*
1010
!lib/esp32-bt-lib
1111
!lib/TheengsUtils
1212
!lib/LEDManager
13+
1314
CMakeLists.txt
1415
dependencies.lock
1516
sdkconfig.*

0 commit comments

Comments
 (0)