Add full source parity validation workflow
This commit is contained in:
@@ -15,6 +15,7 @@ const sha256 = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex"
|
||||
const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
|
||||
const relative = (file) => path.relative(root, file).replaceAll(path.sep, "/");
|
||||
const taskArgument = process.argv.indexOf("--task");
|
||||
const write = process.argv.includes("--write");
|
||||
if (taskArgument >= 0) {
|
||||
const task = process.argv[taskArgument + 1];
|
||||
if (!task) throw new Error("--task requires a task id");
|
||||
@@ -102,7 +103,7 @@ for (const file of inventory.sourceFiles) {
|
||||
}
|
||||
for (const [name, artifact] of Object.entries(manifest.artifacts)) {
|
||||
assert.ok(fs.existsSync(path.join(root, artifact.path)), `${name}: ${artifact.path}`);
|
||||
assert.equal(sha256(fs.readFileSync(path.join(root, artifact.path))), artifact.sha256, `${name}: ${artifact.path}`);
|
||||
if (!write) assert.equal(sha256(fs.readFileSync(path.join(root, artifact.path))), artifact.sha256, `${name}: ${artifact.path}`);
|
||||
}
|
||||
const treeDigest = sha256(inventory.sourceFiles.map((file) => `${file.sourcePath}\0${file.sha256}\n`).join(""));
|
||||
assert.equal(treeDigest, inventory.authority.sourceTreeSha256);
|
||||
@@ -151,4 +152,24 @@ const report = {
|
||||
deterministic: true,
|
||||
};
|
||||
fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
|
||||
process.stdout.write(`source-dynamic-inventory-ok files=${report.sourceFiles} units=${report.unitCount} planningEstimate=${report.planningEstimate} verified=${report.verifiedUnits} unverified=${report.unverifiedUnits} sourceTree=${report.sourceTreeSha256}\n`);
|
||||
if (write) {
|
||||
const artifactSha256 = (name) => sha256(fs.readFileSync(path.join(root, manifest.artifacts[name].path)));
|
||||
for (const name of Object.keys(manifest.artifacts)) manifest.artifacts[name].sha256 = artifactSha256(name);
|
||||
manifest.source = {
|
||||
root: inventory.authority.sourceRoot,
|
||||
treeSha256: inventory.authority.sourceTreeSha256,
|
||||
fileCount: inventory.summary.sourceFiles,
|
||||
byteCount: inventory.summary.sourceBytes,
|
||||
};
|
||||
manifest.inventory = {
|
||||
...manifest.inventory,
|
||||
unitCount: inventory.summary.unitCount,
|
||||
byKind: inventory.summary.byKind,
|
||||
planningEstimate: inventory.policy.planningEstimate,
|
||||
hardTarget: inventory.policy.hardTarget,
|
||||
verifiedUnits: inventory.coverage.verifiedUnits,
|
||||
unverifiedUnits: inventory.coverage.unverifiedUnits,
|
||||
};
|
||||
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
}
|
||||
process.stdout.write(`source-dynamic-inventory-ok files=${report.sourceFiles} units=${report.unitCount} planningEstimate=${report.planningEstimate} verified=${report.verifiedUnits} unverified=${report.unverifiedUnits} sourceTree=${report.sourceTreeSha256} write=${write}\n`);
|
||||
|
||||
Reference in New Issue
Block a user