From 181e7a1e537639e099d951a63596a058109f191b Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Thu, 5 Oct 2023 12:05:01 +0200 Subject: [PATCH 1/2] Introduce the first bot that triggers benchmarks --- .github/workflows/benchmarks-manual.yml | 2 +- .../trigger-benchmarks-on-message.yml | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/trigger-benchmarks-on-message.yml diff --git a/.github/workflows/benchmarks-manual.yml b/.github/workflows/benchmarks-manual.yml index 44793fc17..b967eb073 100644 --- a/.github/workflows/benchmarks-manual.yml +++ b/.github/workflows/benchmarks-manual.yml @@ -74,4 +74,4 @@ jobs: echo "${{ steps.file.outputs.basename }}.json has just been pushed." echo 'How to compare this benchmark with another one?' echo ' - Check the available files with: ./benchmarks/scripts/list.sh' - echo " - Run the following command: ./benchmaks/scipts/compare.sh ${{ steps.file.outputs.basename }}.json" + echo " - Run the following command: ./benchmaks/scripts/compare.sh ${{ steps.file.outputs.basename }}.json" diff --git a/.github/workflows/trigger-benchmarks-on-message.yml b/.github/workflows/trigger-benchmarks-on-message.yml new file mode 100644 index 000000000..86a1ad50e --- /dev/null +++ b/.github/workflows/trigger-benchmarks-on-message.yml @@ -0,0 +1,76 @@ +name: Run and display benchmarks in a PR +on: + issue_comment: + types: [created, edited] + +env: + BENCH_NAME: search_geo + GH_TOKEN: ${{ secrets.MEILI_BOT_GH_PAT }} + +jobs: + run-benchmarks-on-comment: + if: contains(github.event.comment.body, '@meilisearch run benchmarks') + name: Run and upload benchmarks + runs-on: benchmarks + timeout-minutes: 4320 # 72h + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + # Set variables + - name: Set current branch name + shell: bash + run: echo "name=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT + id: current_branch + - name: Set normalized current branch name # Replace `/` by `_` in branch name to avoid issues when pushing to S3 + shell: bash + run: echo "name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT + 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 + run: echo "basename=$(echo ${BENCH_NAME}_${{ steps.normalized_current_branch.outputs.name }}_${{ steps.commit_sha.outputs.short }})" >> $GITHUB_OUTPUT + id: file + + # Run benchmarks + - name: Run benchmarks - Dataset ${BENCH_NAME} - Branch ${{ steps.current_branch.outputs.name }} - Commit ${{ steps.commit_sha.outputs.short }} + run: | + cd benchmarks + cargo bench --bench ${BENCH_NAME} -- --save-baseline ${{ steps.file.outputs.basename }} + + # 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 + run: | + export base=git rev-parse $(git cherry main | head -n 1 | cut -c 3-)~ | cut -c -8 + echo 'Here are your benchmarks diff 👊' >> body.txt + echo '```' >> body.txt + ./benchmaks/scipts/compare.sh $base ${{ steps.file.outputs.basename }}.json >> body.txt + echo '```' >> body.txt + gh pr comment ${GITHUB_REF#refs/heads/} --body-file body.txt From 92c280d1c88416bebacf1b0d41880c5f30ac1f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 5 Oct 2023 12:09:52 +0200 Subject: [PATCH 2/2] Update .github/workflows/trigger-benchmarks-on-message.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clémentine U. - curqui --- .github/workflows/trigger-benchmarks-on-message.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-benchmarks-on-message.yml b/.github/workflows/trigger-benchmarks-on-message.yml index 86a1ad50e..ef90ae851 100644 --- a/.github/workflows/trigger-benchmarks-on-message.yml +++ b/.github/workflows/trigger-benchmarks-on-message.yml @@ -1,4 +1,4 @@ -name: Run and display benchmarks in a PR +name: Benchmarks (PR) on: issue_comment: types: [created, edited]