Skip to content

Commit

Permalink
chore: comment bench results on PR
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
rexagod committed Dec 13, 2023
1 parent 8c1153e commit e1ef6a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ _testmain.go
# Generated CLI help file
help.txt

# Generated benchmark data
benchstat.txt

# jsonnet dependency management
/scripts/vendor
10 changes: 9 additions & 1 deletion tests/compare_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
${BENCHSTAT_OUT}
EOF

# Append the result to the benchstat.txt file.
echo "${BENCHSTAT_OUT}" >> "benchstat.txt"

0 comments on commit e1ef6a8

Please sign in to comment.