Skip to content

Fallback to local in-memory counter if Redis is unavailable #19

Fallback to local in-memory counter if Redis is unavailable

Fallback to local in-memory counter if Redis is unavailable #19

Workflow file for this run

name: Bechmark
on:
pull_request:
jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest
services:
redis:
image: redis:6
ports:
- 6379:6379
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.17
- name: Git clone (master)
uses: actions/checkout@v4
with:
ref: master
- name: Run benchmark (master)
run: go test -bench=. -count=10 -benchmem | tee /tmp/master.txt
- name: Git clone (PR)
uses: actions/checkout@v4
- name: Run benchmark (PR)
run: go test -bench=. -count=10 -benchmem | tee /tmp/pr.txt
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Run benchstat
run: cd /tmp && benchstat master.txt pr.txt | tee /tmp/result.txt
- name: Comment on PR with benchmark results
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('/tmp/result.txt', 'utf8');
const issue_number = context.payload.pull_request.number;
const { owner, repo } = context.repo;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `### Benchmark Results\n\n\`\`\`\n${results}\n\`\`\``
});