From e1ef6a88d75ffb0c4a5d0b3005e2b54e0c05a6c2 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 | 21 +++++++++++++++++++++ .gitignore | 3 +++ tests/compare_benchmarks.sh | 10 +++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 911ff7d0b1..3242d89b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,6 +166,27 @@ 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: + 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/.gitignore b/.gitignore index 33fd299d11..db5f1719a6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,8 @@ _testmain.go # Generated CLI help file help.txt +# Generated benchmark data +benchstat.txt + # jsonnet dependency management /scripts/vendor diff --git a/tests/compare_benchmarks.sh b/tests/compare_benchmarks.sh index d05a52dbde..1b679465ad 100755 --- a/tests/compare_benchmarks.sh +++ b/tests/compare_benchmarks.sh @@ -38,4 +38,12 @@ echo "" echo "### Result" echo "old=${REF_TO_COMPARE} new=${REF_CURRENT}" -benchstat "${RESULT_TO_COMPARE}" "${RESULT_CURRENT}" +BENCHSTAT_OUT=$(benchstat "${RESULT_TO_COMPARE}" "${RESULT_CURRENT}") + +# Display the result. +cat <> "benchstat.txt"