Skip to content
Open
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
25 changes: 3 additions & 22 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

36 changes: 3 additions & 33 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ export async function run(): Promise<void> {

const event = github.context.eventName;
let changedFiles = '';
let baseRef: string | undefined;
let headRef: string | undefined;
let isPullRequest = false;
let pullRequestNumber: number | undefined;

Expand All @@ -237,35 +235,8 @@ export async function run(): Promise<void> {
isPullRequest = true;
pullRequestNumber = pullRequest.number;

// Get list of changed files in PR
baseRef = pullRequest.base.ref;
headRef = pullRequest.head.ref;

if (!baseRef || !headRef) {
throw new Error(
'Unable to determine base or head references from pull request',
);
}

// Validate baseRef and headRef to prevent option injection
validateGitRef(baseRef);
validateGitRef(headRef);

await gitInterface.fetch(['--', 'origin', baseRef]);
const baseFetchHead = (
await gitInterface.revparse(['FETCH_HEAD'])
).trim();

await gitInterface.fetch(['--', 'origin', headRef]);
const headFetchHead = (
await gitInterface.revparse(['FETCH_HEAD'])
).trim();

changedFiles = await gitInterface.diff([
'--name-only',
baseFetchHead,
headFetchHead,
]);
// This code here somehow was getting stuck on "Getting changed files" forever.
// Removing it as it is not necessary. We rely on GitHub's own detection of changed files.
} else if (event === 'workflow_dispatch') {
core.info('Running in workflow_dispatch mode');

Expand Down Expand Up @@ -454,8 +425,7 @@ export async function run(): Promise<void> {
core.endGroup();

const outputFile = path.join(workingDirectory, 'output.json');
const outputFileHtml = path.join(workingDirectory, 'output.html');
let promptfooArgs = ['eval', '-c', configPath, '-o', outputFile, '-o', outputFileHtml];
let promptfooArgs = ['eval', '-c', configPath, '-o', outputFile];
if (!useConfigPrompts && promptFiles.length > 0) {
promptfooArgs = promptfooArgs.concat(['--prompts', ...promptFiles]);
}
Expand Down