You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by po...@apache.org on 2026/09/18 04:19:23 UTC

(magpie-site) branch main updated: fix: clear the type-check hints, and let the check fail on errors again

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/magpie-site.git


The following commit(s) were added to refs/heads/main by this push:
     new caf85c2  fix: clear the type-check hints, and let the check fail on errors again
caf85c2 is described below

commit caf85c2edb27624559c93fc620b45f9bee1d2a3b
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Fri Sep 18 05:50:41 2026 +0200

    fix: clear the type-check hints, and let the check fail on errors again
    
    `astro check` reported nine hints, all of them real:
    
    - Three body builders in the preview publisher took a `pr` argument they never
      read. Removed, with the call sites updated - a parameter that is never used
      is a parameter that lies about what the function needs. The test suite caught
      an incomplete first pass at this, where three `refusedBody` calls still
      passed the PR number and it silently became the refusal reason.
    - `astro:content` no longer re-exports `z`; it comes from `astro/zod`.
    - The JSON-LD script carries an attribute, so Astro already treats it as
      `is:inline`. Saying so explicitly matches what happens.
    - review.js is browser script, not a module: the publisher concatenates
      logic.mjs ahead of it with the `export` keywords stripped, so its three
      helpers arrive as globals. A .d.ts declares them, which both silences the
      hint and documents a contract that was previously only implied.
    
    The step also carried `continue-on-error: true`, so even genuine type errors
    could not fail the build. With the tree clean, that only served to hide the
    next regression. astro check fails a step on errors alone, so warnings and
    hints still print without blocking - and the synced docs cannot break CI by
    acquiring a hint.
    
    Generated-by: Claude Opus 5
---
 .github/workflows/build.yml          |  5 ++++-
 scripts/preview/overlay/globals.d.ts | 23 +++++++++++++++++++++++
 scripts/preview/publish.mjs          | 20 ++++++++++----------
 src/components/JsonLd.astro          |  2 +-
 src/content.config.ts                |  3 ++-
 5 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8d0b4a4..55275fd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -79,8 +79,11 @@ jobs:
         run: npm run sync-docs
 
       - name: Type check
+        # No longer continue-on-error: the tree is clean of errors, warnings and
+        # hints, so anything this reports from here on is a regression someone
+        # introduced. astro check only fails the step on errors — warnings and
+        # hints still print without blocking.
         run: npx astro check
-        continue-on-error: true
 
       - name: Build
         run: npm run build
diff --git a/scripts/preview/overlay/globals.d.ts b/scripts/preview/overlay/globals.d.ts
new file mode 100644
index 0000000..31504fa
--- /dev/null
+++ b/scripts/preview/overlay/globals.d.ts
@@ -0,0 +1,23 @@
+// review.js is browser script, not a module: at publish time the publisher
+// concatenates logic.mjs ahead of it with the `export ` keywords stripped, so
+// these arrive as globals rather than imports. Declaring them here documents
+// that contract and lets `astro check` see the file as it actually runs.
+
+declare function clampRegion(
+  drag: { x1: number; y1: number; x2: number; y2: number },
+  viewport: { w: number; h: number },
+): { x: number; y: number; w: number; h: number } | null;
+
+declare function captionFor(input: {
+  url: string;
+  source: string | null;
+  region: { x: number; y: number; w: number; h: number };
+  sha: string;
+}): string;
+
+declare function targetUrl(input: {
+  repo: string;
+  pr: number;
+  source: string | null;
+  anchors: Record<string, { anchor: string; ranges: [number, number][] }> | null;
+}): string;
diff --git a/scripts/preview/publish.mjs b/scripts/preview/publish.mjs
index 05895f2..57c62aa 100644
--- a/scripts/preview/publish.mjs
+++ b/scripts/preview/publish.mjs
@@ -149,7 +149,7 @@ export async function run({
         force: only === pr,
       });
       if (published && only === pr) {
-        await gh.upsertComment(pr, ARMED_MARKER, armedBody(pr, dispatchedBy));
+        await gh.upsertComment(pr, ARMED_MARKER, armedBody(dispatchedBy));
       }
     } catch (err) {
       console.error(`preview: publish failed for #${pr}: ${err.message}`);
@@ -213,24 +213,24 @@ async function publishOne({
 
   const build = await gh.latestSuccessfulBuild(headSha);
   if (!build) {
-    await gh.upsertComment(pr, MARKER, waitingBody(pr, headSha));
+    await gh.upsertComment(pr, MARKER, waitingBody(headSha));
     return false;
   }
 
   const artifact = await fetchArtifact(build.id);
   if (!artifact) {
-    await gh.upsertComment(pr, MARKER, waitingBody(pr, headSha));
+    await gh.upsertComment(pr, MARKER, waitingBody(headSha));
     return false;
   }
 
   const check = validateMeta(artifact.meta, { number: pr, headSha });
   if (!check.ok) {
-    await gh.upsertComment(pr, MARKER, refusedBody(pr, check.reason));
+    await gh.upsertComment(pr, MARKER, refusedBody(check.reason));
     return false;
   }
 
   if (!artifact.dir) {
-    await gh.upsertComment(pr, MARKER, refusedBody(pr, "artifact had no extracted directory"));
+    await gh.upsertComment(pr, MARKER, refusedBody("artifact had no extracted directory"));
     return false;
   }
 
@@ -240,11 +240,11 @@ async function publishOne({
   try {
     unsafe = await findUnsafeEntries(artifact.dir);
   } catch (err) {
-    await gh.upsertComment(pr, MARKER, refusedBody(pr, `could not screen the artifact: ${err.message}`));
+    await gh.upsertComment(pr, MARKER, refusedBody(`could not screen the artifact: ${err.message}`));
     return false;
   }
   if (unsafe.length) {
-    await gh.upsertComment(pr, MARKER, refusedBody(pr, `unsafe entries: ${unsafe.join(", ")}`));
+    await gh.upsertComment(pr, MARKER, refusedBody(`unsafe entries: ${unsafe.join(", ")}`));
     return false;
   }
 
@@ -321,18 +321,18 @@ const publishedBody = (pr, sha) =>
   `### Preview published\n\n${previewUrl(pr)}\n\nBuilt from \`${sha.slice(0, 7)}\`. ` +
   `Staging takes a few minutes to pick up a new push.`;
 
-const waitingBody = (pr, sha) =>
+const waitingBody = (sha) =>
   `### Preview waiting on a build\n\nNo successful build for \`${sha.slice(0, 7)}\` yet. ` +
   `The preview publishes on the next run after the build goes green.`;
 
-const refusedBody = (pr, reason) =>
+const refusedBody = (reason) =>
   `### Preview could not be published\n\nThe build artifact was refused: ${String(reason).slice(0, 200)}`;
 
 const retiredBody = (pr) =>
   `### Preview retired\n\nThe preview for this pull request is no longer published. ` +
   `${previewUrl(pr)} now serves a notice instead.`;
 
-const armedBody = (pr, by) =>
+const armedBody = (by) =>
   `### Preview armed by manual dispatch\n\n` +
   (by ? `@${by} published this preview by dispatching the workflow.` : `This preview was published by manual dispatch.`) +
   ` It will keep tracking this PR's head commit until the PR closes.`;
diff --git a/src/components/JsonLd.astro b/src/components/JsonLd.astro
index fd8d421..b282f1b 100644
--- a/src/components/JsonLd.astro
+++ b/src/components/JsonLd.astro
@@ -72,7 +72,7 @@ const payload = {
 const json = JSON.stringify(payload).replace(/</g, "\\u003c");
 ---
 
-<script type="application/ld+json" set:html={json} />
+<script is:inline type="application/ld+json" set:html={json} />
 {markdownPath && (
   <link rel="alternate" type="text/markdown" href={`${SITE_URL}${markdownPath}`} />
 )}
diff --git a/src/content.config.ts b/src/content.config.ts
index d3ee572..8a2f2e6 100644
--- a/src/content.config.ts
+++ b/src/content.config.ts
@@ -1,4 +1,5 @@
-import { defineCollection, z } from "astro:content";
+import { defineCollection } from "astro:content";
+import { z } from "astro/zod";
 import { glob } from "astro/loaders";
 
 const docs = defineCollection({