Skip to content

Commit 24f38c0

Browse files
Merge main and correct v0.116 package guidance
Make fresh installs deterministic, split Rocky-family and registered RHEL prerequisites, and correct reset, upgrade, TLS, and non-interactive setup instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ed25bd3e-4cfc-4ee1-b8ee-7733474cc141 Signed-off-by: Guanzhou Song <guanzhousong@microsoft.com>
2 parents 1e7c9a5 + f64836a commit 24f38c0

18 files changed

Lines changed: 2627 additions & 804 deletions
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Fails the build when the site's fallback release drifts from the release the
4+
* package repository actually mirrors.
5+
*
6+
* The /packages page used to hardcode its versions, and they went stale: the
7+
* page still advertised 0.114-0 (and 0.113-0 for the repository examples) after
8+
* v0.116-0 had been published and mirrored. The page now reads
9+
* out/packages/release-info.json at runtime, but it still needs a compiled-in
10+
* fallback for the first paint and for the case where that fetch fails - so the
11+
* fallback can drift in exactly the same way, just less visibly.
12+
*
13+
* This check closes that loop: whenever the deployment mirrors a release, the
14+
* fallback baked into the bundle must name the same one.
15+
*
16+
* Skipped when release-info.json is absent, which is the normal case for a
17+
* site-only build (BUILD_PACKAGES=false, or any fork without the packaging
18+
* secrets). There is nothing to compare against then.
19+
*/
20+
21+
const fs = require("node:fs");
22+
const path = require("node:path");
23+
24+
const releaseInfoPath = path.join(process.cwd(), "out", "packages", "release-info.json");
25+
const fallbackSourcePath = path.join(process.cwd(), "app", "lib", "releaseInfo.ts");
26+
27+
if (!fs.existsSync(releaseInfoPath)) {
28+
console.log(`No ${path.relative(process.cwd(), releaseInfoPath)}; skipping release drift check.`);
29+
process.exit(0);
30+
}
31+
32+
const source = fs.readFileSync(fallbackSourcePath, "utf8");
33+
34+
/** Reads a string field out of the FALLBACK_RELEASE object literal. */
35+
function fallbackField(field) {
36+
const match = new RegExp(`${field}:\\s*"([^"]+)"`).exec(source);
37+
return match ? match[1] : null;
38+
}
39+
40+
const mirrored = JSON.parse(fs.readFileSync(releaseInfoPath, "utf8"));
41+
const mirroredTag = mirrored.tag_name;
42+
if (typeof mirroredTag !== "string" || mirroredTag.length === 0) {
43+
console.error("release-info.json has no tag_name; cannot verify the site's fallback release.");
44+
process.exit(1);
45+
}
46+
47+
const fallbackTag = fallbackField("tagName");
48+
if (fallbackTag !== mirroredTag) {
49+
console.error(
50+
[
51+
"Release drift: the site's fallback release does not match the mirrored release.",
52+
"",
53+
` mirrored (out/packages/release-info.json): ${mirroredTag}`,
54+
` fallback (app/lib/releaseInfo.ts): ${fallbackTag ?? "<not found>"}`,
55+
"",
56+
"Update FALLBACK_RELEASE in app/lib/releaseInfo.ts to the mirrored release.",
57+
"It is what visitors see before the release feed loads, and permanently if",
58+
"that fetch fails.",
59+
].join("\n"),
60+
);
61+
process.exit(1);
62+
}
63+
64+
// The version strings are derived from real asset filenames, so a mismatch here
65+
// means the fallback would render install commands for packages the release
66+
// does not contain.
67+
const assetNames = Array.isArray(mirrored.assets)
68+
? mirrored.assets.map((asset) => asset && asset.name).filter((name) => typeof name === "string")
69+
: [];
70+
71+
const derived = [
72+
{
73+
field: "aptVersion",
74+
pattern: /^ubuntu[\d.]+-postgresql-\d+-documentdb_([^_]+)_/,
75+
},
76+
{
77+
field: "rpmVersion",
78+
pattern: /^rhel\d+-postgresql\d+-documentdb-(.+)\.(?:x86_64|aarch64)\.rpm$/,
79+
},
80+
{
81+
field: "metaVersion",
82+
pattern: /^ubuntu[\d.]+-documentdb_([^_]+)_all\.deb$/,
83+
},
84+
];
85+
86+
let failed = false;
87+
for (const { field, pattern } of derived) {
88+
const actual = assetNames.map((name) => pattern.exec(name)).find((m) => m && m[1]);
89+
if (!actual) {
90+
// The release simply does not ship that package shape; the fallback keeps
91+
// whatever it had, which is not drift.
92+
continue;
93+
}
94+
const expected = actual[1];
95+
const declared = fallbackField(field);
96+
if (declared !== expected) {
97+
console.error(
98+
`Release drift: FALLBACK_RELEASE.${field} is "${declared}" but ${mirroredTag} ships "${expected}".`,
99+
);
100+
failed = true;
101+
}
102+
}
103+
104+
if (failed) {
105+
console.error("\nUpdate FALLBACK_RELEASE in app/lib/releaseInfo.ts.");
106+
process.exit(1);
107+
}
108+
109+
console.log(`Release fallback matches the mirrored release (${mirroredTag}).`);

0 commit comments

Comments
 (0)