Skip to content

Nightly Benchmarks #140

Nightly Benchmarks

Nightly Benchmarks #140

---
name: Nightly Benchmarks
on:
schedule:
# Run at 2 AM UTC every day
- cron: "0 2 * * *"
workflow_dispatch:
inputs:
jmh_args:
description: "Additional JMH arguments (e.g., '-f 1 -wi 1 -i 3' for quick run)"
required: false
default: ""
permissions: {}
concurrency:
group: "benchmarks"
defaults:
run:
shell: bash
jobs:
benchmark:
runs-on: ubuntu-24.04
permissions:
contents: read # checkout only
steps:
- name: Checkout main branch
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
fetch-depth: 0
- name: Setup mise
uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
with:
version: v2026.5.18
sha256: cfac593469d028d7ae5fe36e37bd7c59118b5238e92d8a876209578464f24a84
- name: Cache local Maven repository
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run JMH benchmarks
run: mise run benchmark:ci-json
env:
JMH_ARGS: ${{ github.event.inputs.jmh_args }}
- name: Generate benchmark summary
run: |
mise run benchmark:generate-summary \
--input benchmark-results.json \
--output-dir benchmark-results \
--commit-sha "${{ github.sha }}"
env:
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Upload benchmark results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-results
path: benchmark-results
retention-days: 5
publish:
runs-on: ubuntu-24.04
needs: benchmark
permissions:
contents: write # push generated results to the benchmarks branch
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
# zizmor: ignore[artipacked] -- needs credentials to push to benchmarks branch
persist-credentials: true
fetch-depth: 0
- name: Download benchmark results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: benchmark-results
path: /tmp/benchmark-output
- name: Commit and push results to benchmarks branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Checkout or create benchmarks branch (use -- to disambiguate from benchmarks/ directory)
if git ls-remote --heads origin benchmarks | grep -q benchmarks; then
git fetch origin benchmarks
git switch benchmarks
# Preserve existing history
if [ -d history ]; then
cp -r history /tmp/benchmark-output/
fi
else
git switch --orphan benchmarks
fi
# Clean working directory
git rm -rf . 2>/dev/null || true
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# Copy only the benchmark results
cp -r /tmp/benchmark-output/* .
git add README.md results.json history/
DATE=$(date -u +"%Y-%m-%d")
COMMIT_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
git commit \
-m "Benchmark results for ${DATE} (${COMMIT_SHORT})" \
-m "From commit ${{ github.sha }}" \
|| echo "No changes to commit"
git push origin benchmarks --force-with-lease || git push origin benchmarks