Repository navigation
Show models powering auto in attribution footers #74985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5aa0ad9
e7842a3
1efe3ca
19c5e34
80fd66f
3d83344
0c7589c
d6f34ac
a69a49d
2bf81a3
aced810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ | |
| */ | ||
| import { describe, it, expect, beforeEach, vi } from "vitest"; | ||
| import path from "path"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import { fileURLToPath } from "url"; | ||
|
|
||
| // Mock core for GitHub Actions environment | ||
|
|
@@ -177,6 +179,41 @@ describe("messages.cjs", () => { | |
| }); | ||
|
|
||
| describe("getFooterMessage", () => { | ||
| it.each([false, true])("shows the model powering auto in default and custom credit footers (custom: %s)", async custom => { | ||
| const root = fs.mkdtempSync(path.join(os.tmpdir(), "gh-aw-auto-footer-")); | ||
| const environmentKeys = ["GH_AW_SAFE_OUTPUT_MESSAGES", "GH_AW_TMP_DIR", "GH_AW_ENGINE_ID", "GH_AW_ENGINE_MODEL", "GH_AW_AGENT_AIC", "GH_AW_THREAT_DETECTION_AIC", "GH_AW_AMBIENT_CONTEXT"]; | ||
| const environment = new Map(environmentKeys.map(key => [key, process.env[key]])); | ||
| try { | ||
| process.env.GH_AW_TMP_DIR = root; | ||
| process.env.GH_AW_ENGINE_ID = "copilot"; | ||
| process.env.GH_AW_ENGINE_MODEL = "auto"; | ||
| process.env.GH_AW_AGENT_AIC = "14"; | ||
| process.env.GH_AW_THREAT_DETECTION_AIC = "1"; | ||
| process.env.GH_AW_AMBIENT_CONTEXT = "9200"; | ||
| if (custom) process.env.GH_AW_SAFE_OUTPUT_MESSAGES = JSON.stringify({ footer: "> Generated by [{workflow_name}]({run_url}){ai_credits_suffix}{history_link}" }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test leaks process-wide environment variables into subsequent tests, making footer assertions order-dependent and potentially causing unrelated tests to use the custom template and deleted temp directory. 💡 Restore the environment after each parameterized caseSnapshot the relevant
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in e7842a3: the footer test now snapshots and restores every environment variable it mutates, including the template, temp directory, engine, and AIC/context values. |
||
| fs.writeFileSync(path.join(root, "aw_info.json"), JSON.stringify({ requested_model: "auto", model_selection: { status: "observed", effective_model: "gemini-3.8-flash" } })); | ||
| fs.mkdirSync(path.join(root, "usage"), { recursive: true }); | ||
| fs.writeFileSync( | ||
| path.join(root, "usage/aw_session.jsonl"), | ||
| [ | ||
| { type: "firewall.token_usage", data: { model: "gemini-3.8-flash", purpose: "agent" }, provenance: { component: "firewall", phase: "agent" } }, | ||
| { type: "firewall.token_usage", data: { model: "claude-sonnet-5", purpose: "agent" }, provenance: { component: "firewall", phase: "agent" } }, | ||
| ] | ||
| .map(event => JSON.stringify(event)) | ||
| .join("\n") | ||
| ); | ||
| const { getFooterMessage } = await import("./messages.cjs"); | ||
| const result = getFooterMessage({ workflowName: "Test Workflow", runUrl: "https://github.com/test/repo/actions/runs/123", historyUrl: "https://github.com/search" }); | ||
| expect(result).toContain(" · copilot · auto (Gemini 3.8 Flash, Claude Sonnet 5) · \\~14 AIC · ⌖ \\~1 AIC · ⊞ 9.2K · [◷]"); | ||
| } finally { | ||
| fs.rmSync(root, { recursive: true, force: true }); | ||
| for (const [key, value] of environment) { | ||
| if (value === undefined) delete process.env[key]; | ||
| else process.env[key] = value; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it("should return default footer when no custom config", async () => { | ||
| const { getFooterMessage } = await import("./messages.cjs"); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.