-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add /benchmark github command to comparison benchmark between base and pr commit
#9461
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8fe7ffa
Try running a basic comparison benchmark between base and pr commit
gruuya 831c6ea
Add job for commenting benchmark results on the PR
gruuya d01f559
Trigger benchmark workflow on a pr comment to avoid noise
gruuya a712552
Remove the temp code in step and polish results comment
gruuya 81a2e5f
Update .github/workflows/pr_comment.yml
gruuya a717a97
Update .github/workflows/pr_benchmarks.yml
gruuya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Runs the benchmark command on the PR and | ||
| # on the branch, posting the results as a comment back the PR | ||
| name: Benchmarks | ||
|
|
||
| on: | ||
| issue_comment: | ||
|
|
||
| jobs: | ||
| benchmark: | ||
| name: Run Benchmarks | ||
| runs-on: ubuntu-latest | ||
| if: github.event.issue.pull_request && contains(github.event.comment.body, '/benchmark') | ||
| steps: | ||
| - name: Dump GitHub context | ||
| env: | ||
| GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
| run: echo "$GITHUB_CONTEXT" | ||
|
|
||
| - name: Checkout PR changes | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: refs/pull/${{ github.event.issue.number }}/head | ||
|
|
||
| - name: Setup data and generate unique result names | ||
| run: | | ||
| cd benchmarks | ||
| mkdir data | ||
|
|
||
| # Setup the TPC-H data set with a scale factor of 10 | ||
| ./bench.sh data tpch | ||
|
|
||
| # Generate a unique-ish identifiers for the results | ||
| echo "HEAD_LONG_SHA=$(git log -1 --format='%H')" >> "$GITHUB_ENV" | ||
| echo "HEAD_SHORT_SHA=$(git log -1 --format='%h' --abbrev=7)" >> "$GITHUB_ENV" | ||
| echo "BASE_SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Benchmark PR changes | ||
| env: | ||
| RESULTS_NAME: ${{ env.HEAD_SHORT_SHA }} | ||
| run: | | ||
| cd benchmarks | ||
|
|
||
| ./bench.sh run tpch | ||
|
|
||
| - name: Checkout base commit | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.sha }} | ||
| clean: false | ||
|
|
||
| - name: Benchmark baseline and generate comparison message | ||
| env: | ||
| RESULTS_NAME: ${{ env.BASE_SHORT_SHA }} | ||
| run: | | ||
| cd benchmarks | ||
|
|
||
| ./bench.sh run tpch | ||
|
|
||
| echo ${{ github.event.issue.number }} > pr | ||
|
|
||
| pip3 install rich | ||
| cat > message.md <<EOF | ||
| # Benchmark results | ||
|
|
||
| <details> | ||
| <summary>Benchmarks comparing ${{ github.sha }} (main) and ${{ env.HEAD_LONG_SHA }} (PR)</summary> | ||
|
|
||
| \`\`\` | ||
| $(./bench.sh compare ${{ env.BASE_SHORT_SHA }} ${{ env.HEAD_SHORT_SHA }}) | ||
| \`\`\` | ||
|
|
||
| </details> | ||
| EOF | ||
|
|
||
| cat message.md | ||
|
|
||
| - name: Upload benchmark comparison message | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: message | ||
| path: benchmarks/message.md | ||
|
|
||
| - name: Upload PR number | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pr | ||
| path: benchmarks/pr | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Downloads any `message` artifacts created by other jobs | ||
| # and posts them as comments to the PR | ||
| name: PR Comment | ||
gruuya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Benchmarks"] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| comment: | ||
| name: PR Comment | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.conclusion == 'success' | ||
| steps: | ||
| - name: Dump GitHub context | ||
| env: | ||
| GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
| run: echo "$GITHUB_CONTEXT" | ||
|
|
||
| - name: Download comment message | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: message | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Download pr number | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: pr | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Print message and pr number | ||
| run: | | ||
| cat pr | ||
| echo "PR_NUMBER=$(cat pr)" >> "$GITHUB_ENV" | ||
| cat message.md | ||
|
|
||
| - name: Post the comment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const content = fs.readFileSync('message.md', 'utf8'); | ||
| github.rest.issues.createComment({ | ||
| issue_number: process.env.PR_NUMBER, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: content, | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.