From c4ab2d87879469889748ade31ca49331ef3e2ecd Mon Sep 17 00:00:00 2001 From: "Ya-wen, Jeng" Date: Fri, 31 Jan 2025 21:56:40 +0800 Subject: [PATCH] cache artifacts --- .github/workflows/build-and-test.yml | 102 +++++++++++++++------------ build.rs | 34 +++++++++ 2 files changed, 91 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4f04ea7..b5fdd9f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,45 +13,50 @@ env: CARGO_TERM_COLOR: always jobs: - clippy_check: - runs-on: ubuntu-latest - env: - RUSTFLAGS: "-Dwarnings" # Make sure CI fails on all warnings, including Clippy lints - steps: - - uses: actions/checkout@v4 - - name: Run Clippy - run: cargo clippy --all-targets --all-features - lint: - runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 + # clippy_check: + # runs-on: ubuntu-latest + # env: + # RUSTFLAGS: "-Dwarnings" # Make sure CI fails on all warnings, including Clippy lints + # steps: + # - uses: actions/checkout@v4 + # - name: Run Clippy + # run: cargo clippy --all-targets --all-features + # lint: + # runs-on: ubuntu-latest + # if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + # steps: + # - uses: actions/checkout@v4 - - name: Check formatting - run: cargo fmt --all -- --check - build-ios: - runs-on: macos-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - strategy: - matrix: - target: - - aarch64-apple-ios - - aarch64-apple-ios-sim - - x86_64-apple-ios - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: "1.81.0" - targets: ${{ matrix.target }} - - name: Build - run: cargo build --target ${{ matrix.target }} + # - name: Check formatting + # run: cargo fmt --all -- --check + # build-ios: + # runs-on: macos-latest + # if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + # strategy: + # matrix: + # target: + # - aarch64-apple-ios + # - aarch64-apple-ios-sim + # - x86_64-apple-ios + # steps: + # - name: Checkout Repository + # uses: actions/checkout@v4 + # - name: Install Rust + # uses: dtolnay/rust-toolchain@stable + # with: + # toolchain: "1.81.0" + # targets: ${{ matrix.target }} + # - name: Build + # run: cargo build --target ${{ matrix.target }} test-linux: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name steps: + - name: install requirements + uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: curl xz-utils build-essential cmake m4 nasm libstdc++6 + version: 1.0 - uses: actions/checkout@v4 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -60,15 +65,22 @@ jobs: override: true - name: Run tests run: cargo test -vv - test-macOS: - runs-on: macos-latest - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - steps: - - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + - name: Upload Linux x86_64 dev artifacts + uses: actions/upload-artifact@v4 with: - toolchain: "1.81.0" - override: true - - name: Run tests - run: cargo test + name: rapidsnark-linux-x86_64 + path: | + lib + if-no-files-found: error + # test-macOS: + # runs-on: macos-latest + # if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + # steps: + # - uses: actions/checkout@v4 + # - name: Install Rust toolchain + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: "1.81.0" + # override: true + # - name: Run tests + # run: cargo test diff --git a/build.rs b/build.rs index b71eac5..6de3f08 100644 --- a/build.rs +++ b/build.rs @@ -6,6 +6,25 @@ use std::process::Command; const CLONE_RAPIDSNARK_SCRIPT: &str = include_str!("./clone_rapidsnark.sh"); +fn copy_dir_recursive(src: &Path, dest: &Path) -> std::io::Result<()> { + if !dest.exists() { + fs::create_dir_all(dest)?; + } + + for entry in fs::read_dir(src)? { + let entry = entry?; + let src_path = entry.path(); + let dest_path = dest.join(entry.file_name()); + + if src_path.is_dir() { + copy_dir_recursive(&src_path, &dest_path)?; + } else { + fs::copy(&src_path, &dest_path)?; + } + } + Ok(()) +} + fn main() { if std::env::var("RUST_RAPIDSNARK_LINK_TEST_WITNESS").is_ok() { rust_witness::transpile::transpile_wasm("./test-vectors".to_string()); @@ -82,6 +101,21 @@ fn main() { .wait() .expect("make arm64_host errored"); + // Copy lib_dir to the current directory + let lib_dir = PathBuf::from(lib_dir); + let current_dir = std::env::current_dir().unwrap(); + let lib_dir_name = lib_dir.file_name().unwrap(); + let new_lib_dir = current_dir.join(lib_dir_name); + println!("new_lib_dir: {}", new_lib_dir.to_string_lossy()); + if !new_lib_dir.exists() { + std::fs::create_dir_all(&new_lib_dir).unwrap(); + } + if lib_dir.is_dir() { + copy_dir_recursive(&lib_dir, &new_lib_dir).unwrap(); + } else { + fs::copy(&lib_dir, &new_lib_dir).unwrap(); + } + // Try to list contents of the target directory let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); let rapidsnark_dir = manifest_dir.join("rapidsnark");