diff --git a/actions/setup/js/expired_entity_search_helpers.cjs b/actions/setup/js/expired_entity_search_helpers.cjs index 85637129a1..0d7a7f8cb3 100644 --- a/actions/setup/js/expired_entity_search_helpers.cjs +++ b/actions/setup/js/expired_entity_search_helpers.cjs @@ -1,7 +1,7 @@ // @ts-check /// -const { EXPIRATION_PATTERN } = require("./ephemerals.cjs"); +const { EXPIRATION_PATTERN, LEGACY_EXPIRATION_PATTERN } = require("./ephemerals.cjs"); /** * Configuration for entity-specific GraphQL search @@ -109,10 +109,11 @@ async function searchEntitiesWithExpiration(github, owner, repo, config) { continue; } - // Check if has expiration marker with checked checkbox + // Check if has expiration marker with checked checkbox (try both new and legacy formats) const match = entity.body ? entity.body.match(EXPIRATION_PATTERN) : null; + const legacyMatch = !match && entity.body ? entity.body.match(LEGACY_EXPIRATION_PATTERN) : null; - if (match) { + if (match || legacyMatch) { withExpirationCount++; // Deduplicate if enabled (discussions may have duplicates across pages) @@ -125,7 +126,9 @@ async function searchEntitiesWithExpiration(github, owner, repo, config) { seenIds.add(entity.id); } - core.info(` Found ${config.entityType.slice(0, -1)} #${entity.number} with expiration marker: "${match[1]}" - ${entity.title}`); + const expirationValue = match ? match[1] : legacyMatch ? legacyMatch[1] : "unknown"; + const format = match ? "new" : "legacy"; + core.info(` Found ${config.entityType.slice(0, -1)} #${entity.number} with expiration marker (${format} format): "${expirationValue}" - ${entity.title}`); items.push(entity); } } diff --git a/actions/setup/js/expired_entity_search_helpers.test.cjs b/actions/setup/js/expired_entity_search_helpers.test.cjs index 9aaf2f72a8..c05fcea7fb 100644 --- a/actions/setup/js/expired_entity_search_helpers.test.cjs +++ b/actions/setup/js/expired_entity_search_helpers.test.cjs @@ -201,6 +201,48 @@ describe("searchEntitiesWithExpiration", () => { expect(result.stats.totalScanned).toBe(2); }); + it("should find issues with legacy expiration format (without HTML comment)", async () => { + const legacyFormatIssue = { + id: "issue-legacy", + number: 12667, + title: "Legacy Format Issue", + url: "https://github.com/test-owner/test-repo/issues/12667", + body: "> AI generated by workflow\n\n> - [x] expires on Jan 31, 2026, 6:04 AM UTC", + createdAt: "2026-01-30T04:04:42Z", + }; + + const newFormatIssue = { + id: "issue-new", + number: 123, + title: "New Format Issue", + url: "https://github.com/test-owner/test-repo/issues/123", + body: "> AI generated by workflow\n\n> - [x] expires on Dec 31, 2026, 11:59 PM UTC", + createdAt: "2026-01-01T00:00:00Z", + }; + + mockGithub = { + graphql: vi.fn().mockResolvedValue({ + repository: { + issues: { + pageInfo: { hasNextPage: false, endCursor: null }, + nodes: [legacyFormatIssue, newFormatIssue], + }, + }, + }), + }; + + const result = await searchEntitiesWithExpiration(mockGithub, owner, repo, { + entityType: "issues", + graphqlField: "issues", + resultKey: "issues", + }); + + expect(result.items).toHaveLength(2); + expect(result.items).toContainEqual(legacyFormatIssue); + expect(result.items).toContainEqual(newFormatIssue); + expect(result.stats.totalScanned).toBe(2); + }); + it("should handle pagination correctly", async () => { const page1Issue = { id: "issue-1", @@ -423,7 +465,7 @@ describe("searchEntitiesWithExpiration", () => { expect(global.core.info).toHaveBeenCalledWith("Starting GraphQL search for open issues in test-owner/test-repo"); expect(global.core.info).toHaveBeenCalledWith("Fetching page 1 of open issues (cursor: initial)"); expect(global.core.info).toHaveBeenCalledWith("Page 1: Retrieved 1 open issues (total scanned: 1)"); - expect(global.core.info).toHaveBeenCalledWith(expect.stringContaining("Found issue #123 with expiration marker:")); + expect(global.core.info).toHaveBeenCalledWith(expect.stringMatching(/Found issue #123 with expiration marker \((new|legacy) format\):/)); expect(global.core.info).toHaveBeenCalledWith("Search complete: Scanned 1 issues across 1 pages, found 1 with expiration markers"); }); });