ci: Gitea Actions, release con il solo zip del sito e documentazione senza Forgejo
Il progetto vive in modo definitivo su Gitea: i workflow passano da .forgejo/ a .gitea/workflows/ e la documentazione non nomina più la piattaforma precedente. - ci.yml: i controlli di npm run verify sono passi separati (si vede subito quale è fallito) e alla fine la CI crea lo zip di rilascio e ne verifica il contenuto, così un errore di pacchetto emerge prima del tag. Runner ubuntu-latest, azioni da github.com con URL completo, upload-artifact@v3 (la v4 non funziona su Gitea). - release.yml: a ogni tag vX.Y.Z verifica tutto, crea lo zip e lo pubblica nella Release con scripts/release-upload.sh e l'API di Gitea, senza action esterne di release. - La release contiene un solo file, sito-studio-grasso-vX.Y.Z.zip (contenuto di dist/ alla radice, .htaccess compreso): tolti tar.gz, SHA256SUMS.txt e BUILD-INFO.txt da package.mjs, check-package.mjs e dalla documentazione. - release-upload.sh: variabili GITEA_*, si ferma su errori diversi da 404 invece di provare a creare la release, rifiuta una cartella vuota; provato su una finta API Gitea. - deploy/gitea-deploy.yml.example convertito per Gitea (resta disattivato). - Versione 1.0.1 pronta (package.json, CHANGELOG, D-056 e D-057 in DECISIONS.md); il tag v1.0.1 non è stato creato. Verifica: npm run verify completo (lint, formato, tipi, build, HTML, link, e2e 39, a11y 51, conformità 1455, Lighthouse) e npm run package eseguiti in una copia fuori da .claude/. I workflow non sono ancora stati eseguiti su un runner Gitea. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
083489ac8b
commit
31ac5b7f68
20 files changed
+645
-657
No files matched your search
+16
-96
@@ -1,17 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Integrità del pacchetto di rilascio (brief §11.7), da eseguire dopo scripts/package.mjs:
|
||||
* Integrità del pacchetto di rilascio, da eseguire dopo scripts/package.mjs:
|
||||
*
|
||||
* - in release/ ci sono solo zip, tar.gz, SHA256SUMS.txt e BUILD-INFO.txt, con i nomi attesi;
|
||||
* - le impronte di SHA256SUMS.txt sono corrette (anche con `sha256sum -c`, se disponibile);
|
||||
* - zip e tar.gz, estratti in una cartella temporanea, contengono esattamente i file di dist/
|
||||
* (stessi percorsi, dimensioni e contenuto), alla radice, con .htaccess e tutte le pagine;
|
||||
* - lo zip non supera 5 MB; BUILD-INFO.txt riporta versione, commit e data.
|
||||
* - in release/ c'è solo lo zip, con il nome atteso (nessun altro file);
|
||||
* - lo zip, aperto con un lettore minimale (CRC e dimensioni compresi), contiene esattamente
|
||||
* i file di dist/ (stessi percorsi, dimensioni e contenuto), alla radice, con .htaccess e
|
||||
* tutte le pagine del sitemap;
|
||||
* - lo zip non supera 5 MB.
|
||||
*/
|
||||
import { execFileSync, spawnSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { crc32, inflateRawSync } from 'node:zlib';
|
||||
import { readSitemapPaths } from './lib/pages.mjs';
|
||||
@@ -63,32 +61,6 @@ function readZip(file) {
|
||||
return entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estrazione del tar.gz con `tar` di sistema in una cartella temporanea. L'archivio arriva da
|
||||
* stdin: su Windows il GNU tar di Git Bash interpreta «C:\…» come host remoto.
|
||||
*/
|
||||
function readTarGz(file) {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sito-studio-grasso-'));
|
||||
try {
|
||||
execFileSync('tar', ['-xzf', '-'], { cwd: dir, input: readFileSync(file) });
|
||||
const entries = new Map();
|
||||
for (const rel of listAll(dir)) entries.set(rel, readFileSync(join(dir, rel)));
|
||||
return entries;
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
function listAll(dir, base = '') {
|
||||
const out = [];
|
||||
for (const e of readdirSync(join(dir, base), { withFileTypes: true })) {
|
||||
const rel = base ? `${base}/${e.name}` : e.name;
|
||||
if (e.isDirectory()) out.push(...listAll(dir, rel));
|
||||
else out.push(rel);
|
||||
}
|
||||
return out.sort();
|
||||
}
|
||||
|
||||
function compareWithDist(label, entries, expected) {
|
||||
const names = [...entries.keys()].sort();
|
||||
const missing = expected.filter((f) => !entries.has(f));
|
||||
@@ -130,80 +102,28 @@ try {
|
||||
console.error(`✘ ${e.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
const names = archiveNames(version);
|
||||
const expectedRelease = [names.zip, names.tgz, 'SHA256SUMS.txt', 'BUILD-INFO.txt'].sort();
|
||||
const { zip } = archiveNames(version);
|
||||
|
||||
if (!existsSync(releaseDir)) {
|
||||
console.error('✘ release/ assente: eseguire `npm run package`.');
|
||||
process.exit(1);
|
||||
}
|
||||
const present = readdirSync(releaseDir).sort();
|
||||
for (const f of expectedRelease) if (!present.includes(f)) fail(`release/: manca ${f}`);
|
||||
const present = readdirSync(releaseDir);
|
||||
if (!present.includes(zip)) fail(`release/: manca ${zip}`);
|
||||
for (const f of present)
|
||||
if (!expectedRelease.includes(f))
|
||||
fail(`release/: file inatteso ${f} (la cartella deve contenere solo il pacchetto)`);
|
||||
if (f !== zip) fail(`release/: file inatteso ${f} (la cartella deve contenere solo lo zip)`);
|
||||
|
||||
// impronte
|
||||
const sumsFile = join(releaseDir, 'SHA256SUMS.txt');
|
||||
if (existsSync(sumsFile)) {
|
||||
const lines = readFileSync(sumsFile, 'utf8').trim().split('\n');
|
||||
const listed = new Set();
|
||||
for (const line of lines) {
|
||||
const m = line.match(/^([0-9a-f]{64}) {2}(.+)$/);
|
||||
if (!m) {
|
||||
fail(`SHA256SUMS.txt: riga non valida «${line}»`);
|
||||
continue;
|
||||
}
|
||||
listed.add(m[2]);
|
||||
const target = join(releaseDir, m[2]);
|
||||
if (!existsSync(target)) fail(`SHA256SUMS.txt: il file ${m[2]} non esiste`);
|
||||
else if (sha256(readFileSync(target)) !== m[1])
|
||||
fail(`SHA256SUMS.txt: impronta errata per ${m[2]}`);
|
||||
}
|
||||
for (const f of [names.zip, names.tgz]) if (!listed.has(f)) fail(`SHA256SUMS.txt: manca ${f}`);
|
||||
const tool = spawnSync('sha256sum', ['-c', 'SHA256SUMS.txt'], {
|
||||
cwd: releaseDir,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (tool.error)
|
||||
console.log(' (sha256sum non disponibile: impronte verificate solo con Node.js)');
|
||||
else if (tool.status !== 0) fail(`sha256sum -c non superato:\n${tool.stdout}${tool.stderr}`);
|
||||
else console.log(` sha256sum -c: ${tool.stdout.trim().split('\n').join(' · ')}`);
|
||||
}
|
||||
|
||||
// contenuto degli archivi
|
||||
const expected = listFiles(distDir);
|
||||
const zipPath = join(releaseDir, names.zip);
|
||||
const tgzPath = join(releaseDir, names.tgz);
|
||||
const zipPath = join(releaseDir, zip);
|
||||
if (existsSync(zipPath)) {
|
||||
const size = statSync(zipPath).size;
|
||||
if (size > MAX_ZIP)
|
||||
fail(`${names.zip}: ${(size / 1048576).toFixed(2)} MB oltre il limite di 5 MB`);
|
||||
if (size > MAX_ZIP) fail(`${zip}: ${(size / 1048576).toFixed(2)} MB oltre il limite di 5 MB`);
|
||||
try {
|
||||
compareWithDist(names.zip, readZip(zipPath), expected);
|
||||
compareWithDist(zip, readZip(zipPath), expected);
|
||||
} catch (e) {
|
||||
fail(`${names.zip}: ${e.message}`);
|
||||
fail(`${zip}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
if (existsSync(tgzPath)) {
|
||||
try {
|
||||
compareWithDist(names.tgz, readTarGz(tgzPath), expected);
|
||||
} catch (e) {
|
||||
fail(`${names.tgz}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// BUILD-INFO
|
||||
const infoFile = join(releaseDir, 'BUILD-INFO.txt');
|
||||
if (existsSync(infoFile)) {
|
||||
const info = readFileSync(infoFile, 'utf8');
|
||||
if (!info.includes(`Versione: ${version}`)) fail('BUILD-INFO.txt: manca «Versione»');
|
||||
if (!/^Commit: [0-9a-f]{7,40}$/m.test(info)) fail('BUILD-INFO.txt: manca l’hash del commit');
|
||||
if (!/^Data: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/m.test(info))
|
||||
fail('BUILD-INFO.txt: manca la data ISO');
|
||||
if (!/^Node\.js: v\d+/m.test(info) || !/^Astro: \d+/m.test(info))
|
||||
fail('BUILD-INFO.txt: mancano le versioni di Node.js e Astro');
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error(`✘ Pacchetto v${version}: ${errors.length} errori`);
|
||||
@@ -212,5 +132,5 @@ if (errors.length) {
|
||||
}
|
||||
const zipKb = (statSync(zipPath).size / 1024).toFixed(1);
|
||||
console.log(
|
||||
`✔ Pacchetto v${version} verificato: ${expected.length} file identici a dist/ in zip (${zipKb} KB) e tar.gz, impronte corrette.`,
|
||||
`✔ Pacchetto v${version} verificato: ${expected.length} file identici a dist/ nello zip (${zipKb} KB), unico file di release/.`,
|
||||
);
|
||||
Reference in new issue
Block a user