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
5 changes: 5 additions & 0 deletions actions/setup/js/close_entity_helpers.test.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi } from "vitest";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const mockCore = { debug: vi.fn(), info: vi.fn(), warning: vi.fn(), error: vi.fn(), setFailed: vi.fn(), setOutput: vi.fn(), summary: { addRaw: vi.fn().mockReturnThis(), write: vi.fn().mockResolvedValue() } },
mockContext = { eventName: "issues", runId: 12345, repo: { owner: "testowner", repo: "testrepo" }, payload: { issue: { number: 42 }, pull_request: { number: 100 }, repository: { html_url: "https://github.com/testowner/testrepo" } } };
((global.core = mockCore), (global.context = mockContext));
Expand All @@ -14,6 +15,10 @@ describe("close_entity_helpers", () => {
delete process.env.GH_AW_CLOSE_PR_REQUIRED_LABELS,
delete process.env.GH_AW_CLOSE_PR_REQUIRED_TITLE_PREFIX,
delete process.env.GH_AW_CLOSE_PR_TARGET,
// Point GH_AW_PROMPTS_DIR to the source md/ directory so getPromptPath()
// resolves template files from the source tree in test environments where
// RUNNER_TEMP is set but the runtime prompts directory is not populated.
(process.env.GH_AW_PROMPTS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "../md")),
(global.context.eventName = "issues"),
Comment on lines +18 to 22
(global.context.payload.issue = { number: 42 }),
(global.context.payload.pull_request = { number: 100 }));
Expand Down
6 changes: 6 additions & 0 deletions actions/setup/js/messages.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* - Run status messages (started, success, failure)
*/
import { describe, it, expect, beforeEach, vi } from "vitest";
import path from "path";
import { fileURLToPath } from "url";

// Mock core for GitHub Actions environment
const mockCore = {
Expand All @@ -36,6 +38,10 @@ describe("messages.cjs", () => {
delete process.env.GH_AW_EFFECTIVE_TOKENS;
delete process.env.GH_AW_DETECTION_CONCLUSION;
delete process.env.GH_AW_DETECTION_REASON;
// Point GH_AW_PROMPTS_DIR to the source md/ directory so getPromptPath()
// resolves template files from the source tree in test environments where
// RUNNER_TEMP is set but the runtime prompts directory is not populated.
process.env.GH_AW_PROMPTS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "../md");
// Clear cache by reimporting
vi.resetModules();
Comment on lines +41 to 46
});
Expand Down
5 changes: 2 additions & 3 deletions actions/setup/js/messages_footer.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* for safe-output workflows.
*/

const path = require("path");
const { getMessages, renderTemplate, renderTemplateFromFile, toSnakeCase } = require("./messages_core.cjs");
const { getMessages, renderTemplate, renderTemplateFromFile, toSnakeCase, getPromptPath } = require("./messages_core.cjs");
const { getMissingInfoSections } = require("./missing_messages_helper.cjs");
const { getBlockedDomains, generateBlockedDomainsSection } = require("./firewall_blocked_domains.cjs");
const { getDifcFilteredEvents, generateDifcFilteredSection } = require("./gateway_difc_filtered.cjs");
Expand Down Expand Up @@ -132,7 +131,7 @@ function getFooterInstallMessage(ctx) {
// Create context with both camelCase and snake_case keys, including computed agentic_workflow_url
const templateContext = toSnakeCase({ ...ctx, agenticWorkflowUrl });

const defaultInstallTemplatePath = path.join(__dirname, "../md/workflow_install_note.md");
const defaultInstallTemplatePath = getPromptPath("workflow_install_note.md");

// Use custom installation message if configured
Comment on lines 132 to 136
return messages?.footerInstall ? renderTemplate(messages.footerInstall, templateContext) : renderTemplateFromFile(defaultInstallTemplatePath, templateContext);
Expand Down
14 changes: 14 additions & 0 deletions actions/setup/js/pr_review_buffer.test.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import path from "path";
import { fileURLToPath } from "url";

const mockCore = {
debug: vi.fn(),
Expand Down Expand Up @@ -28,6 +30,7 @@ const { createReviewBuffer } = require("./pr_review_buffer.cjs");
describe("pr_review_buffer (factory pattern)", () => {
let buffer;
let originalMessages;
let originalPromptsDir;

beforeEach(() => {
vi.clearAllMocks();
Expand All @@ -36,6 +39,12 @@ describe("pr_review_buffer (factory pattern)", () => {
originalMessages = process.env.GH_AW_SAFE_OUTPUT_MESSAGES;
delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES;

// Point GH_AW_PROMPTS_DIR to the source md/ directory so getPromptPath()
// resolves template files from the source tree in test environments where
// RUNNER_TEMP is set but the runtime prompts directory is not populated.
originalPromptsDir = process.env.GH_AW_PROMPTS_DIR;
process.env.GH_AW_PROMPTS_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "../md");

// Default: return empty file list so path filtering is skipped unless explicitly mocked
mockGithub.rest.pulls.listFiles.mockResolvedValue({ data: [] });

Expand All @@ -50,6 +59,11 @@ describe("pr_review_buffer (factory pattern)", () => {
} else {
delete process.env.GH_AW_SAFE_OUTPUT_MESSAGES;
}
if (originalPromptsDir !== undefined) {
process.env.GH_AW_PROMPTS_DIR = originalPromptsDir;
} else {
delete process.env.GH_AW_PROMPTS_DIR;
}
});

it("should create independent buffer instances", () => {
Expand Down