From 714f40b7db7256e29764f5812de4428251198acf Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Thu, 14 Dec 2023 01:22:12 +0530 Subject: [PATCH] chore: comment bench results on PR Signed-off-by: Pranshu Srivastava --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ tests/compare_benchmarks.sh | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 911ff7d0b1..d5e4281bd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,6 +166,28 @@ jobs: run: | make test-benchmark-compare + comment-ci-benchmark-tests: + name: comment-ci-benchmark-tests + runs-on: ubuntu-latest + needs: ci-benchmark-tests + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Comment benchmark results + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.KSM_BOT_TOKEN }} + script: | + const fs = require('fs'); + const data = fs.readFileSync('benchstat.txt', 'utf8'); + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: data + }); + ci-build-kube-state-metrics: name: ci-build-kube-state-metrics runs-on: ubuntu-latest diff --git a/tests/compare_benchmarks.sh b/tests/compare_benchmarks.sh index d05a52dbde..75bfd0d79a 100755 --- a/tests/compare_benchmarks.sh +++ b/tests/compare_benchmarks.sh @@ -38,4 +38,7 @@ echo "" echo "### Result" echo "old=${REF_TO_COMPARE} new=${REF_CURRENT}" -benchstat "${RESULT_TO_COMPARE}" "${RESULT_CURRENT}" +benchstat "${RESULT_TO_COMPARE}" "${RESULT_CURRENT}" > benchstat.txt +if [[ -z "${CI:-}" ]]; then + cat benchstat.txt +fi