2023-10-05 18:09:52 +08:00
|
|
|
name: Benchmarks (PR)
|
2023-10-12 05:18:29 +08:00
|
|
|
on: issue_comment
|
2023-10-09 20:56:41 +08:00
|
|
|
permissions:
|
|
|
|
issues: write
|
2023-10-05 18:05:01 +08:00
|
|
|
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.MEILI_BOT_GH_PAT }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
run-benchmarks-on-comment:
|
2023-10-11 20:27:51 +08:00
|
|
|
if: startsWith(github.event.comment.body, '/benchmark')
|
2023-10-05 18:05:01 +08:00
|
|
|
name: Run and upload benchmarks
|
|
|
|
runs-on: benchmarks
|
|
|
|
timeout-minutes: 4320 # 72h
|
|
|
|
steps:
|
2024-07-24 23:09:25 +08:00
|
|
|
- name: Check permissions
|
|
|
|
id: permission
|
|
|
|
env:
|
|
|
|
PR_AUTHOR: ${{github.event.issue.user.login }}
|
|
|
|
COMMENT_AUTHOR: ${{github.event.comment.user.login }}
|
|
|
|
REPOSITORY: ${{github.repository}}
|
|
|
|
PR_ID: ${{github.event.issue.number}}
|
|
|
|
run: |
|
|
|
|
PR_REPOSITORY=$(gh api /repos/"$REPOSITORY"/pulls/"$PR_ID" --jq .head.repo.full_name)
|
|
|
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$PR_AUTHOR"/permission --jq .user.permissions.push)
|
|
|
|
then
|
|
|
|
echo "::notice title=Authentication success::PR author authenticated"
|
|
|
|
else
|
|
|
|
echo "::error title=Authentication error::PR author doesn't have push permission on this repository"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if $(gh api /repos/"$REPOSITORY"/collaborators/"$COMMENT_AUTHOR"/permission --jq .user.permissions.push)
|
|
|
|
then
|
|
|
|
echo "::notice title=Authentication success::Comment author authenticated"
|
|
|
|
else
|
|
|
|
echo "::error title=Authentication error::Comment author doesn't have push permission on this repository"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ "$PR_REPOSITORY" = "$REPOSITORY" ]
|
|
|
|
then
|
|
|
|
echo "::notice title=Authentication success::PR started from main repository"
|
|
|
|
else
|
|
|
|
echo "::error title=Authentication error::PR started from a fork"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-07-29 16:06:34 +08:00
|
|
|
- uses: dtolnay/rust-toolchain@1.79
|
2023-10-05 18:05:01 +08:00
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
|
2023-10-09 20:56:41 +08:00
|
|
|
- name: Check for Command
|
|
|
|
id: command
|
|
|
|
uses: xt0rted/slash-command-action@v2
|
|
|
|
with:
|
|
|
|
command: benchmark
|
|
|
|
reaction-type: "eyes"
|
2023-10-09 22:52:04 +08:00
|
|
|
repo-token: ${{ env.GH_TOKEN }}
|
2023-10-09 20:56:41 +08:00
|
|
|
|
2024-12-02 01:52:21 +08:00
|
|
|
- uses: xt0rted/pull-request-comment-branch@v3
|
2023-10-11 18:02:44 +08:00
|
|
|
id: comment-branch
|
|
|
|
with:
|
|
|
|
repo_token: ${{ env.GH_TOKEN }}
|
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
if: success()
|
|
|
|
with:
|
2023-10-12 18:25:26 +08:00
|
|
|
fetch-depth: 0 # fetch full history to be able to get main commit sha
|
2023-10-11 18:02:44 +08:00
|
|
|
ref: ${{ steps.comment-branch.outputs.head_ref }}
|
|
|
|
|
2023-10-05 18:05:01 +08:00
|
|
|
# Set variables
|
|
|
|
- name: Set current branch name
|
|
|
|
shell: bash
|
2023-10-11 19:05:54 +08:00
|
|
|
run: echo "name=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
|
2023-10-05 18:05:01 +08:00
|
|
|
id: current_branch
|
|
|
|
- name: Set normalized current branch name # Replace `/` by `_` in branch name to avoid issues when pushing to S3
|
|
|
|
shell: bash
|
2023-10-11 19:05:54 +08:00
|
|
|
run: echo "name=$(git rev-parse --abbrev-ref HEAD | tr '/' '_')" >> $GITHUB_OUTPUT
|
2023-10-05 18:05:01 +08:00
|
|
|
id: normalized_current_branch
|
|
|
|
- name: Set shorter commit SHA
|
|
|
|
shell: bash
|
|
|
|
run: echo "short=$(echo $GITHUB_SHA | cut -c1-8)" >> $GITHUB_OUTPUT
|
|
|
|
id: commit_sha
|
|
|
|
- name: Set file basename with format "dataset_branch_commitSHA"
|
|
|
|
shell: bash
|
2023-10-09 20:56:41 +08:00
|
|
|
run: echo "basename=$(echo ${{ steps.command.outputs.command-arguments }}_${{ steps.normalized_current_branch.outputs.name }}_${{ steps.commit_sha.outputs.short }})" >> $GITHUB_OUTPUT
|
2023-10-05 18:05:01 +08:00
|
|
|
id: file
|
|
|
|
|
|
|
|
# Run benchmarks
|
2023-10-09 20:56:41 +08:00
|
|
|
- name: Run benchmarks - Dataset ${{ steps.command.outputs.command-arguments }} - Branch ${{ steps.current_branch.outputs.name }} - Commit ${{ steps.commit_sha.outputs.short }}
|
2023-10-05 18:05:01 +08:00
|
|
|
run: |
|
2024-11-05 22:08:01 +08:00
|
|
|
cd crates/benchmarks
|
2023-10-09 20:56:41 +08:00
|
|
|
cargo bench --bench ${{ steps.command.outputs.command-arguments }} -- --save-baseline ${{ steps.file.outputs.basename }}
|
2023-10-05 18:05:01 +08:00
|
|
|
|
|
|
|
# Generate critcmp files
|
|
|
|
- name: Install critcmp
|
|
|
|
uses: taiki-e/install-action@v2
|
|
|
|
with:
|
|
|
|
tool: critcmp
|
|
|
|
- name: Export cripcmp file
|
|
|
|
run: |
|
|
|
|
critcmp --export ${{ steps.file.outputs.basename }} > ${{ steps.file.outputs.basename }}.json
|
|
|
|
|
|
|
|
# Upload benchmarks
|
|
|
|
- name: Upload ${{ steps.file.outputs.basename }}.json to DO Spaces # DigitalOcean Spaces = S3
|
|
|
|
uses: BetaHuhn/do-spaces-action@v2
|
|
|
|
with:
|
|
|
|
access_key: ${{ secrets.DO_SPACES_ACCESS_KEY }}
|
|
|
|
secret_key: ${{ secrets.DO_SPACES_SECRET_KEY }}
|
|
|
|
space_name: ${{ secrets.DO_SPACES_SPACE_NAME }}
|
|
|
|
space_region: ${{ secrets.DO_SPACES_SPACE_REGION }}
|
|
|
|
source: ${{ steps.file.outputs.basename }}.json
|
|
|
|
out_dir: critcmp_results
|
|
|
|
|
|
|
|
# Compute the diff of the benchmarks and send a message on the GitHub PR
|
|
|
|
- name: Compute and send a message in the PR
|
2023-10-10 00:04:49 +08:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.MEILI_BOT_GH_PAT }}
|
2023-10-05 18:05:01 +08:00
|
|
|
run: |
|
2023-10-12 17:54:56 +08:00
|
|
|
set -x
|
2023-10-12 21:04:37 +08:00
|
|
|
export base_ref=$(git merge-base origin/main ${{ steps.comment-branch.outputs.head_ref }} | head -c8)
|
2023-10-11 20:57:03 +08:00
|
|
|
export base_filename=$(echo ${{ steps.command.outputs.command-arguments }}_main_${base_ref}.json)
|
2023-11-15 20:56:54 +08:00
|
|
|
export bench_name=$(echo ${{ steps.command.outputs.command-arguments }})
|
|
|
|
echo "Here are your $bench_name benchmarks diff 👊" >> body.txt
|
2023-10-05 18:05:01 +08:00
|
|
|
echo '```' >> body.txt
|
2023-10-11 20:57:03 +08:00
|
|
|
./benchmarks/scripts/compare.sh $base_filename ${{ steps.file.outputs.basename }}.json >> body.txt
|
2023-10-05 18:05:01 +08:00
|
|
|
echo '```' >> body.txt
|
2023-10-11 19:05:54 +08:00
|
|
|
gh pr comment ${{ steps.current_branch.outputs.name }} --body-file body.txt
|