P3 done: workflow-example.yml usa composite action (generalizzazione per altri repo)

Riscritta gitea/workflow-example.yml per usare la composite action
Simone/local-ci-system/.gitea/actions/local-ci-build@main invece della
chiamata diretta a Invoke-CIJob.ps1.

Commenti inline guidano la personalizzazione per ogni repo:
- build-command e artifact-source (unici campi obbligatori da adattare)
- submodules, repo-url, use-git-clone (opzionali)
- extra-guest-env-json per secret injection (chiavi di firma, GPG)
- artifact-name personalizzato (e.g. con ref_name per tag build)

Aggiunge workflow_dispatch per trigger manuale.
Rimossa logica di orchestrazione inline: zero duplicazione tra repo.
TODO.md: Gitea Workflow Integration chiuso (5/5).
This commit is contained in:
Simone
2026-05-11 22:38:54 +02:00
parent 7d12dedddd
commit 6511d47a9a
2 changed files with 40 additions and 57 deletions
+6 -3
View File
@@ -31,7 +31,7 @@ _Last updated: 2026-05-11 (post Sprint 14: §6.4+§6.5 DONE — build-nsis.yml m
| [x] | Template VM (Fasi A→D) | 4 | 0 | Snapshot `BaseClean` preso, credenziali in Credential Manager |
| [x] | Scripts Verification | 3 | 0 | e2e-008/009 SUCCESS, cleanup orfani + retry deleteVM ok |
| [x] | Runner Configuration | 2 | 0 | `config.yaml`, capacity 4, `BuildVMGuest` |
| [ ] | Gitea Workflow Integration | 4 | 1 | manca solo §P3 generalizzazione workflow |
| [x] | Gitea Workflow Integration | 5 | 0 | tutti completati — example.yml usa composite action |
| [x] | §1 Sicurezza & hardening | 3 | 0 | 1.1, 1.4, 1.6 done; 1.2/1.3/1.5/1.7/1.8 deferred (home lab) |
| [x] | §2 Affidabilità & resilienza | 7 | 0 | tutto done (2.1-2.7) |
| [x] | §3 Performance & throughput | 4 | 0 | 3.1/3.2/3.3/3.6 done; 3.4/3.5 deferred — **§3 CHIUSO** |
@@ -173,8 +173,11 @@ _Last updated: 2026-05-11 (post Sprint 14: §6.4+§6.5 DONE — build-nsis.yml m
- [x] Push commit e verificare job in Gitea Actions UI
- [x] Verificare artifact scaricabile da Gitea dopo build riuscita
- [x] `gitea/workflows/lint.yml` creato — PSScriptAnalyzer su push/PR che toccano `.ps1` (2026-05-09)
- [ ] **[P3] Adattare workflow per altri repository** — generalizzare `BUILD_COMMAND` e `ARTIFACT_SOURCE`.
Vedi anche §6.2 (composite action riutilizzabile).
- [x] **[P3] Adattare workflow per altri repository** — generalizzare `BUILD_COMMAND` e `ARTIFACT_SOURCE`.
COMPLETATO 2026-05-11: `gitea/workflow-example.yml` riscritto per usare la composite action
`Simone/local-ci-system/.gitea/actions/local-ci-build@main`. Commenti inline guidano
la personalizzazione di `build-command`, `artifact-source`, submodules, SSH URL,
`extra-guest-env-json` e `artifact-name`. Nessuna logica di orchestrazione nei repo chiamanti.
---
+34 -54
View File
@@ -1,11 +1,20 @@
# Gitea Actions workflow: .NET build with ephemeral VMware VM
# Gitea Actions workflow — generic build template using the composite action.
# Copy this file to: .gitea/workflows/build.yml in your repository.
#
# This workflow triggers on push to main/develop and on pull requests.
# It routes the job to the act_runner with label "windows-build",
# which creates an isolated VM per build.
# Adapt the two fields below to your project:
# build-command : the command to run inside the ephemeral VM
# artifact-source : the directory inside the VM where outputs are placed
#
# Runner label selects the guest OS automatically:
# windows-build -> WinBuild2025 (WinRM/HTTPS transport)
# linux-build -> LinuxBuild2404 (SSH transport)
#
# The composite action (Simone/local-ci-system/.gitea/actions/local-ci-build)
# handles the full VM lifecycle: clone template -> start -> build ->
# collect artifacts -> upload to Gitea -> destroy VM.
# No orchestration logic needed in each repo's workflow.
name: Build (.NET / MSBuild)
name: Build (Local CI)
on:
push:
@@ -17,67 +26,38 @@ on:
branches:
- main
- develop
workflow_dispatch:
jobs:
build:
# Must match the runner label defined in runner/config.yaml
# Change to linux-build for Ubuntu 24.04 guest
runs-on: windows-build
# Job-level timeout (should be less than the runner's timeout setting)
timeout-minutes: 90
env:
# Override these per-repository or in Gitea's repository secrets
# GITEA_CI_TEMPLATE_PATH is injected by runner/config.yaml global envs
# GITEA_CI_CLONE_BASE_DIR is injected by runner/config.yaml global envs
# Gitea Credential Manager target (set in runner/config.yaml)
# The VM IP is auto-detected via vmrun getGuestIPAddress — no BUILD_VM_IP needed.
GUEST_CRED_TARGET: "BuildVMGuest"
steps:
# Step 1: Check out the repository on the RUNNER HOST
# (This gives the runner access to the scripts/ directory)
- name: Checkout
uses: actions/checkout@v4
# ── Invoke the full VM lifecycle via composite action ───────────────────
- uses: Simone/local-ci-system/.gitea/actions/local-ci-build@main
with:
fetch-depth: 1
# --- adapt these two per-repository -----------------------------------
build-command: 'python build.py --dist-dir dist' # command run in VM
artifact-source: 'dist' # output dir in VM
# ----------------------------------------------------------------------
# Step 2: Invoke the orchestrator script
# This script handles the entire VM lifecycle:
# clone → start → wait ready → build → collect artifacts → destroy
- name: Build in ephemeral VM
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
# Uncomment to clone repo with submodules inside the VM:
# submodules: 'true'
# CI scripts are at a fixed location on the runner host.
# Do NOT use $env:GITHUB_WORKSPACE — the CI system is in a separate repo.
$ciScriptsDir = 'N:\Code\Workspace\Local-CI-CD-System\scripts'
# Uncomment to clone via SSH alias instead of HTTPS (faster for large repos):
# repo-url: 'ssh://gitea-ci/${{ github.repository }}.git'
# use-git-clone: 'true'
& "$ciScriptsDir\Invoke-CIJob.ps1" `
-JobId "${{ github.run_id }}-${{ github.run_attempt }}" `
-RepoUrl "ssh://gitea-ci/${{ github.repository }}.git" `
-Branch "${{ github.ref_name }}" `
-Commit "${{ github.sha }}" `
-Submodules `
-BuildCommand 'python build_plugin.py --final --dist-dir dist' `
-GuestArtifactSource 'dist' `
-GuestCredentialTarget "$env:GUEST_CRED_TARGET"
# Uncomment to inject secrets as env vars in the VM (never logged):
# extra-guest-env-json: >-
# {"SIGN_PASS":"${{ secrets.SIGN_PASS }}",
# "GPG_KEY_ID":"${{ secrets.GPG_KEY_ID }}"}
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
# Step 3: Upload artifacts to Gitea
# Artifacts were collected to F:\CI\Artifacts\{JobId}\ by Invoke-CIJob.ps1
- name: Upload build artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: build-${{ github.sha }}
path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}\
retention-days: 14
# Artifact name defaults to build-{run_id}-{sha}.
# Uncomment to use a custom name (e.g. include ref_name for tag builds):
# artifact-name: 'myproject-${{ github.ref_name }}'
if-no-files-found: error
# Step 4: Upload artifacts even on failure (for diagnostics)