Skip to content

run benchmarks from comment on pr #19

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

Merged
merged 1 commit into from
Apr 4, 2025
Merged
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
86 changes: 86 additions & 0 deletions .github/workflows/pr_comment_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,92 @@ jobs:
});

- name: Add reaction to comment
uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});

# Runs benchmarks on a PR branch when someone comments with `/benchmark benchmark1 benchmark2 ...`
run_benchmarks:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/benchmark') }}
steps:
- name: Parse benchmark arguments
id: parse
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Extract benchmark names from comment
const comment = context.payload.comment.body.trim();
const args = comment.split(/\s+/).slice(1); // Skip the command itself

// If no benchmarks specified, default to a small set
const benchmarks = args.length > 0 ? args : ['tpch_mem', 'clickbench_partitioned'];

return {
benchmarks: benchmarks
};
result-encoding: json

- name: Dispatch benchmarks for PR branch
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Get PR details
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.issue.number
});

// Extract branch info
const branchName = pullRequest.head.ref;
const headSha = pullRequest.head.sha;
const baseBranch = pullRequest.base.ref;

// Get the base branch HEAD SHA
const { data: baseRef } = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${baseBranch}`
});
const baseSha = baseRef.object.sha;

const benchmarks = ${{ toJSON(steps.parse.outputs.result) }}.benchmarks;
const commentId = context.payload.comment.id;

// Comment to notify benchmark is starting
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: `📊 Running the following benchmarks: ${benchmarks.join(', ')}\n\nComparing PR branch (\`${headSha.substring(0, 8)}\`) with base branch \`${baseBranch}\` (\`${baseSha.substring(0, 8)}\`)\n\nResults will be posted here when complete.`
});

// Create benchmark workflow file
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'pr_benchmarks.yml',
ref: branchName,
inputs: {
pr_number: context.payload.issue.number.toString(),
pr_head_sha: headSha,
base_branch: baseBranch,
base_sha: baseSha,
benchmarks: benchmarks.join(' '),
comment_id: commentId.toString()
}
});

- name: Add reaction to comment
uses: actions/github-script@v7
with:
script: |
Expand Down
Loading