Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/docs-publish-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ jobs:
continue
fi
preview_url="https://${FERN_ORG}-preview-${preview_id}.docs.buildwithfern.com${INSTANCE_PATH}"
npx --yes "fern-api@${FERN_VERSION}" docs preview delete "$preview_url"
if ! delete_output=$(npx --yes "fern-api@${FERN_VERSION}" docs preview delete "$preview_url" 2>&1); then
if grep -Fxq "Domain not registered" <<< "$delete_output"; then
echo "::notice::Fern preview ${preview_id} does not exist."
continue
Comment on lines +133 to +136

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Match the complete Fern response, not any matching line.

grep -Fxq succeeds if any individual line matches, so a response such as Domain not registered\nAuthentication failed would incorrectly allow cleanup to pass. Compare delete_output as a whole and add a mixed-output regression case.

Proposed fix
-              if grep -Fxq "Domain not registered" <<< "$delete_output"; then
+              if [[ "$delete_output" == "Domain not registered" ]]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! delete_output=$(npx --yes "fern-api@${FERN_VERSION}" docs preview delete "$preview_url" 2>&1); then
if grep -Fxq "Domain not registered" <<< "$delete_output"; then
echo "::notice::Fern preview ${preview_id} does not exist."
continue
if ! delete_output=$(npx --yes "fern-api@${FERN_VERSION}" docs preview delete "$preview_url" 2>&1); then
if [[ "$delete_output" == "Domain not registered" ]]; then
echo "::notice::Fern preview ${preview_id} does not exist."
continue
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/docs-publish-staging.yaml around lines 133 - 136, Update
the cleanup check around the preview deletion command to compare the entire
delete_output value against the exact “Domain not registered” response, rather
than matching an individual line with grep. Preserve the existing notice and
continue behavior only for an exact response, and add a regression case covering
mixed output such as “Domain not registered” plus “Authentication failed.”

fi
printf '%s\n' "$delete_output" >&2
exit 1
fi
printf '%s\n' "$delete_output"
echo "Deleted Fern preview ${preview_id}."
done <<< "$PREVIEW_IDS"
38 changes: 38 additions & 0 deletions test/docs-publish-staging-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,42 @@ describe("staging docs preview cleanup", () => {
rmSync(temp, { force: true, recursive: true });
}
});

it.each([
[0, "Domain not registered", "Fern preview pr-123 does not exist."],
[1, "Authentication failed", "Authentication failed"],
])("returns exit status %i when Fern reports %s", (expectedStatus, fernError, expectedOutput) => {
const deleteStep = requiredStep(workflow.jobs["delete-preview"]?.steps, "Delete Fern previews");
const temp = mkdtempSync(join(tmpdir(), "nemoclaw-fern-preview-cleanup-error-"));
const fakeBin = join(temp, "bin");
mkdirSync(fakeBin);
writeFileSync(
join(fakeBin, "npx"),
[
"#!/usr/bin/env node",
"process.stderr.write(`${process.env.FERN_ERROR}\\n`);",
"process.exit(1);",
].join("\n"),
{ mode: 0o755 },
);

try {
const result = spawnSync("bash", ["-c", deleteStep.run ?? ""], {
encoding: "utf8",
env: {
...process.env,
FERN_ERROR: fernError,
FERN_STAGING_INSTANCE: "nvidia-nemoclaw-staging.docs.buildwithfern.com/nemoclaw",
FERN_TOKEN: "test-token",
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
PREVIEW_IDS: "pr-123",
},
});

expect(result.status).toBe(expectedStatus);
expect(`${result.stdout}${result.stderr}`).toContain(expectedOutput);
} finally {
rmSync(temp, { force: true, recursive: true });
}
});
});
Loading