mirror of
https://github.com/ipnet-mesh/meshcore-mqtt.git
synced 2026-05-08 06:14:39 +02:00
134 lines
3.9 KiB
YAML
134 lines
3.9 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
test:
|
|
name: Test Suite
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
python-version: ["3.11", "3.12"]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Cache pip dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/pip
|
|
~/.local/share/virtualenvs
|
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-${{ matrix.python-version }}-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-dev.txt
|
|
|
|
- name: Run tests with pytest
|
|
run: |
|
|
pytest -v --tb=short --cov=meshcore_mqtt --cov-report=xml --cov-report=term-missing --cov-report=html
|
|
|
|
- name: Generate coverage report
|
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
run: |
|
|
echo "## Test Coverage Report" >> $GITHUB_STEP_SUMMARY
|
|
echo "```" >> $GITHUB_STEP_SUMMARY
|
|
coverage report --show-missing >> $GITHUB_STEP_SUMMARY
|
|
echo "```" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
file: ./coverage.xml
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|
|
|
|
- name: Archive coverage reports
|
|
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: htmlcov/
|
|
|
|
- name: Test CLI functionality
|
|
run: |
|
|
# Test CLI help
|
|
python -m meshcore_mqtt.main --help
|
|
|
|
# Test version info (if available)
|
|
python -c "import meshcore_mqtt; print('Package version check passed')"
|
|
|
|
test-examples:
|
|
name: Test Configuration Examples
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install pyyaml
|
|
|
|
- name: Validate JSON configuration examples
|
|
run: |
|
|
python -c "
|
|
import json
|
|
with open('config.example.json', 'r') as f:
|
|
config = json.load(f)
|
|
print('✓ config.example.json is valid JSON')
|
|
print(f'✓ Contains {len(config)} top-level keys')
|
|
"
|
|
|
|
- name: Validate YAML configuration examples
|
|
run: |
|
|
python -c "
|
|
import yaml
|
|
with open('config.example.yaml', 'r') as f:
|
|
config = yaml.safe_load(f)
|
|
print('✓ config.example.yaml is valid YAML')
|
|
print(f'✓ Contains {len(config)} top-level keys')
|
|
"
|
|
|
|
- name: Test configuration loading
|
|
run: |
|
|
python -c "
|
|
from meshcore_mqtt.config import Config
|
|
|
|
# Test JSON config loading
|
|
config_json = Config.from_file('config.example.json')
|
|
print('✓ JSON configuration loads successfully')
|
|
print(f'✓ MQTT broker: {config_json.mqtt.broker}')
|
|
print(f'✓ Events configured: {len(config_json.meshcore.events)}')
|
|
|
|
# Test YAML config loading
|
|
config_yaml = Config.from_file('config.example.yaml')
|
|
print('✓ YAML configuration loads successfully')
|
|
print(f'✓ MQTT broker: {config_yaml.mqtt.broker}')
|
|
print(f'✓ Events configured: {len(config_yaml.meshcore.events)}')
|
|
"
|