Do not go too deep in Git history #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bench | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: short | |
OPENSSL_STATIC: true | |
PKG_CONFIG_ALLOW_CROSS: true | |
jobs: | |
# Ensure various stress tests pass on all platforms | |
stress: | |
name: Stress | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
# Linux builds using cross | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
use-cross: true | |
artifact_name: yek | |
asset_name: yek-x86_64-unknown-linux-gnu.tar.gz | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
use-cross: true | |
artifact_name: yek | |
asset_name: yek-aarch64-unknown-linux-gnu.tar.gz | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
use-cross: true | |
artifact_name: yek | |
asset_name: yek-x86_64-unknown-linux-musl.tar.gz | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
use-cross: true | |
artifact_name: yek | |
asset_name: yek-aarch64-unknown-linux-musl.tar.gz | |
# Native macOS builds | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
artifact_name: yek | |
asset_name: yek-x86_64-apple-darwin.tar.gz | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
artifact_name: yek | |
asset_name: yek-aarch64-apple-darwin.tar.gz | |
# Native Windows builds | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
artifact_name: yek.exe | |
asset_name: yek-x86_64-pc-windows-msvc.zip | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
artifact_name: yek.exe | |
asset_name: yek-aarch64-pc-windows-msvc.zip | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install OpenSSL (Ubuntu) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pkg-config libssl-dev | |
- name: Install OpenSSL (macOS) | |
if: runner.os == 'macOS' | |
run: | | |
brew install openssl@3 | |
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV | |
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV | |
- name: Install OpenSSL (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
choco install openssl --params='/InstallationPath:C:\OpenSSL\' | |
echo "OPENSSL_DIR=C:\OpenSSL" >> $env:GITHUB_ENV | |
echo "PKG_CONFIG_PATH=C:\OpenSSL\lib\pkgconfig" >> $env:GITHUB_ENV | |
- name: Install cross (Linux) | |
if: matrix.use-cross | |
run: cargo install cross | |
- name: Setup Rust (Native builds) | |
if: ${{ !matrix.use-cross }} | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt,clippy | |
- name: Install Rust target | |
if: ${{ !matrix.use-cross }} | |
run: rustup target add ${{ matrix.target }} | |
- name: Build with cross (Linux) | |
if: matrix.use-cross | |
run: cross build --release --target ${{ matrix.target }} | |
- name: Native build (macOS/Windows) | |
if: ${{ !matrix.use-cross }} | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Install yek | |
run: cargo install --path . --all-features | |
- name: Checkout VSCode repository | |
uses: actions/checkout@v4 | |
with: | |
repository: microsoft/vscode | |
path: vscode | |
fetch-depth: 1 | |
- name: Run yek | |
timeout-minutes: 1 | |
run: cd vscode && yek | |
benchmark: | |
name: Benchmark / ${{ matrix.benchmark_group.name }} | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
benchmark_group: | |
- group: "SingleFile_ByteMode" | |
name: "Single File Byte Mode" | |
- group: "SingleFile_ByteMode_Large" | |
name: "Single File Byte Mode Large" | |
- group: "SingleFile_TokenMode_Large" | |
name: "Single File Token Mode Large" | |
- group: "MultipleFiles_Small" | |
name: "Multiple Files Small" | |
- group: "MultipleFiles_Medium" | |
name: "Multiple Files Medium" | |
- group: "MultipleFiles_Large" | |
name: "Multiple Files Large" | |
- group: "MultipleFiles_TokenMode" | |
name: "Multiple Files Token Mode" | |
- group: "CustomConfig" | |
name: "Custom Config" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
- name: Build benchmarks on target branch | |
run: | | |
git fetch origin ${{ github.base_ref }} | |
git checkout ${{ github.base_ref }} | |
cargo bench --bench serialization --no-run | |
- name: Run benchmark on target branch | |
run: cargo bench --bench serialization -- --save-baseline ${{ github.base_ref }} '${{ matrix.benchmark_group.group }}/' | |
- name: Build benchmarks on PR branch | |
run: | | |
git checkout ${{ github.head_ref }} | |
cargo bench --bench serialization --no-run | |
- name: Compare benchmarks | |
run: | | |
cargo bench --bench serialization -- --baseline ${{ github.base_ref }} --noise-threshold 2 '${{ matrix.benchmark_group.group }}/' > benchmark_results.md | |
echo "## Benchmark Results for ${{ matrix.benchmark_group.name }}" >> $GITHUB_STEP_SUMMARY | |
cat benchmark_results.md >> $GITHUB_STEP_SUMMARY | |
- name: Upload benchmark results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: criterion-${{ matrix.benchmark_group.group }}-results | |
path: benchmark_results.md | |
if-no-files-found: error |