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
1 change: 1 addition & 0 deletions .github/workflows/auto-triage-issues.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/workflows/breaking-change-checker.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/workflows/contribution-check.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .github/workflows/smoke-copilot.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions actions/setup/js/run_evals.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ async function setupMain() {
async function parseMain() {
const questionsRaw = process.env.GH_AW_EVALS_QUESTIONS;
const model = process.env.GH_AW_EVALS_MODEL || "";
const runID = process.env.GITHUB_RUN_ID || "unknown";

/** @type {Array<{id: string, question: string}>} */
let questions = [];
Expand Down Expand Up @@ -147,6 +148,7 @@ async function parseMain() {
answer,
model,
timestamp,
runid: runID,
Comment thread
pelikhan marked this conversation as resolved.
Comment thread
pelikhan marked this conversation as resolved.
};
results.push(record);
core.info(`Q[${q.id}]: ${answer}`);
Expand Down
77 changes: 77 additions & 0 deletions actions/setup/js/run_evals.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import fs from "fs";
import { createRequire } from "module";

const EVALS_DIR = "/tmp/gh-aw/evals";
const EVALS_LOG_PATH = `${EVALS_DIR}/evals.log`;
const EVALS_OUTPUT_PATH = "/tmp/gh-aw/evals.jsonl";
const require = createRequire(import.meta.url);
const { parseMain } = require("./run_evals.cjs");

const mockCore = {
info: vi.fn(),
warning: vi.fn(),
setFailed: vi.fn(),
exportVariable: vi.fn(),
summary: {
addDetails: vi.fn().mockReturnThis(),
write: vi.fn().mockResolvedValue(),
},
};

global.core = mockCore;

describe("run_evals.cjs", () => {
beforeEach(() => {
vi.clearAllMocks();
fs.mkdirSync(EVALS_DIR, { recursive: true });
if (fs.existsSync(EVALS_LOG_PATH)) {
fs.unlinkSync(EVALS_LOG_PATH);
}
if (fs.existsSync(EVALS_OUTPUT_PATH)) {
fs.unlinkSync(EVALS_OUTPUT_PATH);
}
Comment thread
pelikhan marked this conversation as resolved.
});
Comment thread
pelikhan marked this conversation as resolved.

afterEach(() => {
vi.unstubAllEnvs();
if (fs.existsSync(EVALS_LOG_PATH)) {
fs.unlinkSync(EVALS_LOG_PATH);
}
if (fs.existsSync(EVALS_OUTPUT_PATH)) {
fs.unlinkSync(EVALS_OUTPUT_PATH);
}
});

it("stores the workflow run id when writing eval records", async () => {
vi.stubEnv("GH_AW_EVALS_QUESTIONS", JSON.stringify([{ id: "labels-applied", question: "Did labels get applied?" }]));
vi.stubEnv("GH_AW_EVALS_MODEL", "small");
vi.stubEnv("GITHUB_RUN_ID", "123456789");
fs.writeFileSync(EVALS_LOG_PATH, "labels-applied: YES\n", "utf8");

await parseMain();

const lines = fs.readFileSync(EVALS_OUTPUT_PATH, "utf8").trim().split("\n");
expect(lines).toHaveLength(1);
expect(JSON.parse(lines[0])).toEqual({
id: "labels-applied",
question: "Did labels get applied?",
answer: "YES",
model: "small",
timestamp: expect.any(String),
runid: "123456789",
});
});

it('falls back to "unknown" when the workflow run id is absent', async () => {
vi.stubEnv("GH_AW_EVALS_QUESTIONS", JSON.stringify([{ id: "labels-applied", question: "Did labels get applied?" }]));
vi.stubEnv("GH_AW_EVALS_MODEL", "small");
vi.stubEnv("GITHUB_RUN_ID", "");
fs.writeFileSync(EVALS_LOG_PATH, "labels-applied: YES\n", "utf8");

await parseMain();

const [line] = fs.readFileSync(EVALS_OUTPUT_PATH, "utf8").trim().split("\n");
expect(JSON.parse(line).runid).toBe("unknown");
});
});
1 change: 1 addition & 0 deletions pkg/workflow/evals_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ await main();`
fmt.Sprintf(" GH_AW_EVALS_QUESTIONS: '%s'\n", escapeYAMLSingleQuoted(questionsJSON)),
fmt.Sprintf(" GH_AW_EVALS_MODEL: %q\n", model),
" GH_AW_EVALS_PHASE: parse\n",
" GITHUB_RUN_ID: ${{ github.run_id }}\n",
" with:\n",
" script: |\n",
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/workflow/evals_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func TestBuildEvalsJobStepsRenderSummary(t *testing.T) {
if renderIdx >= 0 && uploadIdx >= 0 && renderIdx >= uploadIdx {
t.Errorf("expected render step to appear before upload step; renderIdx=%d uploadIdx=%d", renderIdx, uploadIdx)
}

}

func TestBuildEvalsJobStepsRedactionUsesEvalsSecretReferences(t *testing.T) {
Expand Down Expand Up @@ -192,4 +193,7 @@ func TestBuildParseEvalsResultsStepUsesResolvedExecutionModel(t *testing.T) {
if strings.Contains(steps, `GH_AW_EVALS_MODEL: "small"`) {
t.Errorf("expected parse step to avoid default 'small' when engine model is resolved; got:\n%s", steps)
}
if !strings.Contains(steps, "GITHUB_RUN_ID: ${{ github.run_id }}") {
t.Errorf("expected parse step to pass github.run_id through to the eval record writer; got:\n%s", steps)
}
}
Loading