mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 13:23:41 +00:00
Major restructuring of the scripts/ directory with consistent output
formatting, improved organization, and stricter error handling.
Breaking Changes:
- Updated development environment to Home Assistant 2025.7+
- Removed Python 3.12 compatibility (HA 2025.7+ requires Python 3.13)
- Updated all HA core requirements from 2025.7 requirement files
- Added new dependencies: python-multipart, uv (for faster package management)
- Updated GitHub Actions workflows to use Python 3.13
Changes:
- Created centralized output library (scripts/.lib/output.sh)
- Unified color codes and Unicode symbols
- Consistent formatting functions (log_header, log_success, log_error, etc.)
- Support for embedded formatting codes (${BOLD}, ${GREEN}, etc.)
- Reorganized into logical subdirectories:
- scripts/setup/ - Setup and maintenance scripts
- bootstrap: Install/update dependencies (used in CI/CD)
- setup: Full DevContainer setup (pyright, copilot, HACS)
- reset: Reset config/ directory to fresh state (NEW)
- sync-hacs: Sync HACS integrations
- scripts/release/ - Release management scripts
- prepare: Version bump and tagging
- suggest-version: Semantic version suggestion
- generate-notes: Release notes generation
- check-if-released: Check release status
- hassfest: Local integration validation
- Updated all scripts with:
- set -euo pipefail for stricter error handling
- Consistent SCRIPT_DIR pattern for reliable sourcing
- Professional output with colors and emojis
- Unified styling across all 17 scripts
- Removed redundant scripts:
- scripts/update (was just wrapper around bootstrap)
- scripts/json_schemas/ (moved to schemas/json/)
- Enhanced clean script:
- Improved artifact cleanup
- Better handling of accidental package installations
- Hints for reset and deep clean options
- New reset script features:
- Standard mode: Keep configuration.yaml
- Full mode (--full): Reset configuration.yaml from git
- Automatic re-setup after reset
- Updated documentation:
- AGENTS.md: Updated script references and workflow guidance
- docs/development/: Updated all references to new script structure
Impact: Development environment now requires Python 3.13 and Home Assistant
2025.7+. Developers get consistent, professional script output with better
error handling and logical organization. Single source of truth for styling
makes future updates trivial.
119 lines
3.9 KiB
Bash
Executable file
119 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# script/hassfest: Lightweight local validation for Home Assistant integration
|
|
#
|
|
# Performs basic validation checks on the integration structure: JSON syntax,
|
|
# required files, Python syntax, and translation consistency. Full hassfest
|
|
# validation runs in GitHub Actions.
|
|
#
|
|
# Usage:
|
|
# ./scripts/release/hassfest
|
|
#
|
|
# Examples:
|
|
# ./scripts/release/hassfest
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cd "$SCRIPT_DIR/../.."
|
|
|
|
# shellcheck source=scripts/.lib/output.sh
|
|
source "$SCRIPT_DIR/../.lib/output.sh"
|
|
|
|
INTEGRATION_PATH="custom_components/tibber_prices"
|
|
ERRORS=0
|
|
|
|
log_header "Running local integration validation"
|
|
echo ""
|
|
|
|
# Check 1: config_flow.py exists
|
|
printf "%b Checking config_flow.py existence...%b\n" "$BOLD" "$NC"
|
|
if [[ ! -f $INTEGRATION_PATH/config_flow.py ]]; then
|
|
log_result 1 "config_flow.py not found"
|
|
ERRORS=$((ERRORS + 1))
|
|
else
|
|
log_result 0 "config_flow.py exists"
|
|
fi
|
|
|
|
# Check 2: manifest.json syntax
|
|
printf "%b Checking manifest.json syntax...%b\n" "$BOLD" "$NC"
|
|
if ! python -m json.tool "$INTEGRATION_PATH/manifest.json" > /dev/null 2>&1; then
|
|
log_result 1 "manifest.json has invalid JSON syntax"
|
|
ERRORS=$((ERRORS + 1))
|
|
else
|
|
log_result 0 "manifest.json is valid JSON"
|
|
fi
|
|
|
|
# Check 3: Translation files syntax
|
|
printf "%b Checking translation files syntax...%b\n" "$BOLD" "$NC"
|
|
for lang_file in "$INTEGRATION_PATH"/translations/*.json; do
|
|
if [[ -f $lang_file ]]; then
|
|
lang=$(basename "$lang_file")
|
|
if ! python -m json.tool "$lang_file" > /dev/null 2>&1; then
|
|
log_result 1 "$lang has invalid JSON syntax"
|
|
ERRORS=$((ERRORS + 1))
|
|
else
|
|
log_result 0 "$lang is valid JSON"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# Check 4: Custom translation files syntax
|
|
if [[ -d $INTEGRATION_PATH/custom_translations ]]; then
|
|
printf "%b Checking custom translation files syntax...%b\n" "$BOLD" "$NC"
|
|
for lang_file in "$INTEGRATION_PATH"/custom_translations/*.json; do
|
|
if [[ -f $lang_file ]]; then
|
|
lang=$(basename "$lang_file")
|
|
if ! python -m json.tool "$lang_file" > /dev/null 2>&1; then
|
|
log_result 1 "custom_translations/$lang has invalid JSON syntax"
|
|
ERRORS=$((ERRORS + 1))
|
|
else
|
|
log_result 0 "custom_translations/$lang is valid JSON"
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Check 5: Python syntax
|
|
# Note: We use ast.parse() instead of py_compile to avoid creating __pycache__ artifacts
|
|
# ast.parse() validates syntax without writing any files to disk
|
|
printf "%b Checking Python syntax...%b\n" "$BOLD" "$NC"
|
|
PYTHON_ERRORS=0
|
|
find "$INTEGRATION_PATH" -name "*.py" -type f | while IFS= read -r py_file; do
|
|
if ! python -c "import ast; ast.parse(open('$py_file').read())" 2>/dev/null; then
|
|
log_result 1 "$py_file has syntax errors"
|
|
PYTHON_ERRORS=$((PYTHON_ERRORS + 1))
|
|
ERRORS=$((ERRORS + 1))
|
|
fi
|
|
done
|
|
if [[ $PYTHON_ERRORS -eq 0 ]]; then
|
|
log_result 0 "All Python files have valid syntax"
|
|
fi
|
|
|
|
# Check 6: Required manifest fields
|
|
printf "%b Checking required manifest fields...%b\n" "$BOLD" "$NC"
|
|
REQUIRED_FIELDS="domain name version documentation issue_tracker codeowners"
|
|
for field in $REQUIRED_FIELDS; do
|
|
if ! python -c "import json; data=json.load(open('$INTEGRATION_PATH/manifest.json')); exit(0 if '$field' in data else 1)" 2>/dev/null; then
|
|
log_result 1 "manifest.json missing required field: $field"
|
|
ERRORS=$((ERRORS + 1))
|
|
fi
|
|
done
|
|
if [[ $ERRORS -eq 0 ]]; then
|
|
log_result 0 "All required manifest fields present"
|
|
fi
|
|
|
|
echo ""
|
|
if [[ $ERRORS -eq 0 ]]; then
|
|
log_success "All local validation checks passed"
|
|
echo ""
|
|
log_info "Full hassfest validation runs in GitHub Actions."
|
|
log_step "Push your changes to run complete validation."
|
|
exit 0
|
|
else
|
|
log_error "Found $ERRORS error(s)"
|
|
echo ""
|
|
log_info "This is a simplified local validation."
|
|
log_step "Full hassfest validation runs in GitHub Actions."
|
|
exit 1
|
|
fi
|