CI senza azioni e senza Node, solo comandi scritti in casa (C6, 3/4)
Per la decisione di Alberto del 18 novembre 2026 (niente componenti esterni) i flussi di verifica, rilascio e pulizia non usano più azioni JavaScript, che vogliono Node: - sorgenti con git init/fetch e il gettone del lavoro, passato a git solo nell'ambiente del passo, mai scritto nella configurazione; - SDK .NET con .gitea/scripts/dotnet.sh, dai metadati di Microsoft e verificato con lo SHA-512 prima di installarlo nella cache degli strumenti del runner; - builder buildx creato da costruisci-immagine.sh builder; - artefatti nel pacchetto generico febe-ci del registro di Gitea (artefatti.sh, con REGISTRY_TOKEN), tolti dalla pulizia del lunedì dopo 14 giorni; la release ricostruisce installatore e zip invece di riceverli da un altro lavoro; - JSON letto con un lettore in awk POSIX (json.awk) per i controlli e per la scelta delle versioni del registro, al posto di versioni-registro.js; - contenitore delle prove debian:trixie al posto di node:24-trixie; - la prova della pagina di accesso gira in Chromium invece che in Node. controlli.sh rifiuta ora un flusso con uses:, tabulazioni o rientri dispari, e le prove nuove controllano l'assenza di Node, il passo dei sorgenti uguale in ogni lavoro, l'SDK prima di ogni dotnet, la scelta dell'SDK, il caricamento degli artefatti con un curl finto e la scadenza dei vecchi. Nessuna esecuzione vera di Gitea Actions: ciò che resta da vedere è in docs/processo.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a54f1a460
commit
a4ad8a8bc4
27 files changed
+1763
-396
No files matched your search
@@ -1,6 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Febe.Tests.Desktop.Support;
|
||||
using Febe.Tests.Support;
|
||||
using Febe.Tests.Web.Support;
|
||||
@@ -96,19 +96,14 @@ public sealed class LoginSecurityTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TheLoginPageGoesBackOnlyToAPageOfTheInterface()
|
||||
[Timeout(300_000, CooperativeCancellation = true)]
|
||||
public async Task TheLoginPageGoesBackOnlyToAPageOfTheInterface()
|
||||
{
|
||||
var accesso = File.ReadAllText(Repository.PathOf("src", "Febe.Web", "wwwroot", "js", "accesso.js"));
|
||||
StringAssert.Contains(accesso, "import { returnAddress } from './core/return-path.js';");
|
||||
StringAssert.Contains(accesso, "location.href = returnAddress(");
|
||||
Assert.DoesNotContain("startsWith('//')", accesso, "the old check let «/\\host» through");
|
||||
|
||||
var node = FindOnPath("node");
|
||||
if (node is null)
|
||||
{
|
||||
Assert.Inconclusive("Node non è installato: la regola della pagina di accesso si prova solo dove c'è (CI, sviluppo).");
|
||||
}
|
||||
|
||||
const string origin = "http://tower:8480";
|
||||
List<(string? Value, string Expected)> cases =
|
||||
[
|
||||
@@ -121,23 +116,18 @@ public sealed class LoginSecurityTests
|
||||
("/.//dentro", origin + "//dentro"),
|
||||
];
|
||||
|
||||
using var temp = new TempFolder("accesso-js");
|
||||
var script = temp.Combine("prova.mjs");
|
||||
var module = new Uri(Repository.PathOf("src", "Febe.Web", "wwwroot", "js", "core", "return-path.js")).AbsoluteUri;
|
||||
File.WriteAllText(script, $$"""
|
||||
import { returnAddress } from '{{module}}';
|
||||
const cases = JSON.parse(process.argv[2]);
|
||||
console.log(JSON.stringify(cases.map(v => returnAddress(v, '{{origin}}'))));
|
||||
""");
|
||||
var start = new ProcessStartInfo(node) { RedirectStandardOutput = true, RedirectStandardError = true };
|
||||
start.ArgumentList.Add(script);
|
||||
start.ArgumentList.Add(JsonSerializer.Serialize(cases.Select(c => c.Value)));
|
||||
using var process = Process.Start(start)!;
|
||||
var output = process.StandardOutput.ReadToEnd();
|
||||
var errors = process.StandardError.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
Assert.AreEqual(0, process.ExitCode, errors);
|
||||
var results = JsonSerializer.Deserialize<string[]>(output)!;
|
||||
// The rule runs where it runs for real: in Chromium, in the module the login page imports, served by Febe to a
|
||||
// browser that has not logged in yet. No other JavaScript engine: the CI has no Node.
|
||||
await using var ui = await UiBrowser.StartAsync();
|
||||
await using var server = await StartAsync(trustProxy: false);
|
||||
var page = new Uri(server.Address, "/accesso");
|
||||
var navigation = await ui.SendAsync("Page.navigate", new JsonObject { ["url"] = page.AbsoluteUri });
|
||||
Assert.IsFalse(navigation.TryGetProperty("errorText", out var error) && error.GetString() is { Length: > 0 }, $"apertura di {page}: {error}");
|
||||
await ui.WaitAsync("location.pathname === '/accesso' && document.readyState === 'complete'", "pagina di accesso");
|
||||
var values = JsonSerializer.Serialize(cases.Select(c => c.Value));
|
||||
var results = await ui.EvalAsync<string[]>(
|
||||
$"import('/js/core/return-path.js').then((m) => {values}.map((v) => m.returnAddress(v, {JsonSerializer.Serialize(origin)})))");
|
||||
Assert.HasCount(cases.Count, results, ui.Report());
|
||||
for (var i = 0; i < cases.Count; i++)
|
||||
{
|
||||
Assert.AreEqual(cases[i].Expected, results[i], JsonSerializer.Serialize(cases[i].Value));
|
||||
@@ -199,21 +189,4 @@ public sealed class LoginSecurityTests
|
||||
|
||||
private static bool IsSecure(string setCookie) =>
|
||||
setCookie.Split(';').Any(part => string.Equals(part.Trim(), "secure", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private static string? FindOnPath(string name)
|
||||
{
|
||||
foreach (var folder in (Environment.GetEnvironmentVariable("PATH") ?? string.Empty).Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
foreach (var candidate in new[] { name, name + ".exe" })
|
||||
{
|
||||
var path = Path.Combine(folder, candidate);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user