76 lines
5.1 KiB
JavaScript
76 lines
5.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { execFileSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const manifestPath = path.join(repoRoot, "release/RC_MANIFEST.json");
|
|
const manifestBytes = fs.readFileSync(manifestPath);
|
|
const manifest = JSON.parse(manifestBytes);
|
|
const sha256Bytes = (value) => crypto.createHash("sha256").update(value).digest("hex");
|
|
const sha256File = (file) => sha256Bytes(fs.readFileSync(file));
|
|
const archiveEntry = (archive, entry) => execFileSync("tar", ["-xOf", archive, entry], { maxBuffer: 32 * 1024 * 1024 });
|
|
const packageJson = JSON.parse(fs.readFileSync(path.join(repoRoot, "web/package.json"), "utf8"));
|
|
const lockfile = JSON.parse(fs.readFileSync(path.join(repoRoot, "web/package-lock.json"), "utf8"));
|
|
const engine = JSON.parse(fs.readFileSync(path.join(repoRoot, "web/app/public/engine-manifest.json"), "utf8"));
|
|
const binaryArchive = path.join(repoRoot, manifest.artifacts.binaryArchive.path);
|
|
const sourceArchive = path.join(repoRoot, manifest.artifacts.sourceArchive.path);
|
|
const sbomPath = path.join(repoRoot, manifest.artifacts.sbom.path);
|
|
const sumsPath = path.join(repoRoot, "release/SHA256SUMS.txt");
|
|
|
|
assert.equal(manifest.schemaVersion, 1);
|
|
assert.match(manifest.semver, /^\d+\.\d+\.\d+-rc\.\d+$/);
|
|
assert.equal(manifest.rcId, `web-blender-${manifest.semver}`);
|
|
assert.equal(packageJson.version, manifest.semver);
|
|
assert.equal(lockfile.version, manifest.semver);
|
|
assert.equal(lockfile.packages[""].version, manifest.semver);
|
|
assert.equal(engine.releaseId, manifest.engineReleaseId);
|
|
assert.equal(engine.engineVersion, manifest.engineReleaseId);
|
|
assert.equal(manifest.engineReleaseId, `blender-wasm-${manifest.semver}`);
|
|
assert.equal(manifest.gitCommit, execFileSync("git", ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8" }).trim());
|
|
assert.equal(manifest.sourceBinding.mode, "corresponding-source-archive");
|
|
assert.equal(typeof manifest.sourceBinding.worktreeDirty, "boolean");
|
|
|
|
for (const entry of Object.values(manifest.artifacts)) {
|
|
const file = path.join(repoRoot, entry.path);
|
|
assert.equal(fs.statSync(file).size, entry.bytes, `${entry.path} byte length drifted`);
|
|
assert.equal(sha256File(file), entry.sha256, `${entry.path} SHA-256 drifted`);
|
|
}
|
|
const embeddedPackageJson = archiveEntry(sourceArchive, "web/package.json");
|
|
const embeddedPackageLock = archiveEntry(sourceArchive, "web/package-lock.json");
|
|
const embeddedEngineManifest = archiveEntry(binaryArchive, "blender-web-offline/app/engine-manifest.json");
|
|
const embeddedReleaseMetadata = archiveEntry(binaryArchive, "blender-web-offline/release-metadata.json");
|
|
const embeddedSbom = archiveEntry(binaryArchive, "blender-web-offline/sbom.spdx.json");
|
|
assert.deepEqual(embeddedPackageJson, fs.readFileSync(path.join(repoRoot, "web/package.json")));
|
|
assert.deepEqual(embeddedPackageLock, fs.readFileSync(path.join(repoRoot, "web/package-lock.json")));
|
|
assert.deepEqual(embeddedEngineManifest, fs.readFileSync(path.join(repoRoot, "web/app/public/engine-manifest.json")));
|
|
assert.deepEqual(embeddedSbom, fs.readFileSync(sbomPath));
|
|
const releaseMetadata = JSON.parse(embeddedReleaseMetadata.toString("utf8"));
|
|
const sourceManifest = JSON.parse(archiveEntry(sourceArchive, "SOURCE_MANIFEST.json").toString("utf8"));
|
|
assert.equal(releaseMetadata.productVersion, manifest.semver);
|
|
assert.equal(releaseMetadata.engineReleaseId, manifest.engineReleaseId);
|
|
assert.equal(sourceManifest.version, manifest.semver);
|
|
assert.equal(sourceManifest.engineReleaseId, manifest.engineReleaseId);
|
|
assert.equal(manifest.bindings.packageJsonSha256, sha256File(path.join(repoRoot, "web/package.json")));
|
|
assert.equal(manifest.bindings.packageLockSha256, sha256File(path.join(repoRoot, "web/package-lock.json")));
|
|
assert.equal(manifest.bindings.ledgerSha256, sha256File(path.join(repoRoot, "docs/status/parity-ledger.json")));
|
|
assert.equal(manifest.bindings.engineManifestSha256, sha256File(path.join(repoRoot, "web/app/public/engine-manifest.json")));
|
|
assert.equal(manifest.bindings.embeddedReleaseMetadataSha256, sha256Bytes(embeddedReleaseMetadata));
|
|
assert.equal(manifest.bindings.sha256SumsSha256, sha256File(sumsPath));
|
|
assert.deepEqual(Object.keys(manifest.operations), ["deploy", "upgrade", "rollback", "diagnostics", "rehearsal"]);
|
|
for (const entry of Object.values(manifest.operations)) {
|
|
const file = path.join(repoRoot, entry.path);
|
|
assert.equal(fs.statSync(file).size, entry.bytes);
|
|
assert.equal(sha256File(file), entry.sha256);
|
|
}
|
|
const manifestSha256 = sha256Bytes(manifestBytes);
|
|
assert.equal(fs.readFileSync(`${manifestPath}.sha256`, "utf8"), `${manifestSha256} RC_MANIFEST.json\n`);
|
|
const checksumLines = fs.readFileSync(sumsPath, "utf8").trim().split("\n");
|
|
assert.deepEqual(checksumLines, [
|
|
`${manifest.artifacts.binaryArchive.sha256} blender-web-offline.tar.gz`,
|
|
`${manifest.artifacts.sourceArchive.sha256} blender-web-corresponding-source.tar.gz`,
|
|
]);
|
|
process.stdout.write(`rc-manifest-check-ok id=${manifest.rcId} commit=${manifest.gitCommit} artifacts=3 operations=${Object.keys(manifest.operations).length}\n`);
|