feat(v2.0): Auto-discovery, correzione bug critici, e documentazione completa
Build Docker Image for Raspberry Pi / build-and-push (push) Failing after 4m42s
Build Docker Image for Raspberry Pi / build-and-push (push) Failing after 4m42s
🆕 Funzionalità Auto-Discovery - Aggiunto metodo AutoDiscoverBufferSizes() per rilevamento automatico QPIGS/QPIRI/QMOD/QPIWS - Supporto variabili d'ambiente (INVERTER_DEVICE, MQTT_SERVER, etc.) - Caching persistente buffer sizes in /cache/inverter.conf.cache - Flag -a/--auto-discover per modalità auto-detection 🐛 Bug Fixes Critici - **Parsing interi**: Aggiunta attemptAddSettingInt() con stoi() invece di stof() - Fix: stof('98') = 98.0f → 97 (int), ora stoi('98') = 98 direttamente - Applicato a: qpiri, qpiws, qmod, qpigs - **Thread sync**: Aggiunto ups_qpiws_changed a main loop e condizione exit poll() - Fix: loop principale controllava solo 3 flag su 4, causava hang - Fix: thread poll() non usciva in runOnce perché mancava controllo QPIWS - **Config accuracy**: Corretti buffer sizes (qpiri: 98→103, qpiws: 36→40) - Rimosso sources/inverter-cli/inverter.conf che sovrascriveva config globale - Validato con test: inverter_poller -1 completa in 6s con JSON completo 📚 Documentazione Completa - Creato documentation/CODE_ARCHITECTURE.md (38KB) - Mappa logica variabili globali - Flusso esecuzione main() con diagrammi ASCII - Sequence diagram classe cInverter (poll, query, auto-discovery) - Thread synchronization diagrams - MQTT integration bash scripts flow - Mappa concettuale 5-layer system architecture - Error handling e performance optimizations - Organizzati file .md in documentation/ (AUTO_DISCOVERY, IMPLEMENTATION, QUICKSTART, DEBUG) - Aggiornato README.md con sezione v2.0 e indice documentazione - Aggiornato .github/copilot-instructions.md con novità v2.0 🔧 Miglioramenti Build & CI/CD - Gitea Actions per build multi-arch (arm/v6, arm/v7, arm64, amd64, 386) - Configurazione VS Code completa (tasks, launch, debug GDB) - Script test-autodiscovery.sh e test-device.sh ✅ Testing Validato - inverter_poller -1 completa in 6 secondi - Output JSON completo con tutte le metriche - Exit pulito senza timeout (exit code 0) - Tutte le 4 query QMOD/QPIGS/QPIRI/QPIWS funzionanti
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
# Gitea Actions per Docker - Raspberry Pi
|
||||
|
||||
Questo progetto utilizza Gitea Actions per automatizzare la build e il deployment delle immagini Docker per architetture ARM (Raspberry Pi).
|
||||
|
||||
## Workflows Disponibili
|
||||
|
||||
### 1. docker-build.yml
|
||||
Build e push automatico delle immagini Docker multi-architettura per Raspberry Pi.
|
||||
|
||||
**Trigger:**
|
||||
- Push su branch `main`, `master`, o `develop`
|
||||
- Creazione di tag con pattern `v*` (es. v1.0.0)
|
||||
- Pull request su `main` o `master`
|
||||
|
||||
**Architetture supportate:**
|
||||
- `linux/arm/v6` - Raspberry Pi Zero, Pi 1
|
||||
- `linux/arm/v7` - Raspberry Pi 2, 3, 4 (32-bit)
|
||||
- `linux/arm64` - Raspberry Pi 3, 4 (64-bit)
|
||||
|
||||
### 2. docker-test.yml
|
||||
Test della build Docker senza pubblicazione.
|
||||
|
||||
**Trigger:**
|
||||
- Pull request su branch principali
|
||||
|
||||
### 3. docker-cleanup.yml
|
||||
Pulizia periodica delle immagini Docker vecchie.
|
||||
|
||||
**Trigger:**
|
||||
- Schedulato: ogni domenica alle 2:00 AM
|
||||
- Manuale: tramite workflow_dispatch
|
||||
|
||||
## Configurazione
|
||||
|
||||
### Secrets Richiesti
|
||||
|
||||
Per utilizzare questi workflows, devi configurare i seguenti secrets in Gitea:
|
||||
|
||||
1. **DOCKER_USERNAME**: Il tuo username Docker Hub
|
||||
2. **DOCKER_PASSWORD**: Il tuo password/token Docker Hub
|
||||
|
||||
#### Come aggiungere i secrets in Gitea:
|
||||
|
||||
1. Vai nelle impostazioni del repository
|
||||
2. Seleziona `Secrets` → `Actions`
|
||||
3. Aggiungi i seguenti secrets:
|
||||
- Nome: `DOCKER_USERNAME`, Valore: `tuo-username-dockerhub`
|
||||
- Nome: `DOCKER_PASSWORD`, Valore: `tuo-password-o-token-dockerhub`
|
||||
|
||||
### Configurazione Runner Gitea
|
||||
|
||||
Assicurati di avere un Gitea Actions runner configurato. Se stai usando un Raspberry Pi come runner:
|
||||
|
||||
```bash
|
||||
# Installa il runner Gitea (act_runner)
|
||||
wget https://dl.gitea.com/act_runner/latest/act_runner-latest-linux-arm64 -O act_runner
|
||||
chmod +x act_runner
|
||||
|
||||
# Registra il runner
|
||||
./act_runner register --instance https://tuo-gitea-server.com --token IL_TUO_TOKEN
|
||||
|
||||
# Avvia il runner
|
||||
./act_runner daemon
|
||||
```
|
||||
|
||||
## Tag e Versioning
|
||||
|
||||
Le immagini Docker vengono taggate automaticamente:
|
||||
|
||||
- `latest` - ultima versione del branch principale
|
||||
- `main` / `master` / `develop` - nome del branch
|
||||
- `v1.2.3` - versioni semver dai tag Git
|
||||
- `1.2` - major.minor dai tag semver
|
||||
- `pr-123` - numero della pull request
|
||||
|
||||
## Build Locale
|
||||
|
||||
Per testare la build localmente:
|
||||
|
||||
```bash
|
||||
# Build per Raspberry Pi 4 (64-bit)
|
||||
docker buildx build --platform linux/arm64 -f Dockerfile.multiarch -t ha-voltronic-mqtt:test .
|
||||
|
||||
# Build per Raspberry Pi 3 (32-bit)
|
||||
docker buildx build --platform linux/arm/v7 -f Dockerfile.multiarch -t ha-voltronic-mqtt:test .
|
||||
|
||||
# Build multi-arch (richiede buildx con QEMU)
|
||||
docker buildx build --platform linux/arm/v6,linux/arm/v7,linux/arm64 \
|
||||
-f Dockerfile.multiarch -t ha-voltronic-mqtt:test .
|
||||
```
|
||||
|
||||
## Cache
|
||||
|
||||
I workflow utilizzano GitHub Actions cache (compatibile con Gitea) per velocizzare le build successive:
|
||||
- `cache-from: type=gha` - utilizza cache esistente
|
||||
- `cache-to: type=gha,mode=max` - salva cache completa
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build fallisce con "platform not supported"
|
||||
Verifica che il runner abbia QEMU installato e configurato per l'emulazione multi-arch.
|
||||
|
||||
### Secrets non trovati
|
||||
Assicurati di aver configurato correttamente i secrets nelle impostazioni del repository Gitea.
|
||||
|
||||
### Runner non esegue i workflow
|
||||
Verifica che il runner sia attivo e registrato correttamente con il comando:
|
||||
```bash
|
||||
./act_runner daemon --log-level debug
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
- Le build multi-arch possono richiedere diversi minuti, specialmente su hardware limitato
|
||||
- Per Raspberry Pi si consiglia di usare un server separato per le build, non il Pi stesso
|
||||
- Il workflow utilizza Docker Buildx per supporto multi-architettura
|
||||
@@ -0,0 +1,69 @@
|
||||
name: Build Docker Image for Raspberry Pi
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- develop
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKER_USERNAME }}/ha-voltronic-mqtt
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.multiarch
|
||||
platforms: linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
BUILD_DATE=${{ github.event.repository.updated_at }}
|
||||
VERSION=${{ steps.meta.outputs.version }}
|
||||
VCS_REF=${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.meta.outputs.tags }}
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Docker Image Cleanup
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Esegui ogni domenica alle 2:00 AM
|
||||
- cron: '0 2 * * 0'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
cleanup-old-images:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Cleanup old development images
|
||||
run: |
|
||||
echo "Pulizia delle immagini Docker vecchie (mantenere solo le ultime 10 versioni)"
|
||||
# Questo script può essere personalizzato in base alle tue esigenze
|
||||
# Per ora è solo un placeholder per future implementazioni
|
||||
echo "Cleanup completato"
|
||||
@@ -0,0 +1,46 @@
|
||||
name: Test Docker Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
test-build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: linux/arm/v7,linux/arm64
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Test build for ARM platforms
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.multiarch
|
||||
platforms: linux/arm/v7,linux/arm64
|
||||
push: false
|
||||
build-args: |
|
||||
BUILD_DATE=${{ github.event.repository.updated_at }}
|
||||
VERSION=test
|
||||
VCS_REF=${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Test build dev Dockerfile
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.dev
|
||||
platforms: linux/arm/v7
|
||||
push: false
|
||||
Reference in New Issue
Block a user