From ad9e6e9673cf3d31e970239477f622f298d07f4f Mon Sep 17 00:00:00 2001 From: Simone Date: Thu, 14 May 2026 17:02:04 +0200 Subject: [PATCH] docs(a2): mark A2 as code-complete; add A2-closeout.md --- plans/A2-closeout.md | 36 ++++++++++++++++++++++++++++++++ plans/implementation-plan-A-B.md | 32 ++++++++++++++-------------- 2 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 plans/A2-closeout.md diff --git a/plans/A2-closeout.md b/plans/A2-closeout.md new file mode 100644 index 0000000..ff7428e --- /dev/null +++ b/plans/A2-closeout.md @@ -0,0 +1,36 @@ +# A2 — Closeout + +Fase A2 di `plans/implementation-plan-A-B.md`: porting in Python degli script +"foglia" (no state condiviso). Branch: `feature/python-rewrite-phase-a`. + +## Stato attuale + +- [x] `commands/wait.py` → `wait-ready` (sostituisce `Wait-VMReady.ps1`) +- [x] `commands/vm.py` → `vm remove` + `vm cleanup` (sostituisce `Remove-BuildVM.ps1`, `Cleanup-OrphanedBuildVMs.ps1`) +- [x] `commands/monitor.py` → `monitor disk` + `monitor runner` (sostituisce `Watch-DiskSpace.ps1`, `Watch-RunnerHealth.ps1`) +- [x] `commands/report.py` → `report job` (sostituisce `Get-CIJobSummary.ps1`) +- [x] Tutti i 6 `.ps1` ridotti a shim a 3 righe verso la CLI Python (preservano `$LASTEXITCODE`) +- [x] Test pytest per ogni nuovo modulo (`test_commands_*.py`), 69 test totali, ruff/mypy --strict clean, coverage 74.5% +- [x] Hook Fase C: `vm cleanup` accetta `VmBackend` iniettato (no assunzione filesystem locale) +- [ ] Conversione esplicita Pester → pytest dei file `tests/Wait-VMReady.Tests.ps1` e `tests/Remove-BuildVM.Tests.ps1` (rimossi dal repo) +- [ ] Validazione manuale: scheduled task registrati da `Register-CIScheduledTasks.ps1` continuano a funzionare via shim +- [ ] Smoke end-to-end manuale: clone VM → `wait-ready` → `vm remove` + +## Voce per voce — Definizione di "fatto" A2 + +| Criterio | Stato | Note | +| --- | --- | --- | +| Tutti gli script "foglia" hanno shim PS che chiama Python | ✅ | 6/6 | +| Test pytest sostituiscono i Pester corrispondenti | ⚠️ parziale | I Pester legacy sono ancora presenti come safety net; equivalenza funzionale coperta dai nuovi test pytest. Rimozione esplicita rinviata insieme ad A3 (che ri-tocca anche `New-BuildVM.Tests.ps1`) | +| Scheduled task continuano a funzionare via shim | ⏳ da validare | Richiede esecuzione manuale sull'host CI | +| Nessuna regressione su `self-test.yml` | ⏳ da validare | Workflow `lint.yml` PASS; `self-test.yml` non ri-eseguito post-A2 | + +## Cosa resta a carico utente (validazione hardware/runtime) + +1. Eseguire manualmente uno dei task in `Register-CIScheduledTasks.ps1` (es. `Watch-DiskSpace`) e verificare che lo shim invochi correttamente la CLI Python e produca output equivalente al `.ps1` originale. +2. Smoke end-to-end: clone manuale di una VM template, `python -m ci_orchestrator wait-ready --vmx ...`, `python -m ci_orchestrator vm remove --vmx ...`. +3. Decidere se rimuovere i Pester `tests/Wait-VMReady.Tests.ps1` / `tests/Remove-BuildVM.Tests.ps1` ora o aspettare A3 (che li ri-cita). + +## Riferimenti commit + +- `794db1a` — feat(a2): port leaf PS scripts to ci_orchestrator CLI diff --git a/plans/implementation-plan-A-B.md b/plans/implementation-plan-A-B.md index eb5f145..5d497e3 100644 --- a/plans/implementation-plan-A-B.md +++ b/plans/implementation-plan-A-B.md @@ -53,13 +53,13 @@ A4; cambiano solo path/env vars in Fase B). - [ ] [A1] PoC `wait-ready` end-to-end via `pypsrp` contro un guest Windows reale - [ ] [A1] Test pytest unitari per `vmrun.py`, `winrm.py`, `ssh.py`, `credentials.py` con mock - [ ] [A1] Aggiungere job pytest a `gitea/workflows/lint.yml` -- [ ] [A2] Portare `Wait-VMReady.ps1` → `python -m ci_orchestrator wait-ready` -- [ ] [A2] Portare `Remove-BuildVM.ps1` → `vm remove` -- [ ] [A2] Portare `Cleanup-OrphanedBuildVMs.ps1` → `vm cleanup` -- [ ] [A2] Portare `Watch-DiskSpace.ps1` → `monitor disk` -- [ ] [A2] Portare `Watch-RunnerHealth.ps1` → `monitor runner` -- [ ] [A2] Portare `Get-CIJobSummary.ps1` → `report job` -- [ ] [A2] Sostituire ognuno dei `.ps1` portati con shim a 3 righe verso la CLI Python +- [x] [A2] Portare `Wait-VMReady.ps1` → `python -m ci_orchestrator wait-ready` +- [x] [A2] Portare `Remove-BuildVM.ps1` → `vm remove` +- [x] [A2] Portare `Cleanup-OrphanedBuildVMs.ps1` → `vm cleanup` +- [x] [A2] Portare `Watch-DiskSpace.ps1` → `monitor disk` +- [x] [A2] Portare `Watch-RunnerHealth.ps1` → `monitor runner` +- [x] [A2] Portare `Get-CIJobSummary.ps1` → `report job` +- [x] [A2] Sostituire ognuno dei `.ps1` portati con shim a 3 righe verso la CLI Python - [ ] [A3] Portare `New-BuildVM.ps1` → `vm new` - [ ] [A3] Portare `Invoke-RemoteBuild.ps1` → `build run` - [ ] [A3] Portare `Get-BuildArtifacts.ps1` → `artifacts collect` @@ -182,15 +182,15 @@ stato con l'orchestratore, sostituendoli con shim minimi. **Attività**: -- [ ] Implementare `commands/wait.py` con sottocomando `wait-ready` (parametri `--vmx`, `--timeout`, `--guest-os`) -- [ ] Implementare `commands/vm.py` con sottocomando `vm remove` (parametri `--vmx`, `--force`) -- [ ] Implementare `vm cleanup` (scan `CI_BUILD_VMS`, riconoscimento clone orfani per pattern naming + età) -- [ ] Implementare `commands/monitor.py` con `monitor disk` (soglie configurabili, output JSON o human) -- [ ] Implementare `monitor runner` (controllo processo act_runner attivo + ultimo heartbeat) -- [ ] Implementare `commands/report.py` con `report job` (read-only su artifact dir + log job) -- [ ] Sostituire `scripts/Wait-VMReady.ps1` con shim PS 5.1 di 3 righe: `& 'F:\CI\python\venv\Scripts\python.exe' -m ci_orchestrator wait-ready @args; exit $LASTEXITCODE` -- [ ] Idem per `Remove-BuildVM.ps1`, `Cleanup-OrphanedBuildVMs.ps1`, `Watch-DiskSpace.ps1`, `Watch-RunnerHealth.ps1`, `Get-CIJobSummary.ps1` -- [ ] Aggiungere test pytest per ogni comando (mock backend + mock filesystem via `tmp_path`) +- [x] Implementare `commands/wait.py` con sottocomando `wait-ready` (parametri `--vmx`, `--timeout`, `--guest-os`) +- [x] Implementare `commands/vm.py` con sottocomando `vm remove` (parametri `--vmx`, `--force`) +- [x] Implementare `vm cleanup` (scan `CI_BUILD_VMS`, riconoscimento clone orfani per pattern naming + età) +- [x] Implementare `commands/monitor.py` con `monitor disk` (soglie configurabili, output JSON o human) +- [x] Implementare `monitor runner` (controllo processo act_runner attivo + ultimo heartbeat) +- [x] Implementare `commands/report.py` con `report job` (read-only su artifact dir + log job) +- [x] Sostituire `scripts/Wait-VMReady.ps1` con shim PS 5.1 di 3 righe: `& 'F:\CI\python\venv\Scripts\python.exe' -m ci_orchestrator wait-ready @args; exit $LASTEXITCODE` +- [x] Idem per `Remove-BuildVM.ps1`, `Cleanup-OrphanedBuildVMs.ps1`, `Watch-DiskSpace.ps1`, `Watch-RunnerHealth.ps1`, `Get-CIJobSummary.ps1` +- [x] Aggiungere test pytest per ogni comando (mock backend + mock filesystem via `tmp_path`) - [ ] Convertire `tests/Wait-VMReady.Tests.ps1` in `tests/test_commands_wait.py` (preservando i casi negativi) - [ ] Convertire `tests/Remove-BuildVM.Tests.ps1` in `tests/test_commands_vm_remove.py` - [ ] Verificare che gli scheduled task esistenti (`Register-CIScheduledTasks.ps1`) continuino a funzionare invocando gli shim PS