Skip to content

refactor: improve CLI value parsing/docs #170

refactor: improve CLI value parsing/docs

refactor: improve CLI value parsing/docs #170

Workflow file for this run

name: Benchmark
on:
push:
branches: [main]
paths:
- cpp-linter/src/**
- cpp-linter/Cargo.toml
- Cargo.toml
- Cargo.lock
- .github/workflows/benchmark.yml
pull_request:
branches: [main]
paths:
- cpp-linter/src/**
- cpp-linter/Cargo.toml
- Cargo.toml
- Cargo.lock
- .github/workflows/benchmark.yml
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build-bin:
name: Build ${{ matrix.name }} binary
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
env:
BIN: target/release/cpp-linter
steps:
- name: Checkout ${{ matrix.name }}
uses: actions/checkout@v5
with:
ref: ${{ matrix.commit }}
persist-credentials: false
- name: Cache base ref build
uses: actions/cache@v4
id: cache
with:
key: bin-cache-${{ hashFiles('cpp-linter/src/**', 'Cargo.toml', 'Cargo.lock', 'cpp-linter/Cargo.toml') }}
path: ${{ env.BIN }}
- name: Validate cached binary
if: steps.cache.outputs.cache-hit == 'true'
id: validate
run: |
chmod +x ${{ env.BIN }}
if ! ${{ env.BIN }} version; then
echo "Cached binary is invalid, rebuilding..."
echo "cache-valid=false" >> "$GITHUB_OUTPUT"
fi
- run: rustup update --no-self-update
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
- run: cargo build --bin cpp-linter --release
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
- name: Upload build artifact
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.name }}
path: ${{ env.BIN }}
build-py-binding:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
id: setup-python
with:
python-version: '3.x'
- name: Build wheels
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
with:
target: x86_64
args: --release --out dist --find-interpreter
manylinux: auto
before-script-linux: |
# NOTE: rust-cross/manylinux docker images are CentOS based
yum update -y
yum install -y openssl openssl-devel
- name: Upload wheels
uses: actions/upload-artifact@v5
with:
name: wheel
path: dist/*
benchmark:
name: Measure Performance Difference
needs: [build-bin, build-py-binding]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Checkout libgit2
uses: actions/checkout@v5
with:
repository: libgit2/libgit2
ref: v1.8.1
path: benchmark/libgit2
persist-credentials: false
- name: Download built binaries
uses: actions/download-artifact@v6
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@afcf9780305558bcc9e4bc94b7589ab2bb8b6106 # v1.15.9
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Install hyperfine
env:
GITHUB_TOKEN: ${{ github.token }}
run: cargo binstall -y hyperfine
- name: Install nushell
uses: hustcer/setup-nu@3a97c8160c2bb5af321a03336e7addc28f94444e # v3.21
- name: Install uv
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
- name: Run benchmark script
working-directory: benchmark
shell: nu {0}
run: |-
let new_py = (
glob "../wheel/cpp_linter-*.whl"
| first
| path expand
)
let prev_bin = "../previous/cpp-linter" | path expand
let curr_bin = "../current/cpp-linter" | path expand
nu benchmark.nu --new-py $new_py --rust-bin $curr_bin --prev-rust-bin $prev_bin