From 79ab3fe393c6d63f39c133accb924fa36dd69ea8 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 27 Jul 2026 08:35:33 -0700 Subject: [PATCH 1/4] pull preview links from build report --- actions/preview-link-generator/README.md | 2 +- .../__tests__/pull-updater.test.ts | 347 +++--------- actions/preview-link-generator/action.yml | 2 +- actions/preview-link-generator/dist/index.js | 518 ++++++++---------- .../preview-link-generator/dist/index.js.map | 2 +- .../src/pull-updater.ts | 501 +++++++++-------- .../src/types/ChangeType.ts | 7 - .../src/types/FileChange.ts | 8 - .../src/types/NodeOf.ts | 3 - .../src/types/PageInfo.ts | 4 - .../preview-link-generator/src/types/Pull.ts | 15 - .../src/types/PullRequestDetails.ts | 9 +- .../src/types/PullRequestState.ts | 4 - 13 files changed, 555 insertions(+), 867 deletions(-) delete mode 100644 actions/preview-link-generator/src/types/ChangeType.ts delete mode 100644 actions/preview-link-generator/src/types/FileChange.ts delete mode 100644 actions/preview-link-generator/src/types/NodeOf.ts delete mode 100644 actions/preview-link-generator/src/types/PageInfo.ts delete mode 100644 actions/preview-link-generator/src/types/Pull.ts delete mode 100644 actions/preview-link-generator/src/types/PullRequestState.ts diff --git a/actions/preview-link-generator/README.md b/actions/preview-link-generator/README.md index fe1194e6..8d134395 100644 --- a/actions/preview-link-generator/README.md +++ b/actions/preview-link-generator/README.md @@ -1,6 +1,6 @@ # Preview link generator GitHub Action -This action updates a pull request body with preview links for changed markdown and YAML files. +This action updates a pull request body with preview links extracted from the OpenPublishing.Build report after the OPS status check completes. ## Usage diff --git a/actions/preview-link-generator/__tests__/pull-updater.test.ts b/actions/preview-link-generator/__tests__/pull-updater.test.ts index 928e2204..53cfdeef 100644 --- a/actions/preview-link-generator/__tests__/pull-updater.test.ts +++ b/actions/preview-link-generator/__tests__/pull-updater.test.ts @@ -1,18 +1,14 @@ import { exportedForTesting } from "../src/pull-updater"; import { describe, expect, it } from "@jest/globals"; import { WorkflowInput, workflowInput } from "../src/types/WorkflowInput"; -import { PullRequestDetails } from "../src/types/PullRequestDetails"; const { appendTable, - buildMarkdownPreviewTable, - getModifiedPreviewEnabledFiles, - isFilePreviewEnabled, - isPullRequestModifyingPreviewEnabledFiles, + buildMarkdownPreviewTableFromExtractedLinks, + extractPreviewLinksFromBuildReport, PREVIEW_TABLE_END, PREVIEW_TABLE_START, replaceExistingTable, - toPreviewLink, } = exportedForTesting; beforeAll(() => { @@ -81,30 +77,6 @@ ${PREVIEW_TABLE_END}`; expect(actual).toEqual(expectedBody); }); - it("buildMarkdownPreviewTable builds preview table correctly", async () => { - setInput("DOCS_PATH", "docs"); - setInput("URL_BASE_PATH", "dotnet"); - - const actual = await buildMarkdownPreviewTable( - 7, - [ - { - additions: 1, - deletions: 1, - path: "test/markdown.md", - changeType: "MODIFIED", - }, - ], - "", - "oid", - false, - false - ); - expect(actual).toEqual( - `#### Internal previews\n\n| 📄 File | 🔗 Preview link |\n|:--|:--|\n| [test/markdown.md](https://github.com/dotnet/docs/blob/oid/test/markdown.md) | [test/markdown](https://review.learn.microsoft.com/en-us/dotnet/test/markdown?branch=pr-en-us-7) |\n` - ); - }); - it("options are correctly constructed with expected values from import", () => { setInput("COLLAPSIBLE_AFTER", "7"); setInput("DOCS_PATH", "test/path"); @@ -141,269 +113,82 @@ ${PREVIEW_TABLE_END}`; compareMaps(map, opts.opaqueLeadingUrlSegments); }); - - it("buildMarkdownPreviewTable builds preview table correctly with collapsible HTML elements.", async () => { - setInput("COLLAPSIBLE_AFTER", "3"); - setInput("DOCS_PATH", "docs"); - setInput("URL_BASE_PATH", "dotnet"); - - const actual = await buildMarkdownPreviewTable( - 7, - [ - { - additions: 1, - deletions: 1, - path: "1/one.md", - changeType: "MODIFIED", - }, - { - additions: 1, - deletions: 1, - path: "2/two.md", - changeType: "MODIFIED", - }, - { - additions: 1, - deletions: 1, - path: "__tests__/3/three.md", - changeType: "MODIFIED", - }, - { - additions: 1, - deletions: 1, - path: "4/four.md", - changeType: "MODIFIED", - }, - { - additions: 1, - deletions: 1, - path: "5/five.md", - changeType: "MODIFIED", - }, - ], - "", - "oid", - false, - false + it("extractPreviewLinksFromBuildReport parses file to preview URL map", () => { + const html = ` + +
+| File | Status | Preview URL | +
| docs/a.md | +Updated | +a | +
| docs/b.yml | +Updated | +b | +