Skip to content

add CI to detect performance regressions #7

add CI to detect performance regressions

add CI to detect performance regressions #7

Workflow file for this run

name: Performance Regression
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- commit: ${{ github.sha }}
name: current
- commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
name: previous
steps:
- name: Checkout ${{ matrix.name }}
uses: actions/checkout@v4
with:
ref: ${{ matrix.commit }}
- name: Cache base ref build
uses: actions/cache@v4
id: cache
with:
key: bin-cache-${{ matrix.name }}-${{ matrix.commit }}
path: target/release/cpp-linter
- run: rustup update --no-self-update
if: steps.cache.outputs.cache-hit != 'true'
- run: cargo build --bin cpp-linter --release
if: steps.cache.outputs.cache-hit != 'true'
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: target/release/cpp-linter
benchmark:
name: Measure Performance Difference
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout libgit2
uses: actions/checkout@v4
with:
repository: libgit2/libgit2
ref: v1.8.1
path: libgit2
- name: Download built binaries
uses: actions/download-artifact@v4
- name: Make binaries executable
run: chmod +x ./*/cpp-linter
- name: Generate compilation database
working-directory: libgit2
run: |
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install hyperfine
run: cargo binstall -y hyperfine
- name: Warmup and list files
env:
CPP_LINTER_COLOR: true
working-directory: libgit2
# Use previous build for stability. This will
# - create the .cpp-linter_cache folder
# - list the files concerning the benchmark test
# NOTE: This does not actually invoke clang tools.
run: ../previous/cpp-linter -l 0 -p build -i='|!src/libgit2' -s="" -c="-*"
- name: Run hyperfine tool
# using the generated compilation database,
# we will use cpp-linter (both builds) to scan libgit2 sources.
working-directory: libgit2
run: >-
hyperfine
--runs 3
--style color
--export-markdown '${{ runner.temp }}/benchmark.md'
--export-json '${{ runner.temp }}/benchmark.json'
--command-name=previous-build
"../previous/cpp-linter -l 0 -p build -i='|!src/libgit2'"
--command-name=current-build
"../current/cpp-linter -l 0 -p build -i='|!src/libgit2'"
- name: Append report to job summary
run: cat ${{ runner.temp }}/benchmark.md >> $GITHUB_STEP_SUMMARY
- name: Upload JSON results
uses: actions/upload-artifact@v4
with:
path: ${{ runner.temp }}/benchmark.json
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Annotate summary
run: python .github/workflows/bench.py "${{ runner.temp }}/benchmark.json"