Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ jobs:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-test-${{ matrix.os }}-${{ matrix.rust }}
cache-workspace-crates: "true"
shared-key: cargo-${{ matrix.os }}-${{ matrix.rust }}
- name: Build
run: cargo build
- name: Cargo Test
Expand All @@ -58,8 +57,7 @@ jobs:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-clippy-${{ runner.os }}-stable
cache-workspace-crates: "true"
shared-key: cargo-${{ runner.os }}-stable
- run: cargo clippy

unused-deps:
Expand All @@ -70,10 +68,6 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-unused-deps-${{ runner.os }}-stable
cache-workspace-crates: "true"
- name: Install machete
run: cargo install cargo-machete
- name: Check for unused dependencies
Expand Down
48 changes: 21 additions & 27 deletions .github/workflows/cli_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,37 @@ concurrency:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
golden_bin: target/regression-golden/bender
- runner: windows-latest
target: x86_64-pc-windows-msvc
golden_bin: target/regression-golden/bender.exe
- runner: macos-latest
target: aarch64-apple-darwin
golden_bin: target/regression-golden/bender
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Run CLI Regression
run: cargo test --test cli_regression -- --ignored
env:
BENDER_TEST_GOLDEN_BRANCH: ${{ github.base_ref }}

test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Run CLI Regression
run: cargo test --test cli_regression -- --ignored
env:
BENDER_TEST_GOLDEN_BRANCH: ${{ github.base_ref }}

test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- uses: Swatinem/rust-cache@v2
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
shared-key: cargo-${{ runner.os }}-stable
- name: Restore CLI regression golden binary
uses: actions/cache/restore@v5
with:
toolchain: stable
path: target/regression-golden
key: golden-bender-${{ matrix.target }}-${{ github.event.pull_request.base.sha || github.sha }}
- name: Run CLI Regression
run: cargo test --test cli_regression -- --ignored
env:
BENDER_TEST_GOLDEN_BRANCH: ${{ github.base_ref }}
BENDER_TEST_GOLDEN_BIN: ${{ matrix.golden_bin }}
35 changes: 28 additions & 7 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ jobs:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-22.04
container: quay.io/pypa/manylinux_2_28_x86_64
cache_golden_bin: false
- target: aarch64-unknown-linux-gnu
runner: ubuntu-22.04-arm
container: quay.io/pypa/manylinux_2_28_aarch64
- target: x86_64-apple-darwin
runner: macos-latest
cache_golden_bin: false
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
cache_golden_bin: true
- target: aarch64-apple-darwin
runner: macos-15
runner: macos-latest
cache_golden_bin: true
- target: x86_64-apple-darwin
runner: macos-15-intel
cache_golden_bin: false
- target: x86_64-pc-windows-msvc
runner: windows-latest
cache_golden_bin: true
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -51,9 +59,22 @@ jobs:
if: ${{ !matrix.container }}
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: release-build-${{ matrix.target }}
cache-workspace-crates: "true"
- name: Build (release)
run: cargo build --release
- name: Prepare CLI regression golden binary
if: ${{ matrix.cache_golden_bin && runner.os != 'Windows' }}
run: |
mkdir -p target/regression-golden
cp target/release/bender target/regression-golden/bender
- name: Prepare CLI regression golden binary
if: ${{ matrix.cache_golden_bin && runner.os == 'Windows' }}
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path target/regression-golden | Out-Null
Copy-Item target/release/bender.exe target/regression-golden/bender.exe
- name: Cache CLI regression golden binary
if: ${{ matrix.cache_golden_bin }}
uses: actions/cache/save@v5
with:
path: target/regression-golden
key: golden-bender-${{ matrix.target }}-${{ github.sha }}
46 changes: 41 additions & 5 deletions tests/cli_regression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,54 @@ use pretty_assertions::assert_eq;

static SETUP: OnceLock<(PathBuf, PathBuf)> = OnceLock::new();

fn golden_binary_name() -> &'static str {
if cfg!(windows) {
"bender.exe"
} else {
"bender"
}
}

fn non_empty_env_var(key: &str) -> Option<String> {
std::env::var(key).ok().filter(|value| !value.is_empty())
}

fn get_test_env() -> &'static (PathBuf, PathBuf) {
SETUP.get_or_init(|| {
let root = Path::new("target/tmp_regression");
let install_root = root.join("golden_install");
let repo_dir = Path::new("tests/cli_regression").to_path_buf();

if let Some(prebuilt_bin) = non_empty_env_var("BENDER_TEST_GOLDEN_BIN") {
let bender_exe = std::env::current_dir().unwrap().join(prebuilt_bin);
if bender_exe.exists() {
println!("Using prebuilt golden bender binary: {:?}", bender_exe);

let status = SysCommand::new(&bender_exe)
.arg("checkout")
.current_dir(&repo_dir)
.status()
.expect("Failed to run bender checkout");
assert!(
status.success(),
"Failed to initialize common_cells with golden bender"
);

return (bender_exe, repo_dir);
}

println!(
"Prebuilt golden bender binary not found at {:?}, falling back to cargo install",
bender_exe
);
}

// Install Golden Bender
let bender_exe = install_root.join("bin").join("bender");
let bender_exe = install_root.join("bin").join(golden_binary_name());

let golden_branch = std::env::var("BENDER_TEST_GOLDEN_BRANCH")
.or_else(|_| std::env::var("GITHUB_BASE_REF")) // For GitHub Actions
.unwrap_or_else(|_| "master".to_string());
let golden_branch = non_empty_env_var("BENDER_TEST_GOLDEN_BRANCH")
.or_else(|| non_empty_env_var("GITHUB_BASE_REF")) // For GitHub Actions
.unwrap_or_else(|| "master".to_string());

println!("Using golden bender branch: {}", golden_branch);

Expand Down Expand Up @@ -59,7 +95,7 @@ fn get_test_env() -> &'static (PathBuf, PathBuf) {
"Failed to initialize common_cells with bender"
);

(bender_exe, repo_dir)
(bender_exe_abs, repo_dir)
})
}

Expand Down