Skip to content

Commit

Permalink
ci: improve CI & tests (#4)
Browse files Browse the repository at this point in the history
* ci: improve CI & tests

* chore: Switch to lurk-lab fork of abomonation_derive

- Updated the repository source for the `abomonation_derive` dependency in the Cargo.toml file
- Switched from `winston-h-zhang` repository to `lurk-lab` for more updated and maintained versions

* chore: add dependabot config
  • Loading branch information
huitseeker authored Aug 18, 2023
1 parent 76aa073 commit e59041c
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[profile.ci]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Show skipped tests in the CI output.
status-level = "skip"
# Do not cancel the test run on the first failure.
fail-fast = false
# Mark tests as slow after 5mins, kill them after 20mins
slow-timeout = { period = "300s", terminate-after = 4 }
# Retry failed tests once, marked flaky if test then passes
retries = 1
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: cargo
directory: /
pull-request-branch-name:
separator: "-"
schedule:
interval: weekly
groups:
rust-dependencies:
patterns:
- "*"
open-pull-requests-limit: 5

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
74 changes: 50 additions & 24 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
name: Build and Test Nova

on:
merge_group:
push:
branches: [ main ]
branches: [ dev ]
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, ready_for_review]
branches: [ dev ]

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
- name: Install
run: rustup default stable
- name: Install rustfmt Components
run: rustup component add rustfmt
- name: Install clippy
run: rustup component add clippy
- name: Install Wasm target
run: rustup target add wasm32-unknown-unknown
- name: Build
run: cargo build --verbose
- name: Wasm build
run: cargo build --target wasm32-unknown-unknown
- name: Build examples
run: cargo build --examples --verbose
- name: Build benches
run: cargo build --benches --verbose
- name: Run tests
run: cargo +stable test --release --verbose
- name: Check Rustfmt Code Style
run: cargo fmt --all -- --check
- name: Check clippy warnings
run: cargo clippy --all-targets -- -D warnings
- name: Setup Rust
uses: actions-rs/toolchain@v1
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Build, with benches & examples
run: cargo build --profile dev-ci --benches --examples
- name: Linux Tests in parallel, with nextest profile ci and cargo profile dev-ci
run: |
cargo nextest run --profile ci --workspace --cargo-profile dev-ci
misc:
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: rustup target add wasm32-unknown-unknown
- name: Wasm build
run: cargo build --target wasm32-unknown-unknown
- name: Check Rustfmt Code Style
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check clippy warnings
run: cargo clippy --all-targets -- -D warnings
- name: Doctests
run: cargo test --doc --workspace
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ halo2curves = { version = "0.4.0", features = ["derive_serde"] }
group = "0.13.0"
log = "0.4.17"
abomonation = "0.7.3"
abomonation_derive = { git = "https://github.com/winston-h-zhang/abomonation_derive.git" }
abomonation_derive = { git = "https://github.com/lurk-lab/abomonation_derive.git" }

[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
pasta-msm = { git="https://github.com/lurk-lab/pasta-msm", branch="dev", version = "0.1.4" }
Expand Down Expand Up @@ -88,3 +88,11 @@ supernova = []
# This is needed to ensure halo2curves, which imports pasta-curves, uses the *same* traits in bn256_grumpkin
[patch.crates-io]
pasta_curves = { git="https://github.com/lurk-lab/pasta_curves", branch="dev" }

[profile.dev-ci]
inherits = "dev"
# By compiling dependencies with optimizations, performing tests gets much faster.
opt-level = 3
lto = "thin"
incremental = false
codegen-units = 16
6 changes: 3 additions & 3 deletions examples/minroot_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsafe fn entomb_F<F: PrimeField, W: Write>(f: &F, bytes: &mut W) -> std::io::Re
}

/// this is **incredibly, INCREDIBLY** dangerous
unsafe fn exhume_F<'a, 'b, F: PrimeField>(f: &mut F, bytes: &'a mut [u8]) -> Option<&'a mut [u8]> {
unsafe fn exhume_F<'a, F: PrimeField>(f: &mut F, bytes: &'a mut [u8]) -> Option<&'a mut [u8]> {
let (mine, rest) = bytes.split_at_mut(size_of::<F>());
let mine = (mine as *const [u8]) as *const F;
std::ptr::write(f, std::ptr::read(mine));
Expand All @@ -60,7 +60,7 @@ impl<F: PrimeField> abomonation::Abomonation for MinRootIteration<F> {
Ok(())
}

unsafe fn exhume<'a, 'b>(&'a mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
unsafe fn exhume<'b>(&mut self, bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
let bytes = exhume_F(&mut self.x_i, bytes)?;
let bytes = exhume_F(&mut self.y_i, bytes)?;
let bytes = exhume_F(&mut self.x_i_plus_1, bytes)?;
Expand Down Expand Up @@ -195,7 +195,7 @@ fn main() {
TrivialTestCircuit<<G2 as Group>::Scalar>,
>::setup(&circuit_primary, &circuit_secondary);
assert!(result.clone() == pp, "not equal!");
assert!(remaining.len() == 0);
assert!(remaining.is_empty());
} else {
println!("Something terrible happened");
}
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.70.0
1 change: 1 addition & 0 deletions src/gadgets/r1cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ pub fn conditionally_select_alloc_relaxed_r1cs<
Ok(c)
}

#[allow(dead_code)]
/// c = cond ? a: b, where a, b: vec[AllocatedRelaxedR1CSInstance]
pub fn conditionally_select_vec_allocated_relaxed_r1cs_instance<
G: Group,
Expand Down

0 comments on commit e59041c

Please sign in to comment.