Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Update github actions #1221

Update github actions

Update github actions #1221

Workflow file for this run

name: Benchmarks
on:
pull_request:
branches: [ '**' ]
types: [opened, synchronize, reopened, labeled]
env:
PROMSCALE_LOGGING: false
SKIP_PROMQL_BENCHMARKS: true
golang-version: 1.22.1
jobs:
benchmark:
if: contains( github.event.pull_request.labels.*.name, 'action:benchmarks')
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@v3
- name: Set up Go ${{ env.golang-version }}
uses: actions/setup-go@v3.5.0
with:
go-version: ${{ env.golang-version }}
id: go
- name: Benchmark current PR
run: go test -bench=. -run=^$ -benchmem -cpu=1 -count=10 -timeout=6h ./... | tee current.txt
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: current
path: current.txt
- name: Checkout master branch
uses: actions/checkout@v3
with:
ref: 'master'
- name: Benchmark Master
run: go test -bench=. -run=^$ -benchmem -cpu=1 -count=10 -timeout=6h ./... | tee master.txt
- name: Download results of "Benchmark current PR"
uses: actions/download-artifact@v3
with:
name: current
- name: Install benchstat
run: go install -a golang.org/x/perf/cmd/benchstat@latest
- name: Compare
id: compare
run: |
OUTPUT=$(benchstat master.txt current.txt)
echo "${OUTPUT}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "result=$OUTPUT" >> ${GITHUB_OUTPUT}
- name: Publish results as comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: compare
message: |
@${{ github.event.pull_request.user.login }}
## Benchmark Result for **${{ github.sha }}**
### Master vs PR
```
${{ steps.compare.outputs.result }}
```