chore(deps): bump github.com/valyala/fasthttp from 1.48.0 to 1.49.0 in /benchmarks #134
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Benchmark | |
on: | |
pull_request: | |
permissions: | |
contents: read | |
pull-requests: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
packages: | |
name: Changed packages | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Find packages with changes | |
id: packages | |
uses: tj-actions/changed-files@v39 | |
with: | |
files: '**/*.go' | |
dir_names: true | |
json: true | |
- name: Set output | |
id: set-matrix | |
run: | | |
echo "matrix={\"package\":${{ steps.packages.outputs.all_changed_and_modified_files }}}" >> $GITHUB_OUTPUT | |
benchmark: | |
name: Benchmark ${{ matrix.package }} | |
needs: packages | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{ fromJSON(needs.packages.outputs.matrix) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Run benchmark | |
run: go test -bench=. -count=10 -benchmem ./${{ matrix.package }} | tee after | |
- name: Run benchmark for base code | |
run: | | |
git fetch --quiet origin master ${{ github.event.pull_request.base.sha }} | |
git reset --quiet --hard ${{ github.event.pull_request.base.sha }} | |
go test -bench=. -count=10 -benchmem ./${{ matrix.package }} | tee before | |
- name: Compare benchmarks | |
id: bench | |
run: | | |
GO111MODULE=off go get golang.org/x/perf/cmd/benchstat | |
OUTPUT=$(benchstat before after) | |
echo "${OUTPUT}" | |
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT | |
- name: Save benchmark results | |
uses: cloudposse/[email protected] | |
if: steps.bench.outputs.diff != '' | |
with: | |
matrix-step-name: ${{ github.job }} | |
matrix-key: ${{ matrix.package }} | |
outputs: ${{ toJSON(steps.bench.outputs) }} | |
comment: | |
name: Comment | |
needs: benchmark | |
runs-on: ubuntu-latest | |
steps: | |
- name: Load benchmark results | |
uses: cloudposse/[email protected] | |
id: read | |
with: | |
matrix-step-name: benchmark | |
- name: Generate comment text | |
uses: actions/github-script@v6 | |
if: steps.read.outputs.result != '{}' | |
id: parse | |
with: | |
result-encoding: string | |
script: | | |
const result = ${{ steps.read.outputs.result }} | |
return Object.keys(result.diff).sort().map((key) => ` | |
<details><summary><code>${key}</code></summary> | |
` + "```" + ` | |
${result.diff[key]} | |
` + "```" + ` | |
</details> | |
`).join('') | |
- name: Create comment | |
if: steps.parse.outputs.result != '' | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
header: benchmarks | |
message: | | |
### Benchmark Results | |
${{ steps.parse.outputs.result }} |