Skip to content

Commit

Permalink
cache artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianjeng committed Jan 31, 2025
1 parent d9ec711 commit c4ab2d8
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 45 deletions.
102 changes: 57 additions & 45 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
34 changes: 34 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit c4ab2d8

Please sign in to comment.