Skip to content

ci(Qodana): add qodana.yaml & GitHub workflow #96

ci(Qodana): add qodana.yaml & GitHub workflow

ci(Qodana): add qodana.yaml & GitHub workflow #96

Workflow file for this run

name: Testing
on:
push:
pull_request:
permissions:
contents: write
pull-requests: write
jobs:
test:
name: Test w/ go test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@v6
with:
go-version: 1.25.1
- name: Run tests
run: |
go mod tidy
go test -v ./...
benchmark:
name: Benchmark w/ go test & benchstat
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@v6
with:
go-version: 1.25.1
- name: Install benchstat
run: |
go install golang.org/x/perf/cmd/benchstat@latest
- name: Run benchmark on base branch
if: github.event_name == 'pull_request'
run: |
git checkout ${{ github.event.pull_request.base.sha }}
go mod tidy
go test -v -run ^$ -bench . -count ${{ vars.GO_BENCHMARK_COUNT }} -benchmem > base-bench.txt
git checkout ${{ github.event.pull_request.head.sha }}
- name: Run benchmark on HEAD commit
run: |
go mod tidy
go test -v -run ^$ -bench . -count ${{ vars.GO_BENCHMARK_COUNT }} -benchmem > head-bench.txt
- name: Compare benchmarks
if: github.event_name == 'pull_request'
run: |
cat > benchmark-comment.md << EOF
## Benchmark comparison w/ base branch
\`\`\`
$(benchstat base-bench.txt head-bench.txt)
\`\`\`
EOF
- name: Comment PR w/ benchmark comparison
if: github.event_name == 'pull_request'
uses: actions/github-script@v8
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: require('fs').readFileSync('benchmark-comment.md', 'utf8')
});