Skip to content

Commit 6057d8d

Browse files
committed
Merge commit '56d37d0d5d1a23b179ee018f701eb99a2a25bd24' into trunk
2 parents 1d1f576 + 56d37d0 commit 6057d8d

3 files changed

Lines changed: 365 additions & 33 deletions

File tree

.github/scripts/docs-playground-preview/build.mjs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ echo "Reference API navigation seeded.\\n";
646646
async function validateSnapshotWithServer(deps, snapshotPath, logDir, manifest) {
647647
const restoreBlueprint = path.join(path.dirname(snapshotPath), 'restore-blueprint.json');
648648
const pathInZip = await detectPathInZip(snapshotPath);
649+
const smokeResult = {
650+
ok: false,
651+
pathInZip: pathInZip || '',
652+
};
649653
const blueprint = {
650654
$schema: deps.playground.blueprintSchema,
651655
preferredVersions: {
@@ -688,6 +692,7 @@ async function validateSnapshotWithServer(deps, snapshotPath, logDir, manifest)
688692
child.stdout.on('data', (chunk) => { output += chunk.toString(); });
689693
child.stderr.on('data', (chunk) => { output += chunk.toString(); });
690694

695+
let smokeError = null;
691696
try {
692697
await waitForHttp(`http://127.0.0.1:${port}/reference/`, 180_000);
693698
const routeResults = {};
@@ -701,12 +706,23 @@ async function validateSnapshotWithServer(deps, snapshotPath, logDir, manifest)
701706
}
702707
routeResults[route] = { bytes: body.length };
703708
}
709+
smokeResult.ok = true;
710+
smokeResult.routes = routeResults;
704711
manifest.checks.routes = routeResults;
705712
manifest.checks.pathInZip = pathInZip || '';
713+
} catch (error) {
714+
smokeError = error;
715+
smokeResult.error = error instanceof Error ? error.message : String(error);
706716
} finally {
707717
child.kill('SIGTERM');
708718
await fs.writeFile(path.join(logDir, 'restore-smoke.log'), output);
709719
}
720+
721+
manifest.checks.restoreSmoke = smokeResult;
722+
if (smokeError) {
723+
console.warn(`Warning: docs Playground restore smoke failed: ${smokeResult.error}`);
724+
logGroup('Docs Playground restore smoke output', output);
725+
}
710726
}
711727

712728
async function normalizeSnapshotArchive(inputZip, outputZip) {
@@ -874,7 +890,8 @@ async function fetchText(url) {
874890
res.on('data', (chunk) => { body += chunk; });
875891
res.on('end', () => {
876892
if ((res.statusCode || 0) >= 400) {
877-
reject(new Error(`${url} returned ${res.statusCode}`));
893+
const excerpt = bodyExcerpt(body);
894+
reject(new Error(`${url} returned ${res.statusCode}${excerpt ? `\nResponse body:\n${excerpt}` : ''}`));
878895
} else {
879896
resolve(body);
880897
}
@@ -887,6 +904,30 @@ async function fetchText(url) {
887904
});
888905
}
889906

907+
function bodyExcerpt(body, limit = 4000) {
908+
const clean = String(body || '').replace(/\0/g, '');
909+
if (!clean) {
910+
return '';
911+
}
912+
if (clean.length <= limit) {
913+
return clean;
914+
}
915+
return `${clean.slice(0, limit)}\n...[truncated ${clean.length - limit} chars]`;
916+
}
917+
918+
function logGroup(title, body, limit = 20000) {
919+
const clean = String(body || '').trim();
920+
if (!clean) {
921+
return;
922+
}
923+
const excerpt = clean.length > limit
924+
? `${clean.slice(clean.length - limit)}\n...[truncated ${clean.length - limit} earlier chars]`
925+
: clean;
926+
console.log(`::group::${title}`);
927+
console.log(excerpt);
928+
console.log('::endgroup::');
929+
}
930+
890931
async function getFreePort() {
891932
return new Promise((resolve, reject) => {
892933
const server = http.createServer();

.github/workflows/docs-playground-preview-build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
permissions:
2525
contents: read
2626
with:
27-
artifacts: docs-playground-snapshot=build/docs-playground-snapshot.zip
27+
artifacts: |
28+
docs-playground-snapshot=build/docs-playground-snapshot.zip
29+
docs-preview-diagnostics=build/docs-preview-diagnostics.zip
2830
node-version: '20'
2931
php-version: '8.4'
3032
build-command: |
@@ -34,3 +36,7 @@ jobs:
3436
--out "$GITHUB_WORKSPACE/build" \
3537
--pr-number "${{ github.event.pull_request.number }}" \
3638
--head-sha "${{ github.event.pull_request.head.sha }}"
39+
(
40+
cd "$GITHUB_WORKSPACE/build"
41+
zip -rq docs-preview-diagnostics.zip docs-preview-manifest.json restore-blueprint.json logs
42+
)

0 commit comments

Comments
 (0)